[mutter/wip/garnacho/touchpad-gestures: 4/4] wayland: Implement wl_pointer_gestures



commit b1a020b30dbe3273355d19150ab5ec6549c7e89d
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Jul 22 16:50:20 2015 +0200

    wayland: Implement wl_pointer_gestures
    
    The wl_pointer_gestures is backed by a MetaWaylandPointerGestures,
    this commit effectively bridges and enables clients to support the
    gestures protocol.

 src/Makefile.am                             |    2 +
 src/wayland/meta-wayland-pointer-gestures.c |  107 +++++++++++++++++++++++++++
 src/wayland/meta-wayland-pointer-gestures.h |   39 ++++++++++
 src/wayland/meta-wayland-private.h          |    2 +
 src/wayland/meta-wayland-types.h            |    1 +
 src/wayland/meta-wayland-versions.h         |    1 +
 src/wayland/meta-wayland.c                  |    1 +
 7 files changed, 153 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index 66f2249..97448a7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -253,6 +253,8 @@ libmutter_la_SOURCES +=                             \
        wayland/meta-wayland-data-device.c      \
        wayland/meta-wayland-data-device.h      \
        wayland/meta-wayland-data-device-private.h      \
+       wayland/meta-wayland-pointer-gestures.c \
+       wayland/meta-wayland-pointer-gestures.h \
        wayland/meta-wayland-pointer-gesture-swipe.c    \
        wayland/meta-wayland-pointer-gesture-swipe.h    \
        wayland/meta-wayland-pointer-gesture-pinch.c    \
diff --git a/src/wayland/meta-wayland-pointer-gestures.c b/src/wayland/meta-wayland-pointer-gestures.c
new file mode 100644
index 0000000..f948af9
--- /dev/null
+++ b/src/wayland/meta-wayland-pointer-gestures.c
@@ -0,0 +1,107 @@
+/*
+ * Wayland Support
+ *
+ * Copyright (C) 2015 Red Hat
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+ * 02111-1307, USA.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#define _GNU_SOURCE
+
+#include "config.h"
+
+#include <glib.h>
+#include "meta-wayland-pointer-gestures.h"
+#include "gestures-server-protocol.h"
+#include "meta-wayland-versions.h"
+#include "meta-wayland-private.h"
+
+static void
+unbind_resource (struct wl_resource *resource)
+{
+  wl_list_remove (wl_resource_get_link (resource));
+}
+
+static void
+gestures_get_swipe (struct wl_client   *client,
+                    struct wl_resource *resource,
+                    uint32_t            id,
+                    struct wl_resource *pointer_resource)
+{
+  MetaWaylandPointer *pointer = wl_resource_get_user_data (pointer_resource);
+  MetaWaylandPointerGestureSwipe *swipe = &pointer->swipe;
+
+  meta_wayland_pointer_gesture_swipe_create_new_resource (swipe, client, resource, id);
+}
+
+static void
+gestures_get_pinch (struct wl_client   *client,
+                    struct wl_resource *resource,
+                    uint32_t            id,
+                    struct wl_resource *pointer_resource)
+{
+  MetaWaylandPointer *pointer = wl_resource_get_user_data (pointer_resource);
+  MetaWaylandPointerGesturePinch *pinch = &pointer->pinch;
+
+  meta_wayland_pointer_gesture_pinch_create_new_resource (pinch, client, resource, id);
+}
+
+static const struct _wl_pointer_gestures_interface pointer_gestures_interface = {
+  gestures_get_swipe,
+  gestures_get_pinch
+};
+
+static void
+bind_pointer_gestures (struct wl_client *client,
+                       void             *data,
+                       guint32           version,
+                       guint32           id)
+{
+  MetaWaylandPointerGestures *gestures = data;
+  struct wl_resource *resource;
+
+  resource = wl_resource_create (client, &_wl_pointer_gestures_interface, version, id);
+  wl_resource_set_implementation (resource, &pointer_gestures_interface,
+                                  gestures, unbind_resource);
+  wl_list_insert (&gestures->resource_list, wl_resource_get_link (resource));
+}
+
+static MetaWaylandPointerGestures *
+meta_wayland_pointer_gestures_new (struct wl_display *display)
+{
+  MetaWaylandPointerGestures *gestures = g_new0 (MetaWaylandPointerGestures, 1);
+
+  wl_list_init (&gestures->resource_list);
+  wl_global_create (display, &_wl_pointer_gestures_interface,
+                    META_WL_POINTER_GESTURES_VERSION,
+                    gestures, bind_pointer_gestures);
+
+  return gestures;
+}
+
+void
+meta_wayland_pointer_gestures_free (MetaWaylandPointerGestures *gestures)
+{
+  g_free (gestures);
+}
+
+void
+meta_wayland_pointer_gestures_init (MetaWaylandCompositor *compositor)
+{
+  compositor->pointer_gestures = meta_wayland_pointer_gestures_new (compositor->wayland_display);
+}
diff --git a/src/wayland/meta-wayland-pointer-gestures.h b/src/wayland/meta-wayland-pointer-gestures.h
new file mode 100644
index 0000000..2fdd9e0
--- /dev/null
+++ b/src/wayland/meta-wayland-pointer-gestures.h
@@ -0,0 +1,39 @@
+/*
+ * Wayland Support
+ *
+ * Copyright (C) 2015 Red Hat
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library. If not, see <http://www.gnu.org/licenses/>.
+ *
+ * Author: Carlos Garnacho <carlosg gnome org>
+ */
+
+#ifndef META_WAYLAND_POINTER_GESTURES_H
+#define META_WAYLAND_POINTER_GESTURES_H
+
+#include <wayland-server.h>
+#include <glib.h>
+
+#include "meta-wayland-types.h"
+
+struct _MetaWaylandPointerGestures
+{
+  struct wl_display *display;
+  struct wl_list resource_list;
+};
+
+void meta_wayland_pointer_gestures_init (MetaWaylandCompositor *compositor);
+void meta_wayland_pointer_gestures_free (MetaWaylandPointerGestures *gestures);
+
+#endif /* META_WAYLAND_POINTER_GESTURES_H */
diff --git a/src/wayland/meta-wayland-private.h b/src/wayland/meta-wayland-private.h
index c93fcf2..88c40aa 100644
--- a/src/wayland/meta-wayland-private.h
+++ b/src/wayland/meta-wayland-private.h
@@ -32,6 +32,7 @@
 #include "meta-wayland-versions.h"
 #include "meta-wayland-surface.h"
 #include "meta-wayland-seat.h"
