gdk/x11: don't select RANDR events if the extension is missing

Prevents an Xlib warning on Xnest, or Xorg with xinerama, or other
non-RANDR-capable xserver.  Reintroduce a have_randr12 field in
GdkDisplayX11 to avoid having to call XRRQuery{Extension,Version} twice,
and don't select randr 1.2 events if that's false.

https://bugzilla.gnome.org/show_bug.cgi?id=634711

Signed-off-by: Julien Cristau <jcristau@debian.org>
This commit is contained in:
Julien Cristau 2010-12-23 13:50:13 +01:00 committed by Matthias Clasen
parent 317f8baf60
commit d211c8af6b
3 changed files with 20 additions and 12 deletions

View File

@ -1220,6 +1220,7 @@ _gdk_x11_display_open (const gchar *display_name)
_gdk_x11_precache_atoms (display, precache_atoms, G_N_ELEMENTS (precache_atoms));
/* RandR must be initialized before we initialize the screens */
display_x11->have_randr12 = FALSE;
display_x11->have_randr13 = FALSE;
#ifdef HAVE_RANDR
if (XRRQueryExtension (display_x11->xdisplay,
@ -1229,8 +1230,11 @@ _gdk_x11_display_open (const gchar *display_name)
XRRQueryVersion (display_x11->xdisplay, &major, &minor);
if ((major == 1 && minor >= 3) || major > 1)
display_x11->have_randr13 = TRUE;
if ((major == 1 && minor >= 2) || major > 1) {
display_x11->have_randr12 = TRUE;
if (minor >= 3 || major > 1)
display_x11->have_randr13 = TRUE;
}
gdk_x11_register_standard_event_type (display, display_x11->xrandr_event_base, RRNumberEvents);
}

View File

@ -67,6 +67,7 @@ struct _GdkX11Display
gboolean have_xdamage;
gint xdamage_event_base;
gboolean have_randr12;
gboolean have_randr13;
gint xrandr_event_base;

View File

@ -1,7 +1,7 @@
/*
* gdkscreen-x11.c
*
* Copyright 2001 Sun Microsystems Inc.
*
* Copyright 2001 Sun Microsystems Inc.
*
* Erwann Chenede <erwann.chenede@sun.com>
*
@ -842,20 +842,23 @@ gdk_x11_screen_is_composited (GdkScreen *screen)
}
static void
init_randr_support (GdkScreen * screen)
init_randr_support (GdkScreen *screen)
{
GdkX11Screen *x11_screen = GDK_X11_SCREEN (screen);
XSelectInput (GDK_SCREEN_XDISPLAY (screen),
x11_screen->xroot_window,
StructureNotifyMask);
x11_screen->xroot_window,
StructureNotifyMask);
#ifdef HAVE_RANDR
if (!GDK_X11_DISPLAY (gdk_screen_get_display (screen))->have_randr12)
return;
XRRSelectInput (GDK_SCREEN_XDISPLAY (screen),
x11_screen->xroot_window,
RRScreenChangeNotifyMask |
RRCrtcChangeNotifyMask |
RROutputPropertyNotifyMask);
x11_screen->xroot_window,
RRScreenChangeNotifyMask
| RRCrtcChangeNotifyMask
| RROutputPropertyNotifyMask);
#endif
}