summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-10-05 19:20:18 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2012-10-05 19:20:18 +0100
commitb1532f465e05d566f6d160c5ca916a5a12614067 (patch)
tree7e464f8689870471666ba403a0c3cb2fa04aae81
parentdba46f4eab716c0148d278ba7cae0cb075b5df01 (diff)
xlib/shm: Avoid using XSendEvent with old versions of Xorg
Søren Sandmann Pedersen pointed out that all versions of Xorg prior to and including xorg-1.11.0 contained a bug that would cause them to crash if they ever processed an event sent by XSendEvent. This was fixed in commit 2d2dce558d24eeea0eb011ec9ebaa6c5c2273c39 Author: Sam Spilsbury <sam.spilsbury@canonical.com> Date: Wed Sep 14 09:58:34 2011 +0800 Remove the SendEvent bit (0x80) before doing range checks on event type. so make sure we do not use XSendEvent prior to that commit, which fortuitously is quite easy as we only do so along the ShmPixmap path. Reported-by: Søren Sandmann Pedersen <ssp@redhat.com> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/cairo-xlib-surface-shm.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/cairo-xlib-surface-shm.c b/src/cairo-xlib-surface-shm.c
index 08169f21a..3e6eaf276 100644
--- a/src/cairo-xlib-surface-shm.c
+++ b/src/cairo-xlib-surface-shm.c
@@ -1121,6 +1121,24 @@ _cairo_xlib_shm_surface_is_idle (cairo_surface_t *surface)
return shm->idle > 0;
}
+#define XORG_VERSION_ENCODE(major,minor,patch,snap) \
+ (((major) * 10000000) + ((minor) * 100000) + ((patch) * 1000) + snap)
+
+static cairo_bool_t
+xorg_has_buggy_send_event(Display *dpy)
+{
+ /* Avoid incurring the wrath fixed by:
+ *
+ * commit 2d2dce558d24eeea0eb011ec9ebaa6c5c2273c39
+ * Author: Sam Spilsbury <sam.spilsbury@canonical.com>
+ * Date: Wed Sep 14 09:58:34 2011 +0800
+ *
+ * Remove the SendEvent bit (0x80) before doing range checks on event type.
+ */
+ return (strstr (ServerVendor (dpy), "X.Org") != NULL &&
+ VendorRelease (dpy) < XORG_VERSION_ENCODE(1,11,0,1));
+}
+
void
_cairo_xlib_display_init_shm (cairo_xlib_display_t *display)
{
@@ -1153,6 +1171,9 @@ _cairo_xlib_display_init_shm (cairo_xlib_display_t *display)
DefaultVisual (display->display, scr),
CWOverrideRedirect, &attr);
+ if (xorg_has_buggy_send_event(display->display))
+ has_pixmap = 0;
+
shm->has_pixmaps = has_pixmap ? MIN_PIXMAP_SIZE : 0;
cairo_list_init (&shm->pool);