[cairo-commit] src/cairo-xlib-surface-shm.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Oct 5 11:24:53 PDT 2012


 src/cairo-xlib-surface-shm.c |   21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

New commits:
commit b1532f465e05d566f6d160c5ca916a5a12614067
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 5 19:20:18 2012 +0100

    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 at 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 at redhat.com>
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-xlib-surface-shm.c b/src/cairo-xlib-surface-shm.c
index 08169f2..3e6eaf2 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 at 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);
 


More information about the cairo-commit mailing list