summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--configure.ac2
-rw-r--r--mate-panel/Makefile.am4
-rw-r--r--mate-panel/main.c10
-rw-r--r--mate-panel/panel-toplevel.c20
-rw-r--r--mate-panel/wayland-backend.c57
-rw-r--r--mate-panel/wayland-backend.h18
6 files changed, 109 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 4feaaa4c..debe5d09 100644
--- a/configure.ac
+++ b/configure.ac
@@ -223,8 +223,6 @@ AM_CONDITIONAL(ENABLE_X11, [test "x$have_x11" = "xyes"])
if test "x$have_x11" = "xyes"; then
AC_DEFINE(HAVE_X11, 1, [Have the X11 development library])
-else
- AC_MSG_ERROR([No support yet for non-X11 builds])
fi
if test "x$have_x11" != "xyes" -a "x$have_wayland" != "xyes"; then
diff --git a/mate-panel/Makefile.am b/mate-panel/Makefile.am
index e4bc90ac..4255db34 100644
--- a/mate-panel/Makefile.am
+++ b/mate-panel/Makefile.am
@@ -61,6 +61,8 @@ panel_sources = \
panel-reset.c
if ENABLE_WAYLAND
+panel_sources += \
+ wayland-backend.c
endif
if ENABLE_X11
@@ -120,6 +122,8 @@ panel_headers = \
panel-schemas.h
if ENABLE_WAYLAND
+panel_headers += \
+ wayland-backend.h
endif
if ENABLE_X11
diff --git a/mate-panel/main.c b/mate-panel/main.c
index 82d475c1..db1fafb4 100644
--- a/mate-panel/main.c
+++ b/mate-panel/main.c
@@ -37,6 +37,10 @@
#include "xstuff.h"
#endif
+#ifdef HAVE_WAYLAND
+#include "wayland-backend.h"
+#endif
+
/* globals */
GSList *panels = NULL;
GSList *panel_list = NULL;
@@ -181,6 +185,12 @@ main (int argc, char **argv)
gboolean found_backend = FALSE;
+#ifdef HAVE_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (display)) {
+ found_backend = TRUE;
+ }
+#endif
+
#ifdef HAVE_X11
if (GDK_IS_X11_DISPLAY (display)) {
xstuff_init ();
diff --git a/mate-panel/panel-toplevel.c b/mate-panel/panel-toplevel.c
index 8a7b6c7b..223d72b0 100644
--- a/mate-panel/panel-toplevel.c
+++ b/mate-panel/panel-toplevel.c
@@ -57,6 +57,9 @@
#include "panel-xutils.h"
#include "panel-struts.h"
#endif
+#ifdef HAVE_WAYLAND
+#include "wayland-backend.h"
+#endif
#define DEFAULT_SIZE 48
#define DEFAULT_AUTO_HIDE_SIZE 1
@@ -1557,6 +1560,11 @@ static gboolean panel_toplevel_update_struts(PanelToplevel* toplevel, gboolean e
}
#endif // HAVE_X11
+#ifdef HAVE_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))) {
+ wayland_panel_toplevel_update_placement (toplevel);
+ }
+#endif // HAVE_WAYLAND
return geometry_changed;
}
@@ -4815,6 +4823,12 @@ panel_toplevel_init (PanelToplevel *toplevel)
toplevel);
update_style_classes (toplevel);
+
+#ifdef HAVE_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (gdk_display_get_default ())) {
+ wayland_panel_toplevel_init (toplevel);
+ }
+#endif // HAVE_WAYLAND
}
PanelWidget *
@@ -5059,6 +5073,12 @@ panel_toplevel_set_orientation (PanelToplevel *toplevel,
g_object_notify (G_OBJECT (toplevel), "orientation");
g_object_thaw_notify (G_OBJECT (toplevel));
+
+#ifdef HAVE_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (gtk_widget_get_display (GTK_WIDGET (toplevel)))) {
+ wayland_panel_toplevel_update_placement (toplevel);
+ }
+#endif // HAVE_WAYLAND
}
PanelOrientation
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]);
+}
diff --git a/mate-panel/wayland-backend.h b/mate-panel/wayland-backend.h
new file mode 100644
index 00000000..ae6a837f
--- /dev/null
+++ b/mate-panel/wayland-backend.h
@@ -0,0 +1,18 @@
+#ifndef __WAYLAND_BACKEND_H__
+#define __WAYLAND_BACKEND_H__
+
+#include <config.h>
+
+#ifndef HAVE_WAYLAND
+#error file should only be included when HAVE_WAYLAND is enabled
+#endif
+
+#include <gdk/gdk.h>
+#include <gdk/gdkwayland.h>
+
+#include "panel-toplevel.h"
+
+void wayland_panel_toplevel_init (PanelToplevel* toplevel);
+void wayland_panel_toplevel_update_placement (PanelToplevel* toplevel);
+
+#endif /* __WAYLAND_BACKEND_H__ */