[gtk-wayland v2 PATCH 2/3] gtk-wayland: update interfaces bindings and display sync APIs

juan.j.zhao at intel.com juan.j.zhao at intel.com
Mon Nov 7 04:31:18 PST 2011


From: Juan Zhao <juan.j.zhao at intel.com>

The code can not be compiled, because the wl_display related interfaces are changed in wayland.
Update wl_display_sync_callback APIs to wl_callback_add_listener and wl_display_roundtrip for display sync.
Because wl_xxx_create is removed in wayland. Update it to wl_display_bind for binding related interfaces like wl_shm_interface.
Clean compositor listener which is used for visual changing.
https://bugzilla.gnome.org/show_bug.cgi?id=663550
---
 gdk/wayland/gdkdisplay-wayland.c |   28 ++++++++++++++--------------
 1 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 6195e46..39c2b7e 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -143,10 +143,6 @@ display_handle_mode(void *data,
 {
 }
 
-static const struct wl_compositor_listener compositor_listener = {
-	NULL,
-};
-
 static const struct wl_output_listener output_listener = {
 	output_handle_geometry,
 	display_handle_mode
@@ -161,21 +157,20 @@ gdk_display_handle_global(struct wl_display *display, uint32_t id,
   struct wl_input_device *input;
 
   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);
+    display_wayland->compositor = wl_display_bind(display, id, &wl_compositor_interface);
+
   } else if (strcmp(interface, "wl_shm") == 0) {
-    display_wayland->shm = wl_shm_create(display, id, 1);
+    display_wayland->shm = wl_display_bind(display, id, &wl_shm_interface);
   } else if (strcmp(interface, "wl_shell") == 0) {
-    display_wayland->shell = wl_shell_create(display, id, 1);
+    display_wayland->shell = wl_display_bind(display, id, &wl_shell_interface);
     wl_shell_add_listener(display_wayland->shell,
 			  &shell_listener, display_wayland);
   } else if (strcmp(interface, "wl_output") == 0) {
-    display_wayland->output = wl_output_create(display, id, 1);
+    display_wayland->output = wl_display_bind(display, id, &wl_output_interface);
     wl_output_add_listener(display_wayland->output,
 			   &output_listener, display_wayland);
   } else if (strcmp(interface, "wl_input_device") == 0) {
-    input = wl_input_device_create(display, id, 1);
+    input = wl_display_bind(display, id, &wl_input_device_interface);
     _gdk_wayland_device_manager_add_device (gdk_display->device_manager,
 					    input);
   }
@@ -430,20 +425,25 @@ sync_callback(void *data)
   *done = TRUE;
 }
 
+static const struct wl_callback_listener sync_listener = {
+       sync_callback
+};
+
 static void
 gdk_wayland_display_sync (GdkDisplay *display)
 {
   GdkDisplayWayland *display_wayland;
+  struct wl_callback *callback;
   gboolean done;
 
   g_return_if_fail (GDK_IS_DISPLAY (display));
 
   display_wayland = GDK_DISPLAY_WAYLAND (display);
 
-  wl_display_sync_callback(display_wayland->wl_display, sync_callback, &done);
+  callback=wl_display_sync(display_wayland->wl_display);
+  wl_callback_add_listener(callback, &sync_listener, &done);
   wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_WRITABLE);
-  while (!done)
-    wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_READABLE);
+  wl_display_roundtrip(display_wayland->wl_display);
 }
 
 static void
-- 
1.7.1



More information about the wayland-devel mailing list