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
This commit is contained in:
Christian Dywan 2012-09-18 21:29:38 +02:00
parent 7e39d05a17
commit 01b36c5fc4
3 changed files with 37 additions and 23 deletions

View file

@ -116,6 +116,10 @@ G_BEGIN_DECLS
#define GDK_KEY_Return GDK_Return #define GDK_KEY_Return GDK_Return
#endif #endif
#ifndef GDK_IS_X11_DISPLAY
#define GDK_IS_X11_DISPLAY(display) TRUE
#endif
G_END_DECLS G_END_DECLS
#endif #endif

View file

@ -1599,9 +1599,16 @@ midori_inactivity_timeout (gpointer data)
if (has_extension == -1) if (has_extension == -1)
{ {
GdkDisplay* display = gtk_widget_get_display (GTK_WIDGET (mit->browser)); GdkDisplay* display = gtk_widget_get_display (GTK_WIDGET (mit->browser));
xdisplay = GDK_DISPLAY_XDISPLAY (display); if (GDK_IS_X11_DISPLAY (display))
has_extension = XScreenSaverQueryExtension (xdisplay, {
&event_base, &error_base); xdisplay = GDK_DISPLAY_XDISPLAY (display);
has_extension = XScreenSaverQueryExtension (xdisplay,
&event_base, &error_base);
}
else
{
has_extension = 0;
}
} }
if (has_extension) if (has_extension)

View file

@ -688,26 +688,29 @@ sokoke_get_desktop (void)
} }
else else
{ {
/* Are we running in Xfce <= 4.6? */ /* Are we running in Xfce <= 4.6? */
GdkDisplay* display = gdk_display_get_default (); GdkDisplay* display = gdk_display_get_default ();
Display* xdisplay = GDK_DISPLAY_XDISPLAY (display); if (GDK_IS_X11_DISPLAY (display))
Window root_window = RootWindow (xdisplay, 0); {
Atom save_mode_atom = gdk_x11_get_xatom_by_name_for_display ( Display* xdisplay = GDK_DISPLAY_XDISPLAY (display);
display, "_DT_SAVE_MODE"); Window root_window = RootWindow (xdisplay, 0);
Atom actual_type; Atom save_mode_atom = gdk_x11_get_xatom_by_name_for_display (
int actual_format; display, "_DT_SAVE_MODE");
unsigned long n_items, bytes; Atom actual_type;
gchar* value; int actual_format;
int status = XGetWindowProperty (xdisplay, root_window, unsigned long n_items, bytes;
save_mode_atom, 0, (~0L), gchar* value;
False, AnyPropertyType, &actual_type, &actual_format, int status = XGetWindowProperty (xdisplay, root_window,
&n_items, &bytes, (unsigned char**)&value); save_mode_atom, 0, (~0L),
if (status == Success) False, AnyPropertyType, &actual_type, &actual_format,
{ &n_items, &bytes, (unsigned char**)&value);
if (n_items == 6 && !strncmp (value, "xfce4", 6)) if (status == Success)
desktop = SOKOKE_DESKTOP_XFCE; {
XFree (value); if (n_items == 6 && !strncmp (value, "xfce4", 6))
} desktop = SOKOKE_DESKTOP_XFCE;
XFree (value);
}
}
} }
} }