[mutter/wayland] wayland: fix interface versioning



commit 73ee4912818e8526d142652a9a6586d9c40008e8
Author: Giovanni Campagna <gcampagn redhat com>
Date:   Tue Sep 10 13:13:34 2013 +0200

    wayland: fix interface versioning
    
    Add MIN(...) with the interface version actually implemented
    to all resource constructor, so that we never risk seeing requests
    we don't implement (and consequently segfault)
    
    https://bugzilla.gnome.org/show_bug.cgi?id=707851

 src/wayland/meta-wayland-surface.c |    4 ++--
 src/wayland/meta-wayland.c         |    9 +++++----
 src/wayland/meta-xwayland.c        |    2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)
---
diff --git a/src/wayland/meta-wayland-surface.c b/src/wayland/meta-wayland-surface.c
index 1ce77f7..8374ebe 100644
--- a/src/wayland/meta-wayland-surface.c
+++ b/src/wayland/meta-wayland-surface.c
@@ -871,7 +871,7 @@ bind_shell (struct wl_client *client,
 {
   struct wl_resource *resource;
 
-  resource = wl_resource_create (client, &wl_shell_interface, version, id);
+  resource = wl_resource_create (client, &wl_shell_interface, MIN (1, version), id);
   wl_resource_set_implementation (resource, &meta_wayland_shell_interface, data, NULL);
 }
 
@@ -973,7 +973,7 @@ bind_gtk_shell (struct wl_client *client,
 {
   struct wl_resource *resource;
 
-  resource = wl_resource_create (client, &gtk_shell_interface, version, id);
+  resource = wl_resource_create (client, &gtk_shell_interface, MIN (1, version), id);
   wl_resource_set_implementation (resource, &meta_wayland_gtk_shell_interface, data, NULL);
 
   /* FIXME: ask the plugin */
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index adc2ef5..e20ae75 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -234,7 +234,7 @@ meta_wayland_compositor_create_surface (struct wl_client *wayland_client,
   surface = meta_wayland_surface_create (compositor,
                                         wayland_client,
                                         id,
-                                        wl_resource_get_version (wayland_compositor_resource));
+                                        MIN (3, wl_resource_get_version (wayland_compositor_resource)));
   
   compositor->surfaces = g_list_prepend (compositor->surfaces, surface);
 }
@@ -297,7 +297,8 @@ meta_wayland_compositor_create_region (struct wl_client *wayland_client,
   MetaWaylandRegion *region = g_slice_new0 (MetaWaylandRegion);
 
   region->resource = wl_resource_create (wayland_client,
-                                        &wl_region_interface, 1,
+                                        &wl_region_interface,
+                                        MIN (1, wl_resource_get_version (compositor_resource)),
                                         id);
   wl_resource_set_implementation (region->resource,
                                  &meta_wayland_region_interface, region,
@@ -335,7 +336,7 @@ bind_output (struct wl_client *client,
   struct wl_resource *resource;
   guint mode_flags;
 
-  resource = wl_resource_create (client, &wl_output_interface, version, id);
+  resource = wl_resource_create (client, &wl_output_interface, MIN (2, version), id);
   wayland_output->resources = g_list_prepend (wayland_output->resources, resource);
 
   wl_resource_set_user_data (resource, wayland_output);
@@ -518,7 +519,7 @@ compositor_bind (struct wl_client *client,
   MetaWaylandCompositor *compositor = data;
   struct wl_resource *resource;
 
-  resource = wl_resource_create (client, &wl_compositor_interface, version, id);
+  resource = wl_resource_create (client, &wl_compositor_interface, MIN (3, version), id);
   wl_resource_set_implementation (resource, &meta_wayland_compositor_interface, compositor, NULL);
 }
 
diff --git a/src/wayland/meta-xwayland.c b/src/wayland/meta-xwayland.c
index 3b3c699..2d1af18 100644
--- a/src/wayland/meta-xwayland.c
+++ b/src/wayland/meta-xwayland.c
@@ -88,7 +88,7 @@ bind_xserver (struct wl_client *client,
     return;
 
   compositor->xserver_resource =
-    wl_resource_create (client, &xserver_interface, version, id);
+    wl_resource_create (client, &xserver_interface, MIN (1, version), id);
   wl_resource_set_implementation (compositor->xserver_resource,
                                  &xserver_implementation, compositor, NULL);
 


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