summaryrefslogtreecommitdiff
path: root/mate-panel/wayland-backend.c
diff options
context:
space:
mode:
authorWilliam Wold <[email protected]>2019-06-20 18:18:30 +0000
committerraveit65 <[email protected]>2019-07-07 21:31:33 +0200
commit01fb4342ea56d467ad46a68a411ffb07b4d5d326 (patch)
tree0a47b8f6bb32e0a71de5dabaa49f3ede481e2749 /mate-panel/wayland-backend.c
parent188846cecfda3b8f19e45ca37a60d817bff2afed (diff)
downloadmate-panel-01fb4342ea56d467ad46a68a411ffb07b4d5d326.tar.bz2
mate-panel-01fb4342ea56d467ad46a68a411ffb07b4d5d326.tar.xz
Add Wayland backend
Diffstat (limited to 'mate-panel/wayland-backend.c')
-rw-r--r--mate-panel/wayland-backend.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/mate-panel/wayland-backend.c b/mate-panel/wayland-backend.c
new file mode 100644
index 00000000..0d797f33
--- /dev/null
+++ b/mate-panel/wayland-backend.c
@@ -0,0 +1,57 @@
+#include <config.h>
+
+#include <gtk-layer-shell/gtk-layer-shell.h>
+
+#include "wayland-backend.h"
+
+void
+wayland_panel_toplevel_init (PanelToplevel* toplevel)
+{
+ GtkWindow* window;
+
+ window = GTK_WINDOW (toplevel);
+ gtk_layer_init_for_window (window);
+ gtk_layer_set_layer (window, GTK_LAYER_SHELL_LAYER_TOP);
+ gtk_layer_set_namespace (window, "panel");
+ gtk_layer_auto_exclusive_zone_enable (window);
+ wayland_panel_toplevel_update_placement (toplevel);
+}
+
+void
+wayland_panel_toplevel_update_placement (PanelToplevel* toplevel)
+{
+ GtkWindow* window;
+ gboolean expand;
+ PanelOrientation orientation;
+ gboolean anchor[GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER];
+
+ window = GTK_WINDOW (toplevel);
+ expand = panel_toplevel_get_expand (toplevel);
+ orientation = panel_toplevel_get_orientation (toplevel);
+ for (int i = 0; i < GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER; i++)
+ anchor[i] = expand;
+
+ switch (orientation) {
+ case PANEL_ORIENTATION_LEFT:
+ anchor[GTK_LAYER_SHELL_EDGE_LEFT] = TRUE;
+ anchor[GTK_LAYER_SHELL_EDGE_RIGHT] = FALSE;
+ break;
+ case PANEL_ORIENTATION_RIGHT:
+ anchor[GTK_LAYER_SHELL_EDGE_RIGHT] = TRUE;
+ anchor[GTK_LAYER_SHELL_EDGE_LEFT] = FALSE;
+ break;
+ case PANEL_ORIENTATION_TOP:
+ anchor[GTK_LAYER_SHELL_EDGE_TOP] = TRUE;
+ anchor[GTK_LAYER_SHELL_EDGE_BOTTOM] = FALSE;
+ break;
+ case PANEL_ORIENTATION_BOTTOM:
+ anchor[GTK_LAYER_SHELL_EDGE_BOTTOM] = TRUE;
+ anchor[GTK_LAYER_SHELL_EDGE_TOP] = FALSE;
+ break;
+ default:
+ g_warning ("Invalid panel orientation %d", orientation);
+ }
+
+ for (int i = 0; i < GTK_LAYER_SHELL_EDGE_ENTRY_NUMBER; i++)
+ gtk_layer_set_anchor (window, i, anchor[i]);
+}