+#include "meta-wayland-pointer-gestures.h"
 
 typedef struct _MetaXWaylandSelection MetaXWaylandSelection;
 
@@ -68,6 +69,7 @@ struct _MetaWaylandCompositor
   MetaXWaylandManager xwayland_manager;
 
   MetaWaylandSeat *seat;
+  MetaWaylandPointerGestures *pointer_gestures;
 };
 
 #endif /* META_WAYLAND_PRIVATE_H */
diff --git a/src/wayland/meta-wayland-types.h b/src/wayland/meta-wayland-types.h
index 094d3f2..14fd3c1 100644
--- a/src/wayland/meta-wayland-types.h
+++ b/src/wayland/meta-wayland-types.h
@@ -43,6 +43,7 @@ typedef struct _MetaWaylandOutput MetaWaylandOutput;
 
 typedef struct _MetaWaylandSerial MetaWaylandSerial;
 
+typedef struct _MetaWaylandPointerGestures MetaWaylandPointerGestures;
 typedef struct _MetaWaylandPointerGestureSwipe MetaWaylandPointerGestureSwipe;
 typedef struct _MetaWaylandPointerGesturePinch MetaWaylandPointerGesturePinch;
 
diff --git a/src/wayland/meta-wayland-versions.h b/src/wayland/meta-wayland-versions.h
index 08ceaca..e2030d6 100644
--- a/src/wayland/meta-wayland-versions.h
+++ b/src/wayland/meta-wayland-versions.h
@@ -44,5 +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
 
 #endif
diff --git a/src/wayland/meta-wayland.c b/src/wayland/meta-wayland.c
index f11f8c5..13709f1 100644
--- a/src/wayland/meta-wayland.c
+++ b/src/wayland/meta-wayland.c
@@ -310,6 +310,7 @@ meta_wayland_init (void)
   meta_wayland_outputs_init (compositor);
   meta_wayland_data_device_manager_init (compositor);
   meta_wayland_shell_init (compositor);
+  meta_wayland_pointer_gestures_init (compositor);
   meta_wayland_seat_init (compositor);
 
   compositor->display_name = wl_display_add_socket_auto (compositor->wayland_display);


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