From 01b36c5fc46385faf40eea9d66af1a5c8c497409 Mon Sep 17 00:00:00 2001 From: Christian Dywan Date: Tue, 18 Sep 2012 21:29:38 +0200 Subject: [PATCH] Enclose screen saver and root window in IS_X11_DISPLAY If building with a Wayland-enabled GTK+3 the GdkDisplay can be something other than GdkX11Display at runtime. Fixes: https://bugs.launchpad.net/midori/+bug/975355 --- katze/gtk3-compat.h | 4 ++++ midori/main.c | 13 ++++++++++--- midori/sokoke.c | 43 +++++++++++++++++++++++-------------------- 3 files changed, 37 insertions(+), 23 deletions(-) diff --git a/katze/gtk3-compat.h b/katze/gtk3-compat.h index 12981b1a..a8450af2 100644 --- a/katze/gtk3-compat.h +++ b/katze/gtk3-compat.h @@ -116,6 +116,10 @@ G_BEGIN_DECLS #define GDK_KEY_Return GDK_Return #endif +#ifndef GDK_IS_X11_DISPLAY + #define GDK_IS_X11_DISPLAY(display) TRUE +#endif + G_END_DECLS #endif diff --git a/midori/main.c b/midori/main.c index d2104d70..2d3af37a 100644 --- a/midori/main.c +++ b/midori/main.c @@ -1599,9 +1599,16 @@ midori_inactivity_timeout (gpointer data) if (has_extension == -1) { GdkDisplay* display = gtk_widget_get_display (GTK_WIDGET (mit->browser)); - xdisplay = GDK_DISPLAY_XDISPLAY (display); - has_extension = XScreenSaverQueryExtension (xdisplay, - &event_base, &error_base); + if (GDK_IS_X11_DISPLAY (display)) + { + xdisplay = GDK_DISPLAY_XDISPLAY (display); + has_extension = XScreenSaverQueryExtension (xdisplay, + &event_base, &error_base); + } + else + { + has_extension = 0; + } } if (has_extension) diff --git a/midori/sokoke.c b/midori/sokoke.c index 8efc1848..a303bfbf 100644 --- a/midori/sokoke.c +++ b/midori/sokoke.c @@ -688,26 +688,29 @@ sokoke_get_desktop (void) } else { - /* Are we running in Xfce <= 4.6? */ - GdkDisplay* display = gdk_display_get_default (); - Display* xdisplay = GDK_DISPLAY_XDISPLAY (display); - Window root_window = RootWindow (xdisplay, 0); - Atom save_mode_atom = gdk_x11_get_xatom_by_name_for_display ( - display, "_DT_SAVE_MODE"); - Atom actual_type; - int actual_format; - unsigned long n_items, bytes; - gchar* value; - int status = XGetWindowProperty (xdisplay, root_window, - save_mode_atom, 0, (~0L), - False, AnyPropertyType, &actual_type, &actual_format, - &n_items, &bytes, (unsigned char**)&value); - if (status == Success) - { - if (n_items == 6 && !strncmp (value, "xfce4", 6)) - desktop = SOKOKE_DESKTOP_XFCE; - XFree (value); - } + /* Are we running in Xfce <= 4.6? */ + GdkDisplay* display = gdk_display_get_default (); + if (GDK_IS_X11_DISPLAY (display)) + { + Display* xdisplay = GDK_DISPLAY_XDISPLAY (display); + Window root_window = RootWindow (xdisplay, 0); + Atom save_mode_atom = gdk_x11_get_xatom_by_name_for_display ( + display, "_DT_SAVE_MODE"); + Atom actual_type; + int actual_format; + unsigned long n_items, bytes; + gchar* value; + int status = XGetWindowProperty (xdisplay, root_window, + save_mode_atom, 0, (~0L), + False, AnyPropertyType, &actual_type, &actual_format, + &n_items, &bytes, (unsigned char**)&value); + if (status == Success) + { + if (n_items == 6 && !strncmp (value, "xfce4", 6)) + desktop = SOKOKE_DESKTOP_XFCE; + XFree (value); + } + } } } -- 2.39.5