[gtk+/gtk-3-6] wayland: Update to reflect protocol changes



commit c0c72b1d40359938da5629e9c686f06a74ce1eab
Author: Scott Moreau <oreaus gmail com>
Date:   Tue Oct 16 20:38:41 2012 -0600

    wayland: Update to reflect protocol changes
    
    (cherry picked from commit e5b88f1bdd570e9f411a8be41199adceb950c61c)

 gdk/wayland/gdkdevice-wayland.c  |    1 +
 gdk/wayland/gdkdisplay-wayland.c |   37 +++++++++++++++++++++----------------
 gdk/wayland/gdkdisplay-wayland.h |    1 +
 gdk/wayland/gdkeventsource.c     |   31 ++++---------------------------
 gdk/wayland/gdkprivate-wayland.h |    1 -
 gdk/wayland/gdkwindow-wayland.c  |    1 +
 6 files changed, 28 insertions(+), 44 deletions(-)
---
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 3f7091c..cef1ddf 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -183,6 +183,7 @@ gdk_device_core_set_window_cursor (GdkDevice *device,
                          x, y);
   wl_surface_attach (wd->pointer_surface, buffer, 0, 0);
   wl_surface_damage (wd->pointer_surface,  0, 0, w, h);
+  wl_surface_commit(wd->pointer_surface);
 
   g_object_unref (cursor);
 }
diff --git a/gdk/wayland/gdkdisplay-wayland.c b/gdk/wayland/gdkdisplay-wayland.c
index 734fd10..a2eb8e0 100644
--- a/gdk/wayland/gdkdisplay-wayland.c
+++ b/gdk/wayland/gdkdisplay-wayland.c
@@ -96,7 +96,8 @@ static void
 output_handle_geometry(void *data,
 		       struct wl_output *wl_output,
 		       int x, int y, int physical_width, int physical_height,
-		       int subpixel, const char *make, const char *model)
+		       int subpixel, const char *make, const char *model,
+		       int32_t transform)
 {
   /*
     g_signal_emit_by_name (screen, "monitors-changed");
@@ -119,8 +120,8 @@ static const struct wl_output_listener output_listener = {
 };
 
 static void
-gdk_display_handle_global(struct wl_display *display, uint32_t id,
-			  const char *interface, uint32_t version, void *data)
+gdk_registry_handle_global(void *data, struct wl_registry *registry, uint32_t id,
+					const char *interface, uint32_t version)
 {
   GdkWaylandDisplay *display_wayland = data;
   GdkDisplay *gdk_display = GDK_DISPLAY_OBJECT (data);
@@ -128,27 +129,29 @@ gdk_display_handle_global(struct wl_display *display, uint32_t id,
 
   if (strcmp(interface, "wl_compositor") == 0) {
     display_wayland->compositor =
-      wl_display_bind(display, id, &wl_compositor_interface);
+	wl_registry_bind(display_wayland->wl_registry, id, &wl_compositor_interface, 1);
   } else if (strcmp(interface, "wl_shm") == 0) {
-    display_wayland->shm = wl_display_bind(display, id, &wl_shm_interface);
+   display_wayland->shm =
+	wl_registry_bind(display_wayland->wl_registry, id, &wl_shm_interface, 1);
 
     /* SHM interface is prerequisite */
     _gdk_wayland_display_load_cursor_theme(display_wayland);
   } else if (strcmp(interface, "wl_shell") == 0) {
-    display_wayland->shell = wl_display_bind(display, id, &wl_shell_interface);
+    display_wayland->shell =
+	wl_registry_bind(display_wayland->wl_registry, id, &wl_shell_interface, 1);
   } else if (strcmp(interface, "wl_output") == 0) {
     display_wayland->output =
-      wl_display_bind(display, id, &wl_output_interface);
+      wl_registry_bind(display_wayland->wl_registry, id, &wl_output_interface, 1);
     wl_output_add_listener(display_wayland->output,
 			   &output_listener, display_wayland);
   } else if (strcmp(interface, "wl_seat") == 0) {
-    seat = wl_display_bind (display, id, &wl_seat_interface);
+    seat = wl_registry_bind(display_wayland->wl_registry, id, &wl_seat_interface, 1);
     _gdk_wayland_device_manager_add_device (gdk_display->device_manager,
 					    seat);
   } else if (strcmp(interface, "wl_data_device_manager") == 0) {
       display_wayland->data_device_manager =
-        wl_display_bind(display, id,
-                        &wl_data_device_manager_interface);
+        wl_registry_bind(display_wayland->wl_registry, id,
+					&wl_data_device_manager_interface, 1);
   }
 }
 
@@ -210,6 +213,10 @@ gdk_display_init_egl(GdkDisplay *display)
 }
 #endif
 
+static const struct wl_registry_listener registry_listener = {
+	gdk_registry_handle_global
+};
+
 GdkDisplay *
 _gdk_wayland_display_open (const gchar *display_name)
 {
@@ -231,14 +238,13 @@ _gdk_wayland_display_open (const gchar *display_name)
   display->device_manager = _gdk_wayland_device_manager_new (display);
 
   /* Set up listener so we'll catch all events. */
-  wl_display_add_global_listener(display_wayland->wl_display,
-				 gdk_display_handle_global, display_wayland);
+  display_wayland->wl_registry = wl_display_get_registry(display_wayland->wl_display);
+  wl_registry_add_listener(display_wayland->wl_registry, &registry_listener, display_wayland);
 
 #ifdef GDK_WAYLAND_USE_EGL
   gdk_display_init_egl(display);
 #else
-  wl_display_iterate(wl_display, WL_DISPLAY_READABLE);
-  wl_display_roundtrip(wl_display);
+  wl_display_dispatch(display_wayland->wl_display);
 #endif
 
   display_wayland->event_source =
@@ -351,8 +357,7 @@ gdk_wayland_display_flush (GdkDisplay *display)
   g_return_if_fail (GDK_IS_DISPLAY (display));
 
   if (!display->closed)
-    _gdk_wayland_display_flush (display,
-				GDK_WAYLAND_DISPLAY (display)->event_source);
+    wl_display_flush(GDK_WAYLAND_DISPLAY (display)->wl_display);;
 }
 
 static gboolean
