[PATCH weston] dnd: work around cairo-gl brokenness

Ander Conselvan de Oliveira ander.conselvan.de.oliveira at intel.com
Fri May 25 06:03:06 PDT 2012


If cairo-gl is used, display_create_surface() will create an
wl_egl_window for each surface and this will result in errors if this
surface is used as a source. Also, one can't get a wl_buffer for such
a surface wich led to crashes when trying to do so for the drag icon.

This patch works around both problems by forcing the item and drag icon
surfaces to use shm.
---
 clients/dnd.c    |    6 ++++--
 clients/window.c |    2 +-
 clients/window.h |    1 +
 3 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/clients/dnd.c b/clients/dnd.c
index 32dec96..de1ca47 100644
--- a/clients/dnd.c
+++ b/clients/dnd.c
@@ -106,7 +106,8 @@ item_create(struct display *display, int x, int y, int seed)
 
 	rect.width = item_width;
 	rect.height = item_height;
-	item->surface = display_create_surface(display, NULL, &rect, 0);
+	item->surface =
+		display_create_surface(display, NULL, &rect, SURFACE_SHM);
 
 	item->x = x;
 	item->y = y;
@@ -322,7 +323,8 @@ create_drag_cursor(struct dnd_drag *dnd_drag,
 
 	rectangle.width = item_width + 2 * pointer->width;
 	rectangle.height = item_height + 2 * pointer->height;
-	surface = display_create_surface(dnd->display, NULL, &rectangle, 0);
+	surface = display_create_surface(dnd->display, NULL, &rectangle,
+					 SURFACE_SHM);
 
 	cr = cairo_create(surface);
 	cairo_translate(cr, pointer->width, pointer->height);
diff --git a/clients/window.c b/clients/window.c
index 7187fac..1b87744 100644
--- a/clients/window.c
+++ b/clients/window.c
@@ -605,7 +605,7 @@ display_create_surface(struct display *display,
 	if (check_size(rectangle) < 0)
 		return NULL;
 #ifdef HAVE_CAIRO_EGL
-	if (display->dpy)
+	if (display->dpy && !(flags & SURFACE_SHM))
 		return display_create_egl_window_surface(display,
 							 surface,
 							 flags,
diff --git a/clients/window.h b/clients/window.h
index a79eb50..ab83546 100644
--- a/clients/window.h
+++ b/clients/window.h
@@ -112,6 +112,7 @@ display_get_image_for_egl_image_surface(struct display *display,
 #endif
 
 #define SURFACE_OPAQUE 0x01
+#define SURFACE_SHM    0x02
 
 cairo_surface_t *
 display_create_surface(struct display *display,
-- 
1.7.4.1



More information about the wayland-devel mailing list