summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke from DC <[email protected]>2023-07-08 17:10:25 +0000
committerGitHub <[email protected]>2023-07-08 19:10:25 +0200
commitc1b2e7798670cc795979090023d1b9dcb2a0b330 (patch)
tree632a206d3501fd48f0e1d1af709b0c4054c49c84
parentdf25aef7d386d3bf8da08ec5d8dd9e44c9b09e50 (diff)
downloadcaja-c1b2e7798670cc795979090023d1b9dcb2a0b330.tar.bz2
caja-c1b2e7798670cc795979090023d1b9dcb2a0b330.tar.xz
wayland: initial support for showing the desktop
* Wayland: Support rendering the desktop *Wayland support is optional via the --enable-wayland option * eel-editable-label-c: remove unused variable This was leftover from earlier code compatable only with x11 * Fix gtk-layer-shell-0 version check, improve error message when Wayland requested but not found
-rw-r--r--.build.yml4
-rw-r--r--configure.ac32
-rw-r--r--eel/eel-background.c22
-rw-r--r--eel/eel-editable-label.c2
-rw-r--r--eel/eel-gtk-extensions.c36
-rw-r--r--src/Makefile.am5
-rw-r--r--src/caja-application.c43
-rw-r--r--src/caja-desktop-window.c132
-rw-r--r--src/file-manager/fm-desktop-icon-view.c88
9 files changed, 271 insertions, 93 deletions
diff --git a/.build.yml b/.build.yml
index 5745cd31..ffe389c9 100644
--- a/.build.yml
+++ b/.build.yml
@@ -40,6 +40,7 @@ requires:
- libgirepository1.0-dev
- libglib2.0-dev
- libgtk-3-dev
+ - libgtk-layer-shell-dev
- libmate-desktop-dev
- libnotify-dev
- libpango1.0-dev
@@ -62,6 +63,8 @@ requires:
- cppcheck-htmlreport
- git
- gcc
+ - gtk3-devel
+ - gtk-layer-shell-devel
- make
- redhat-rpm-config
- dbus-glib-devel
@@ -95,6 +98,7 @@ requires:
- libgirepository1.0-dev
- libglib2.0-dev
- libgtk-3-dev
+ - libgtk-layer-shell-dev
- libmate-desktop-dev
- libnotify-dev
- libpango1.0-dev
diff --git a/configure.ac b/configure.ac
index 99858732..d630daf6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -2,7 +2,7 @@ AC_PREREQ(2.60)
dnl ===========================================================================
-m4_define(gdkpixbuf_minver, 2.36.5)
+m4_define(gdkpixbuf_minver, 2.36.5)
m4_define(glib_minver, 2.58.1)
m4_define(gio_minver, 2.50.0)
m4_define(mate_desktop_minver, 1.17.3)
@@ -13,6 +13,7 @@ m4_define(exif_minver, 0.6.14)
m4_define(exempi_minver, 1.99.5)
m4_define(gail_minver, 3.0.0)
m4_define(notify_minver, 0.7.0)
+m4_define(gtk_layer_shell_minver, 0.8.0)
dnl 1. If the library code has changed at all since last release, then increment revision.
@@ -177,7 +178,31 @@ if test "x$enable_xmp" != "xno"; then
AC_SUBST(EXEMPI_LIBS)
fi
-dnl ==========================================================================
+dnl **************************************************************************
+dnl Whether or not to build with wayland support and check for gtk-layer-shell
+dnl **************************************************************************
+
+
+AC_ARG_ENABLE(wayland,
+ [AS_HELP_STRING([--enable-wayland],
+ [Explicitly enable or disable Wayland support
+ (default is to enable only if Wayland client development library is detected)])],
+ [enable_wayland=$enableval],
+ [enable_wayland=auto])
+
+# Check if we have gtk-layer-shell installed, and thus should build with Wayland support
+have_wayland=no
+m4_define([WAYLAND_DEPS], [gtk-layer-shell-0 >= gtk_layer_shell_minver wayland-client])
+AS_IF([test "x$enable_wayland" = "xyes"],
+ [PKG_CHECK_MODULES([WAYLAND], [WAYLAND_DEPS], [have_wayland=yes])],
+ [test "x$enable_wayland" != "xno"],
+ [PKG_CHECK_MODULES([WAYLAND], [WAYLAND_DEPS], [have_wayland=yes], [have_wayland=no])])
+
+AM_CONDITIONAL(ENABLE_WAYLAND, [test "x$have_wayland" = "xyes"])
+
+if test "x$have_wayland" = "xyes"; then
+ AC_DEFINE(HAVE_WAYLAND, 1, [Have the Wayland development library])
+fi
dnl ****************************
dnl *** Check for libselinux ***
@@ -240,7 +265,7 @@ AC_SUBST(LIBCAJA_EXTENSION_LIBS)
dnl core caja
PKG_CHECK_MODULES(GMODULE, gmodule-2.0, [GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""])
-CORE_MODULES="glib-2.0 $GMODULE_ADD mate-desktop-2.0 gthread-2.0 gio-2.0 gio-unix-2.0 gail-3.0 libxml-2.0 $EXTRA_CORE_MODULES gtk+-3.0 x11"
+CORE_MODULES="glib-2.0 $GMODULE_ADD mate-desktop-2.0 gthread-2.0 gio-2.0 gio-unix-2.0 gail-3.0 libxml-2.0 gtk+-3.0 x11"
CORE_CFLAGS="`$PKG_CONFIG --cflags $CORE_MODULES`"
AC_SUBST(CORE_CFLAGS)
CORE_LIBS="`$PKG_CONFIG --libs $CORE_MODULES`"
@@ -323,6 +348,7 @@ Configure summary:
PackageKit support: $msg_packagekit
Native Language support: $USE_NLS
Self check: $msg_self_check
+ Wayland support: ${have_wayland}
caja-extension documentation: ${enable_gtk_doc}
caja-extension introspection: ${found_introspection}
diff --git a/eel/eel-background.c b/eel/eel-background.c
index 5b00f849..2b50d450 100644
--- a/eel/eel-background.c
+++ b/eel/eel-background.c
@@ -105,7 +105,7 @@ free_background_surface (EelBackground *self)
it will live forever, so we need to kill it manually.
If set as root background it will be killed next time the
background is changed. */
- if (self->details->unset_root_surface)
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default()) && (self->details->unset_root_surface))
{
XKillClient (cairo_xlib_surface_get_display (surface),
cairo_xlib_surface_get_drawable (surface));
@@ -312,7 +312,7 @@ drawable_get_adjusted_size (EelBackground *self,
{
GdkScreen *screen = gtk_widget_get_screen (self->details->widget);
GdkDisplay *display = gdk_screen_get_display (screen);
- if (GDK_IS_X11_DISPLAY (display))
+ if (GDK_IS_X11_DISPLAY (display))
{
gint scale = gtk_widget_get_scale_factor (self->details->widget);
*width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
@@ -433,8 +433,8 @@ set_root_surface (EelBackground *self,
self->details->bg_surface = mate_bg_create_surface (self->details->bg, window,
width, height, TRUE);
}
-
- if (self->details->bg_surface != NULL)
+ GdkDisplay *display = gdk_screen_get_display (screen);
+ if ((GDK_IS_X11_DISPLAY (display)) && (self->details->bg_surface != NULL))
mate_bg_set_surface_as_root (screen, self->details->bg_surface);
}
@@ -649,7 +649,7 @@ widget_realized_setup (GtkWidget *widget,
}
GdkScreen *screen = gtk_widget_get_screen (widget);
- GdkWindow *window = gdk_screen_get_root_window (screen);
+ GdkDisplay *display = gdk_screen_get_display (screen);
if (self->details->screen_size_handler > 0)
{
@@ -665,8 +665,16 @@ widget_realized_setup (GtkWidget *widget,
self->details->screen_monitors_handler =
g_signal_connect (screen, "monitors-changed", G_CALLBACK (screen_size_changed), self);
- self->details->use_common_surface =
- (gdk_window_get_visual (window) == gtk_widget_get_visual (widget)) ? TRUE : FALSE;
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ GdkWindow *window = gdk_screen_get_root_window (screen);
+ self->details->use_common_surface =
+ (gdk_window_get_visual (window) == gtk_widget_get_visual (widget)) ? TRUE : FALSE;
+ }
+ else /*Wayland is always composited*/
+ {
+ self->details->use_common_surface = TRUE;
+ }
init_fade (self);
}
diff --git a/eel/eel-editable-label.c b/eel/eel-editable-label.c
index 92ce7015..7c4bcb38 100644
--- a/eel/eel-editable-label.c
+++ b/eel/eel-editable-label.c
@@ -1028,7 +1028,6 @@ eel_editable_label_ensure_layout (EelEditableLabel *label,
else
{
gint wrap_width;
- gint scale;
pango_layout_set_width (label->layout, -1);
pango_layout_get_extents (label->layout, NULL, &logical_rect);
@@ -1039,7 +1038,6 @@ eel_editable_label_ensure_layout (EelEditableLabel *label,
longest_paragraph = width;
wrap_width = get_label_wrap_width (label);
- scale = gtk_widget_get_scale_factor (widget);
width = MIN (width, wrap_width);
width = MIN (width,
PANGO_SCALE * (gdk_screen_width () + 1) / 2);
diff --git a/eel/eel-gtk-extensions.c b/eel/eel-gtk-extensions.c
index 21c3c358..a36c579e 100644
--- a/eel/eel-gtk-extensions.c
+++ b/eel/eel-gtk-extensions.c
@@ -93,23 +93,27 @@ sanity_check_window_position (int *left, int *top)
* that it might be obscured by the panel.
*
*/
- root_window = gdk_screen_get_root_window (gdk_screen_get_default());
display = gdk_display_get_default ();
- gdk_monitor_get_workarea(gdk_display_get_monitor_at_window (display, root_window), &workarea);
- *top = CLAMP (*top, 0, workarea.height - MINIMUM_ON_SCREEN_HEIGHT);
-
- /* FIXME bugzilla.eazel.com 669:
- * If window has negative left coordinate, set_uposition sends it
- * somewhere else entirely. Not sure what level contains this bug (XWindows?).
- * Hacked around by pinning the left edge to zero, which just means you
- * can't set a window to be partly off the left of the screen using
- * this routine.
- */
- /* Make sure the left edge of the window isn't off the right edge of
- * the screen, or so close to the right edge that it might be
- * obscured by the panel.
- */
- *left = CLAMP (*left, 0, workarea.width - MINIMUM_ON_SCREEN_WIDTH);
+ /*This is x11 only, there is no root window in wayland*/
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ root_window = gdk_screen_get_root_window (gdk_screen_get_default());
+ gdk_monitor_get_workarea(gdk_display_get_monitor_at_window (display, root_window), &workarea);
+ *top = CLAMP (*top, 0, workarea.height - MINIMUM_ON_SCREEN_HEIGHT);
+
+ /* FIXME bugzilla.eazel.com 669:
+ * If window has negative left coordinate, set_uposition sends it
+ * somewhere else entirely. Not sure what level contains this bug (XWindows?).
+ * Hacked around by pinning the left edge to zero, which just means you
+ * can't set a window to be partly off the left of the screen using
+ * this routine.
+ */
+ /* Make sure the left edge of the window isn't off the right edge of
+ * the screen, or so close to the right edge that it might be
+ * obscured by the panel.
+ */
+ *left = CLAMP (*left, 0, workarea.width - MINIMUM_ON_SCREEN_WIDTH);
+ }
}
static void
diff --git a/src/Makefile.am b/src/Makefile.am
index 391df3a2..d36b37e5 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -38,6 +38,11 @@ LDADD = \
-lnotify
$(NULL)
+if ENABLE_WAYLAND
+LDADD += \
+ $(WAYLAND_LIBS)
+endif
+
dbus_freedesktop_built_sources = \
caja-freedesktop-generated.c \
caja-freedesktop-generated.h
diff --git a/src/caja-application.c b/src/caja-application.c
index 1467e421..e6d3000a 100644
--- a/src/caja-application.c
+++ b/src/caja-application.c
@@ -634,19 +634,15 @@ selection_get_cb (GtkWidget *widget,
static GtkWidget *
get_desktop_manager_selection (GdkDisplay *display)
{
- /*FIXME: for Wayland we need a new desktop canvas anyway
- *so when that is ready we will need to add a wayland code
- *path here to support it
- */
- if (GDK_IS_X11_DISPLAY (display)){
- char selection_name[32];
- GdkAtom selection_atom;
- Window selection_owner;
- GtkWidget *selection_widget;
-
- g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S0");
- selection_atom = gdk_atom_intern (selection_name, FALSE);
+ char selection_name[32];
+ GdkAtom selection_atom;
+ Window selection_owner;
+ GtkWidget *selection_widget;
+ g_snprintf (selection_name, sizeof (selection_name), "_NET_DESKTOP_MANAGER_S0");
+ selection_atom = gdk_atom_intern (selection_name, FALSE);
+ if (GDK_IS_X11_DISPLAY (display))
+ {
selection_owner = XGetSelectionOwner (GDK_DISPLAY_XDISPLAY (display),
gdk_x11_atom_to_xatom_for_display (display,
selection_atom));
@@ -654,24 +650,31 @@ get_desktop_manager_selection (GdkDisplay *display)
{
return NULL;
}
+ }
+ selection_widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display));
+ /* We need this for gdk_x11_get_server_time() */
+ gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK);
- selection_widget = gtk_invisible_new_for_screen (gdk_display_get_default_screen (display));
- /* We need this for gdk_x11_get_server_time() */
- gtk_widget_add_events (selection_widget, GDK_PROPERTY_CHANGE_MASK);
-
+ if (GDK_IS_X11_DISPLAY (display))
+ {
if (gtk_selection_owner_set_for_display (display,
selection_widget,
selection_atom,
gdk_x11_get_server_time (gtk_widget_get_window (selection_widget))))
{
-
g_signal_connect (selection_widget, "selection_get",
- G_CALLBACK (selection_get_cb), NULL);
+ G_CALLBACK (selection_get_cb), NULL);
return selection_widget;
}
-
- gtk_widget_destroy (selection_widget);
}
+ else
+ {
+ g_signal_connect (selection_widget, "selection_get",
+ G_CALLBACK (selection_get_cb), NULL);
+ return selection_widget;
+ }
+
+ gtk_widget_destroy (selection_widget);
return NULL;
}
diff --git a/src/caja-desktop-window.c b/src/caja-desktop-window.c
index b5f7e9a5..6188fa63 100644
--- a/src/caja-desktop-window.c
+++ b/src/caja-desktop-window.c
@@ -29,7 +29,10 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
#include <glib/gi18n.h>
-
+#ifdef HAVE_WAYLAND
+#include <gdk/gdkwayland.h>
+#include <gtk-layer-shell/gtk-layer-shell.h>
+#endif
#include <eel/eel-background.h>
#include <eel/eel-vfs-extensions.h>
@@ -156,9 +159,23 @@ caja_desktop_window_screen_size_changed (GdkScreen *screen,
{
int width_request, height_request;
- GdkWindow *root_window;
- root_window = gdk_screen_get_root_window (screen);
- gdk_window_get_geometry (root_window, NULL, NULL, &width_request, &height_request);
+ GdkDisplay *display = gdk_screen_get_display (screen);
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ GdkWindow *root_window;
+ root_window = gdk_screen_get_root_window (screen);
+ gdk_window_get_geometry (root_window, NULL, NULL, &width_request, &height_request);
+ }
+ else
+ {
+ /*No root window or primary monitor in wayland unless compositors add it back*/
+ GdkRectangle geometry = {0};
+ GdkMonitor *monitor;
+ monitor = gdk_display_get_monitor (display, 0);
+ gdk_monitor_get_geometry (monitor, &geometry);
+ width_request = geometry.width;
+ height_request = geometry.height;
+ }
g_object_set (window,
"width_request", width_request,
@@ -174,10 +191,27 @@ caja_desktop_window_new (CajaApplication *application,
int width_request, height_request;
int scale;
- scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
-
- width_request = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
- height_request = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ GdkDisplay *display = gdk_screen_get_display (screen);
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+ width_request = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ height_request = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ }
+ else
+ {
+ /*FIXME: There is no primary monitor in wayland itself
+ *compositors can implement this but as this is written
+ *only a few wayland compositors allow setting a primary monitor
+ *and they all do it differently. For now, use the first monitor
+ */
+ GdkRectangle geometry = {0};
+ GdkMonitor *monitor;
+ monitor = gdk_display_get_monitor (display, 0);
+ gdk_monitor_get_geometry (monitor, &geometry);
+ width_request = geometry.width;
+ height_request = geometry.height;
+ }
window = CAJA_DESKTOP_WINDOW
(gtk_widget_new (caja_desktop_window_get_type(),
@@ -191,11 +225,47 @@ caja_desktop_window_new (CajaApplication *application,
/* will cause the desktop window to open at the wrong size in gtk 3.20 */
gtk_window_set_default_size (GTK_WINDOW (window), -1, -1);
+ /*For wayland only
+ *Code taken from gtk-layer-shell simple-example.c
+ */
+#ifdef HAVE_WAYLAND
+ if (GDK_IS_WAYLAND_DISPLAY (display))
+ {
+ GtkWindow *gtkwin;
+ gtkwin = (GTK_WINDOW(window));
+
+ /* Before the window is first realized, set it up to be a layer surface */
+ gtk_layer_init_for_window (gtkwin);
+
+ /* Order below normal windows */
+ gtk_layer_set_layer (gtkwin, GTK_LAYER_SHELL_LAYER_BOTTOM);
+
+ gtk_layer_set_namespace (gtkwin, "desktop");
+
+ /*Anchor the desktop to all four corners
+ *This is much simpler than on x11 and
+ *should always render the desktop across
+ *all of the screen
+ */
+ gtk_layer_set_anchor (gtkwin, GTK_LAYER_SHELL_EDGE_TOP, TRUE);
+ gtk_layer_set_anchor (gtkwin, GTK_LAYER_SHELL_EDGE_BOTTOM, TRUE);
+ gtk_layer_set_anchor (gtkwin, GTK_LAYER_SHELL_EDGE_LEFT, TRUE);
+ gtk_layer_set_anchor (gtkwin, GTK_LAYER_SHELL_EDGE_RIGHT, TRUE);
+
+ /*Enable keyboard use on the desktop*/
+ gtk_layer_set_keyboard_mode (gtkwin, GTK_LAYER_SHELL_KEYBOARD_MODE_ON_DEMAND);
+ }
+#endif
/* Special sawmill setting*/
GdkWindow *gdkwin;
- gtk_widget_realize (GTK_WIDGET (window));
+ if ((GDK_IS_X11_DISPLAY (display)))
+ gtk_widget_realize (GTK_WIDGET (window));
+ else
+ gtk_widget_show (GTK_WIDGET (window));
+
gdkwin = gtk_widget_get_window (GTK_WIDGET (window));
- if (gdk_window_ensure_native (gdkwin)) {
+ if ((GDK_IS_X11_DISPLAY (display)) && (gdk_window_ensure_native (gdkwin)))
+ {
Display *disp = GDK_DISPLAY_XDISPLAY (gdk_window_get_display (gdkwin));
XClassHint *xch = XAllocClassHint ();
xch->res_name = "desktop_window";
@@ -230,15 +300,21 @@ unrealize (GtkWidget *widget)
CajaDesktopWindow *window;
CajaDesktopWindowPrivate *details;
GdkWindow *root_window;
+ GdkDisplay *display;
window = CAJA_DESKTOP_WINDOW (widget);
details = window->details;
+ display = gtk_widget_get_display (widget);
- root_window = gdk_screen_get_root_window (
+ /*Avoid root window on wayland-it's not supposed to work*/
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ root_window = gdk_screen_get_root_window (
gtk_window_get_screen (GTK_WINDOW (window)));
- gdk_property_delete (root_window,
- gdk_atom_intern ("CAJA_DESKTOP_WINDOW_ID", TRUE));
+ gdk_property_delete (root_window,
+ gdk_atom_intern ("CAJA_DESKTOP_WINDOW_ID", TRUE));
+ }
if (details->size_changed_id != 0) {
g_signal_handler_disconnect (gtk_window_get_screen (GTK_WINDOW (window)),
@@ -249,6 +325,7 @@ unrealize (GtkWidget *widget)
GTK_WIDGET_CLASS (caja_desktop_window_parent_class)->unrealize (widget);
}
+/*This should only be reached in x11*/
static void
set_wmspec_desktop_hint (GdkWindow *window)
{
@@ -262,18 +339,18 @@ set_wmspec_desktop_hint (GdkWindow *window)
GDK_PROP_MODE_REPLACE, (guchar *) &atom, 1);
}
+/*This should only be reached in x11*/
static void
set_desktop_window_id (CajaDesktopWindow *window,
GdkWindow *gdkwindow)
{
- /* Tuck the desktop windows xid in the root to indicate we own the desktop.
+ /* Tuck the desktop windows xid in the root to indicate we own the desktop in on x11
*/
Window window_xid;
GdkWindow *root_window;
root_window = gdk_screen_get_root_window (
gtk_window_get_screen (GTK_WINDOW (window)));
-
window_xid = GDK_WINDOW_XID (gdkwindow);
gdk_property_change (root_window,
@@ -289,17 +366,24 @@ realize (GtkWidget *widget)
CajaDesktopWindowPrivate *details;
window = CAJA_DESKTOP_WINDOW (widget);
details = window->details;
+ GdkDisplay *display;
/* Make sure we get keyboard events */
- gtk_widget_set_events (widget, gtk_widget_get_events (widget)
- | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
- /* Do the work of realizing. */
- GTK_WIDGET_CLASS (caja_desktop_window_parent_class)->realize (widget);
+ display = gtk_widget_get_display (widget);
+ if (GDK_IS_X11_DISPLAY (display))
+ gtk_widget_set_events (widget, gtk_widget_get_events (widget)
+ | GDK_KEY_PRESS_MASK | GDK_KEY_RELEASE_MASK);
- /* This is the new way to set up the desktop window */
- set_wmspec_desktop_hint (gtk_widget_get_window (widget));
+ /*Do the work of realizing. */
+ GTK_WIDGET_CLASS (caja_desktop_window_parent_class)->realize (widget);
- set_desktop_window_id (window, gtk_widget_get_window (widget));
+ /* This is the new way to set up the desktop window in x11 but not for wayland */
+ display = gtk_widget_get_display (widget);
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ set_wmspec_desktop_hint (gtk_widget_get_window (widget));
+ set_desktop_window_id (window, gtk_widget_get_window (widget));
+ }
details->size_changed_id =
g_signal_connect (gtk_window_get_screen (GTK_WINDOW (window)), "size_changed",
@@ -311,7 +395,6 @@ draw (GtkWidget *widget,
cairo_t *cr)
{
eel_background_draw (widget, cr);
-
return GTK_WIDGET_CLASS (caja_desktop_window_parent_class)->draw (widget, cr);
}
@@ -332,7 +415,8 @@ caja_desktop_window_class_init (CajaDesktopWindowClass *klass)
wclass->realize = realize;
wclass->unrealize = unrealize;
wclass->map = map;
- wclass->draw = draw;
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default()))
+ wclass->draw = draw;
gtk_widget_class_set_accessible_type (wclass, CAJA_TYPE_DESKTOP_WINDOW_ACCESSIBLE);
diff --git a/src/file-manager/fm-desktop-icon-view.c b/src/file-manager/fm-desktop-icon-view.c
index a90f884f..3a88b091 100644
--- a/src/file-manager/fm-desktop-icon-view.c
+++ b/src/file-manager/fm-desktop-icon-view.c
@@ -120,13 +120,27 @@ icon_container_set_workarea (CajaIconContainer *icon_container,
int screen_width, screen_height;
int scale;
int i;
+ GdkDisplay *display;
left = right = top = bottom = 0;
- scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
-
- screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
- screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ display = gdk_screen_get_display (screen);
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ scale = gdk_window_get_scale_factor (gdk_screen_get_root_window (screen));
+ screen_width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ screen_height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ }
+ else
+ {
+ scale = 1; /*wayland handles this for us*/
+ GdkRectangle geometry = {0};
+ GdkMonitor *monitor;
+ monitor = gdk_display_get_monitor (display, 0);
+ gdk_monitor_get_geometry (monitor, &geometry);
+ screen_width = geometry.width;
+ screen_height = geometry.height;
+ }
for (i = 0; i < n_items; i += 4)
{
@@ -148,6 +162,7 @@ icon_container_set_workarea (CajaIconContainer *icon_container,
left, right, top, bottom);
}
+/*This code is only reached when running in x11*/
static void
net_workarea_changed (FMDesktopIconView *icon_view,
GdkWindow *window)
@@ -239,6 +254,7 @@ net_workarea_changed (FMDesktopIconView *icon_view,
g_free (workareas);
}
+/*This code is reached only in x11*/
static GdkFilterReturn
desktop_icon_view_property_filter (GdkXEvent *gdk_xevent,
GdkEvent *event,
@@ -258,7 +274,6 @@ desktop_icon_view_property_filter (GdkXEvent *gdk_xevent,
default:
break;
}
-
return GDK_FILTER_CONTINUE;
}
@@ -317,6 +332,7 @@ fm_desktop_icon_view_class_init (FMDesktopIconViewClass *class)
FM_ICON_VIEW_CLASS (class)->supports_labels_beside_icons = real_supports_labels_beside_icons;
}
+/*This code is only reached when running on x11*/
static void
fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container,
GdkEventButton *event,
@@ -373,6 +389,9 @@ fm_desktop_icon_view_handle_middle_click (CajaIconContainer *icon_container,
static void
unrealized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
{
+ if (!GDK_IS_X11_DISPLAY (gdk_display_get_default()))
+ return;
+
g_return_if_fail (desktop_icon_view->priv->root_window != NULL);
/* Remove the property filter */
@@ -387,13 +406,13 @@ realized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
{
GdkWindow *root_window;
GdkScreen *screen;
+ GdkDisplay *display;
GtkAllocation allocation;
- gint scale;
g_return_if_fail (desktop_icon_view->priv->root_window == NULL);
screen = gtk_widget_get_screen (widget);
- scale = gtk_widget_get_scale_factor (widget);
+ display = gdk_screen_get_display (screen);
/* Ugly HACK for the problem that the views realize at the
* wrong size and then get resized. (This is a problem with
@@ -403,24 +422,46 @@ realized_callback (GtkWidget *widget, FMDesktopIconView *desktop_icon_view)
*/
allocation.x = 0;
allocation.y = 0;
- allocation.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
- allocation.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ gint scale;
+ scale = gtk_widget_get_scale_factor (widget);
+ allocation.width = WidthOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ allocation.height = HeightOfScreen (gdk_x11_screen_get_xscreen (screen)) / scale;
+ }
+ else
+ {
+ /*No real root window or primary monitor in wayland unless compositors add it back*/
+ GdkRectangle geometry = {0};
+ GdkMonitor *monitor;
+ monitor = gdk_display_get_monitor (display, 0);
+ gdk_monitor_get_geometry (monitor, &geometry);
+ allocation.width = geometry.width;
+ allocation.height = geometry.height;
+ }
+
gtk_widget_size_allocate (GTK_WIDGET(get_icon_container(desktop_icon_view)),
&allocation);
- root_window = gdk_screen_get_root_window (screen);
-
- desktop_icon_view->priv->root_window = root_window;
+ if (GDK_IS_X11_DISPLAY (display))
+ {
+ root_window = gdk_screen_get_root_window (screen);
+ desktop_icon_view->priv->root_window = root_window;
- /* Read out the workarea geometry and update the icon container accordingly */
- net_workarea_changed (desktop_icon_view, root_window);
+ /* Read out the workarea geometry and update the icon container accordingly */
+ net_workarea_changed (desktop_icon_view, root_window);
- /* Setup the property filter */
- gdk_window_set_events (root_window, GDK_PROPERTY_CHANGE_MASK);
- gdk_window_add_filter (root_window,
- desktop_icon_view_property_filter,
- desktop_icon_view);
+ /* Setup the property filter */
+ gdk_window_set_events (root_window, GDK_PROPERTY_CHANGE_MASK);
+ gdk_window_add_filter (root_window,
+ desktop_icon_view_property_filter,
+ desktop_icon_view);
+ }
+ else
+ {
+ desktop_icon_view->priv->root_window = NULL;
+ }
}
static CajaZoomLevel
@@ -610,8 +651,13 @@ fm_desktop_icon_view_init (FMDesktopIconView *desktop_icon_view)
CAJA_ICON_LAYOUT_T_B_R_L :
CAJA_ICON_LAYOUT_T_B_L_R);
- g_signal_connect_object (icon_container, "middle_click",
- G_CALLBACK (fm_desktop_icon_view_handle_middle_click), desktop_icon_view, 0);
+ /*Handle the middle click on x11 */
+ if (GDK_IS_X11_DISPLAY (gdk_display_get_default ()))
+ {
+ g_signal_connect_object (desktop_icon_view, "middle_click",
+ G_CALLBACK (fm_desktop_icon_view_handle_middle_click), desktop_icon_view, 0);
+ }
+
g_signal_connect_object (desktop_icon_view, "realize",
G_CALLBACK (realized_callback), desktop_icon_view, 0);
g_signal_connect_object (desktop_icon_view, "unrealize",