diff --git a/gdk/wayland/gdkdisplay-wayland.h b/gdk/wayland/gdkdisplay-wayland.h
index c31a82b..5e8e76f 100644
--- a/gdk/wayland/gdkdisplay-wayland.h
+++ b/gdk/wayland/gdkdisplay-wayland.h
@@ -76,6 +76,7 @@ struct _GdkWaylandDisplay
 
   /* Wayland fields below */
   struct wl_display *wl_display;
+  struct wl_registry *wl_registry;
   struct wl_compositor *compositor;
   struct wl_shm *shm;
   struct wl_shell *shell;
diff --git a/gdk/wayland/gdkeventsource.c b/gdk/wayland/gdkeventsource.c
index f86a580..31918f4 100644
--- a/gdk/wayland/gdkeventsource.c
+++ b/gdk/wayland/gdkeventsource.c
@@ -44,8 +44,7 @@ gdk_event_source_prepare(GSource *base, gint *timeout)
   if (_gdk_event_queue_find_first (source->display) != NULL)
     return TRUE;
 
-  while (source->mask & WL_DISPLAY_WRITABLE)
-    wl_display_iterate(display->wl_display, WL_DISPLAY_WRITABLE);
+  wl_display_flush(display->wl_display);
 
   return FALSE;
 }
@@ -97,16 +96,6 @@ static GSourceFuncs wl_glib_source_funcs = {
   gdk_event_source_finalize
 };
 
-static int
-gdk_event_source_update(uint32_t mask, void *data)
-{
-  GdkWaylandEventSource *source = data;
-
-  source->mask = mask;
-
-  return 0;
-}
-
 void
 _gdk_wayland_display_deliver_event (GdkDisplay *display, GdkEvent *event)
 {
@@ -134,8 +123,7 @@ _gdk_wayland_display_event_source_new (GdkDisplay *display)
 
   display_wayland = GDK_WAYLAND_DISPLAY (display);
   wl_source->display = display;
-  wl_source->pfd.fd = wl_display_get_fd(display_wayland->wl_display,
-					gdk_event_source_update, source);
+  wl_source->pfd.fd = wl_display_get_fd(display_wayland->wl_display);
   wl_source->pfd.events = G_IO_IN | G_IO_ERR;
   g_source_add_poll(source, &wl_source->pfd);
 
@@ -149,16 +137,6 @@ _gdk_wayland_display_event_source_new (GdkDisplay *display)
 }
 
 void
-_gdk_wayland_display_flush (GdkDisplay *display, GSource *source)
-{
-  GdkWaylandEventSource *wayland_source = (GdkWaylandEventSource *) source;
-
-  while (wayland_source->mask & WL_DISPLAY_WRITABLE)
-    wl_display_iterate(GDK_WAYLAND_DISPLAY (display)->wl_display,
-		       WL_DISPLAY_WRITABLE);
-}
-
-void
 _gdk_wayland_display_queue_events (GdkDisplay *display)
 {
   GdkWaylandDisplay *display_wayland;
@@ -166,10 +144,9 @@ _gdk_wayland_display_queue_events (GdkDisplay *display)
 
   display_wayland = GDK_WAYLAND_DISPLAY (display);
   source = (GdkWaylandEventSource *) display_wayland->event_source;
-
   if (source->pfd.revents)
     {
-      wl_display_iterate(display_wayland->wl_display, WL_DISPLAY_READABLE);
-      source->pfd.revents = 0;
+	wl_display_dispatch(display_wayland->wl_display);
+	source->pfd.revents = 0;
     }
 }
diff --git a/gdk/wayland/gdkprivate-wayland.h b/gdk/wayland/gdkprivate-wayland.h
index a47f4ec..8a3161b 100644
--- a/gdk/wayland/gdkprivate-wayland.h
+++ b/gdk/wayland/gdkprivate-wayland.h
@@ -137,7 +137,6 @@ GdkKeymap *_gdk_wayland_device_get_keymap (GdkDevice *device);
 void     _gdk_wayland_display_deliver_event (GdkDisplay *display, GdkEvent *event);
 GSource *_gdk_wayland_display_event_source_new (GdkDisplay *display);
 void     _gdk_wayland_display_queue_events (GdkDisplay *display);
-void     _gdk_wayland_display_flush (GdkDisplay *display, GSource *source);
 
 GdkAppLaunchContext *_gdk_wayland_display_get_app_launch_context (GdkDisplay *display);
 
diff --git a/gdk/wayland/gdkwindow-wayland.c b/gdk/wayland/gdkwindow-wayland.c
index fad879e..553d0b9 100644
--- a/gdk/wayland/gdkwindow-wayland.c
+++ b/gdk/wayland/gdkwindow-wayland.c
@@ -1563,6 +1563,7 @@ gdk_wayland_window_process_updates_recurse (GdkWindow      *window,
       cairo_region_get_rectangle (region, i, &rect);
       wl_surface_damage (impl->surface,
                          rect.x, rect.y, rect.width, rect.height);
+      wl_surface_commit(impl->surface);
     }
 
   _gdk_window_process_updates_recurse (window, region);



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]