[mutter] wayland/pointer-gestures: Send error on protocol version mismatch



commit e76c3ecb008ac079925b4cf4110c26e9f2f1a01c
Author: Jonas Ådahl <jadahl gmail com>
Date:   Thu Aug 20 11:29:23 2015 +0800

    wayland/pointer-gestures: Send error on protocol version mismatch
    
    When a client binds an incompatible version, we should terminate it.
    This check should only be there for the unstable version, as once it is
    declared stable and renamed, future versions will be backward compatible.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=753855

 src/wayland/meta-wayland-pointer-gestures.c |   11 ++++++++++-
 src/wayland/meta-wayland-versions.h         |    2 +-
 src/wayland/protocol/pointer-gestures.xml   |    4 ++++
 3 files changed, 15 insertions(+), 2 deletions(-)
---
diff --git a/src/wayland/meta-wayland-pointer-gestures.c b/src/wayland/meta-wayland-pointer-gestures.c
index 6fc1f1f..17fae0f 100644
--- a/src/wayland/meta-wayland-pointer-gestures.c
+++ b/src/wayland/meta-wayland-pointer-gestures.c
@@ -67,6 +67,15 @@ bind_pointer_gestures (struct wl_client *client,
   struct wl_resource *resource;
 
   resource = wl_resource_create (client, &_wl_pointer_gestures_interface, version, id);
+
+  if (version != META__WL_POINTER_GESTURES_VERSION)
+    {
+      wl_resource_post_error (resource,
+                              _WL_POINTER_GESTURES_ERROR_VERSION_MISMATCH,
+                              "The client bound a non-supported version");
+      return;
+    }
+
   wl_resource_set_implementation (resource, &pointer_gestures_interface,
                                   NULL, NULL);
 }
@@ -76,6 +85,6 @@ meta_wayland_pointer_gestures_init (MetaWaylandCompositor *compositor)
 {
   wl_global_create (compositor->wayland_display,
                     &_wl_pointer_gestures_interface,
-                    META_WL_POINTER_GESTURES_VERSION,
+                    META__WL_POINTER_GESTURES_VERSION,
                     NULL, bind_pointer_gestures);
 }
diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h
index e2030d6..9ca8def 100644
--- a/src/wayland/meta-wayland-versions.h
+++ b/src/wayland/meta-wayland-versions.h
@@ -44,6 +44,6 @@
 #define META_XSERVER_VERSION                1
 #define META_GTK_SHELL_VERSION              2
 #define META_WL_SUBCOMPOSITOR_VERSION       1
-#define META_WL_POINTER_GESTURES_VERSION    1
+#define META__WL_POINTER_GESTURES_VERSION   1
 
 #endif
diff --git a/src/wayland/protocol/pointer-gestures.xml b/src/wayland/protocol/pointer-gestures.xml
index 1bca8f7..041bf14 100644
--- a/src/wayland/protocol/pointer-gestures.xml
+++ b/src/wayland/protocol/pointer-gestures.xml
@@ -16,6 +16,10 @@
       name and the version will be reset to 1.
     </description>
 
+    <enum name="error">
+      <entry name="version_mismatch" value="0"/>
+    </enum>
+
     <request name="get_swipe_gesture">
       <description summary="get swipe gesture">
        Create a swipe gesture object. See the


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