[PATCH] gtk: Track wayland protocol changes

Scott Moreau oreaus at gmail.com
Wed Jun 22 13:44:18 PDT 2011


Hi. This is a patch for gtk to build against current wayland:

diff --git a/gdk/wayland/gdkcursor-wayland.c b/gdk/wayland/gdkcursor-wayland.c
index e93abc8..21b3bf5 100644
--- a/gdk/wayland/gdkcursor-wayland.c
+++ b/gdk/wayland/gdkcursor-wayland.c
@@ -224,7 +224,7 @@ create_cursor(GdkDisplayWayland *display,
GdkPixbuf *pixbuf, int x, int y)
   else
     memset (cursor->map, 0, 4);

-  visual = wl_display_get_premultiplied_argb_visual(display->wl_display);
+  visual = display->premultiplied_argb_visual;
   cursor->buffer = wl_shm_create_buffer(display->shm,
 					fd,
 					cursor->width,
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 5cd7be2..8481e8b 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -124,17 +124,53 @@ static const struct wl_shell_listener shell_listener = {

 static void
 output_handle_geometry(void *data,
-		       struct wl_output *output,
-		       int32_t x, int32_t y, int32_t width, int32_t height)
+		       struct wl_output *wl_output,
+		       int x, int y, int physical_width, int physical_height,
+		       int subpixel, const char *make, const char *model)
 {
   /*
     g_signal_emit_by_name (screen, "monitors-changed");
     g_signal_emit_by_name (screen, "size-changed");
   */
 }
+static void
+display_handle_mode(void *data,
+                   struct wl_output *wl_output,
+                   uint32_t flags,
+                   int width,
+                   int height,
+                   int refresh)
+{
+}
+
+static void
+compositor_handle_visual(void *data,
+			 struct wl_compositor *compositor,
+			 uint32_t id, uint32_t token)
+{
+	GdkDisplayWayland *d = data;
+
+	switch (token) {
+	case WL_COMPOSITOR_VISUAL_ARGB32:
+		d->argb_visual = wl_visual_create(d->wl_display, id, 1);
+		break;
+	case WL_COMPOSITOR_VISUAL_PREMULTIPLIED_ARGB32:
+		d->premultiplied_argb_visual =
+			wl_visual_create(d->wl_display, id, 1);
+		break;
+	case WL_COMPOSITOR_VISUAL_XRGB32:
+		d->rgb_visual = wl_visual_create(d->wl_display, id, 1);
+		break;
+	}
+}
+
+static const struct wl_compositor_listener compositor_listener = {
+	compositor_handle_visual,
+};

 static const struct wl_output_listener output_listener = {
 	output_handle_geometry,
+	display_handle_mode
 };

 static void
@@ -147,6 +183,8 @@ gdk_display_handle_global(struct wl_display
*display, uint32_t id,

   if (strcmp(interface, "wl_compositor") == 0) {
     display_wayland->compositor = wl_compositor_create(display, id, 1);
+    wl_compositor_add_listener(display_wayland->compositor,
+					   &compositor_listener, display_wayland);
   } else if (strcmp(interface, "wl_shm") == 0) {
     display_wayland->shm = wl_shm_create(display, id, 1);
   } else if (strcmp(interface, "wl_shell") == 0) {
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
index 88756af..787de8c 100644
--- a/gdk/wayland/gdkdisplay-wayland.h
+++ b/gdk/wayland/gdkdisplay-wayland.h
@@ -71,6 +71,7 @@ struct _GdkDisplayWayland

   /* Wayland fields below */
   struct wl_display *wl_display;
+  struct wl_visual *argb_visual, *premultiplied_argb_visual, *rgb_visual;
   struct wl_compositor *compositor;
   struct wl_shm *shm;
   struct wl_shell *shell;
diff --git a/gdk/wayland/gdkscreen-wayland.c b/gdk/wayland/gdkscreen-wayland.c
index b1cb479..26f426d 100644
--- a/gdk/wayland/gdkscreen-wayland.c
+++ b/gdk/wayland/gdkscreen-wayland.c
@@ -482,15 +482,14 @@ _gdk_wayland_screen_new (GdkDisplay *display)
   screen_wayland->width = 8192;
   screen_wayland->height = 8192;

-  visual = wl_display_get_argb_visual(display_wayland->wl_display);
+  visual = display_wayland->argb_visual;
   screen_wayland->argb_visual = gdk_wayland_visual_new (screen, visual);

-  visual =
-    wl_display_get_premultiplied_argb_visual(display_wayland->wl_display);
+  visual = display_wayland->premultiplied_argb_visual;
   screen_wayland->premultiplied_argb_visual =
     gdk_wayland_visual_new (screen, visual);

-  visual = wl_display_get_rgb_visual(display_wayland->wl_display);
+  visual = display_wayland->rgb_visual;
   screen_wayland->rgb_visual = gdk_wayland_visual_new (screen, visual);

   screen_wayland->root_window =
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index c19b3c5..194d763 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -392,7 +392,7 @@ gdk_wayland_create_cairo_surface
(GdkDisplayWayland *display,
   data = g_new (GdkWaylandCairoSurfaceData, 1);
   data->display = display;
   data->buffer = NULL;
-  visual = wl_display_get_premultiplied_argb_visual(display->wl_display);
+  visual = display->premultiplied_argb_visual;
   data->width = width;
   data->height = height;
   data->pixmap = wl_egl_pixmap_create(width, height, visual, 0);
@@ -450,6 +450,8 @@ gdk_wayland_window_map (GdkWindow *window)
 {
   GdkWindowImplWayland *impl = GDK_WINDOW_IMPL_WAYLAND (window->impl);
   GdkWindowImplWayland *parent;
+  GdkDisplayWayland *display_wayland =
+		GDK_DISPLAY_WAYLAND (gdk_window_get_display (impl->wrapper));

   if (!impl->mapped)
     {
@@ -462,11 +464,11 @@ gdk_wayland_window_map (GdkWindow *window)
 		  window->y);

 	  parent = GDK_WINDOW_IMPL_WAYLAND (impl->transient_for->impl);
-	  wl_surface_map_transient (impl->surface, parent->surface,
+	  wl_shell_set_transient (display_wayland->shell, impl->surface,
parent->surface,
 				    window->x, window->y, 0);
 	}
       else
-	wl_surface_map_toplevel (impl->surface);
+      wl_shell_set_toplevel (display_wayland->shell, impl->surface);
       impl->mapped = TRUE;
     }
 }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/wayland-devel/attachments/20110622/8c298329/attachment.htm>


More information about the wayland-devel mailing list