[mutter/wip/tablet-protocol: 46/57] wayland: Add MetaWaylandTablet



commit 5cca6f111648dc2ccf6658b878a300e7a38158e2
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri Jan 9 17:20:22 2015 +0100

    wayland: Add MetaWaylandTablet
    
    This (very basic at the moment) struct keeps server-side information
    for wl_tablet resources.

 src/Makefile.am                   |    2 +
 src/wayland/meta-wayland-tablet.c |  159 +++++++++++++++++++++++++++++++++++++
 src/wayland/meta-wayland-tablet.h |   61 ++++++++++++++
 src/wayland/meta-wayland-types.h  |    2 +
 4 files changed, 224 insertions(+), 0 deletions(-)
---
diff --git a/src/Makefile.am b/src/Makefile.am
index bae0716..ea8ddb1 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -258,6 +258,8 @@ libmutter_la_SOURCES +=                             \
        wayland/meta-wayland-pointer.h          \
        wayland/meta-wayland-seat.c             \
        wayland/meta-wayland-seat.h             \
+       wayland/meta-wayland-tablet.c           \
+       wayland/meta-wayland-tablet.h           \
        wayland/meta-wayland-touch.c            \
        wayland/meta-wayland-touch.h            \
        wayland/meta-wayland-surface.c          \
diff --git a/src/wayland/meta-wayland-tablet.c b/src/wayland/meta-wayland-tablet.c
new file mode 100644
index 0000000..b990f18
--- /dev/null
+++ b/src/wayland/meta-wayland-tablet.c
@@ -0,0 +1,159 @@
+/*
+ * 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 <wayland-server.h>
+#include "wayland-tablet-server-protocol.h"
+
+#include "meta-surface-actor-wayland.h"
+#include "meta-wayland-private.h"
+#include "meta-wayland-tablet.h"
+
+static void
+unbind_resource (struct wl_resource *resource)
+{
+  wl_list_remove (wl_resource_get_link (resource));
+}
+
+MetaWaylandTablet *
+meta_wayland_tablet_new (ClutterInputDevice       *device,
+                         MetaWaylandTabletManager *manager)
+{
+  MetaWaylandTablet *tablet;
+
+  tablet = g_slice_new0 (MetaWaylandTablet);
+  wl_list_init (&tablet->resource_list);
+  tablet->device = device;
+  tablet->manager = manager;
+
+  return tablet;
+}
+
+void
+meta_wayland_tablet_free (MetaWaylandTablet *tablet)
+{
+  struct wl_resource *resource, *next;
+
+  wl_resource_for_each_safe (resource, next, &tablet->resource_list)
+    {
+      wl_tablet_send_removed (resource);
+      wl_resource_destroy (resource);
+    }
+
+  g_slice_free (MetaWaylandTablet, tablet);
+}
+
+void
+meta_wayland_tablet_update (MetaWaylandTablet  *tablet,
+                            const ClutterEvent *event)
+{
+}
+
+static void
+handle_motion_event (MetaWaylandTablet  *tablet,
+                     const ClutterEvent *event)
+{
+}
+
+static void
+handle_button_event (MetaWaylandTablet  *tablet,
+                     const ClutterEvent *event)
+{
+}
+
+gboolean
+meta_wayland_tablet_handle_event (MetaWaylandTablet  *tablet,
+                                  const ClutterEvent *event)
+{
+  switch (event->type)
+    {
+    case CLUTTER_MOTION:
+      handle_motion_event (tablet, event);
+    case CLUTTER_BUTTON_PRESS:
+    case CLUTTER_BUTTON_RELEASE:
+      handle_button_event (tablet, event);
+      break;
+    default:
+      return FALSE;
+    }
+  return TRUE;
+}
+
+static void
+tablet_release (struct wl_client   *client,
+                struct wl_resource *resource)
+{
+  wl_resource_destroy (resource);
+}
+
+static void
+tablet_set_cursor (struct wl_client   *client,
+                   struct wl_resource *resource,
+                   uint32_t            serial,
+                   struct wl_resource *surface_resource,
+                   int32_t             hotspot_x,
+                   int32_t             hotspot_y)
+{
+}
+
+static const struct wl_tablet_interface tablet_interface = {
+  tablet_release,
+  tablet_set_cursor
+};
+
+struct wl_resource *
+meta_wayland_tablet_create_new_resource (MetaWaylandTablet  *tablet,
+                                         struct wl_client   *client,
+                                         struct wl_resource *seat_resource,
+                                         uint32_t            id)
+{
+  struct wl_resource *resource;
+
+  resource = wl_resource_create (client, &wl_tablet_interface,
+                                 wl_resource_get_version (seat_resource), id);
+  wl_resource_set_implementation (resource, &tablet_interface,
+                                  tablet, unbind_resource);
+  wl_resource_set_user_data (resource, tablet);
+  wl_list_insert (&tablet->resource_list, wl_resource_get_link (resource));
+
+  return resource;
+}
+
+struct wl_resource *
+meta_wayland_tablet_lookup_resource (MetaWaylandTablet *tablet,
+                                     struct wl_client  *client)
+{
+  struct wl_resource *resource;
+
+  resource = wl_resource_find_for_client (&tablet->resource_list, client);
+
+  if (!resource)
+    resource = wl_resource_find_for_client (&tablet->focus_resource_list, client);
+
+  return resource;
+}
diff --git a/src/wayland/meta-wayland-tablet.h b/src/wayland/meta-wayland-tablet.h
new file mode 100644
index 0000000..3eba8bd
--- /dev/null
+++ b/src/wayland/meta-wayland-tablet.h
@@ -0,0 +1,61 @@
+/*
+ * 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_TABLET_H
+#define META_WAYLAND_TABLET_H
+
+#include <wayland-server.h>
+
+#include <glib.h>
+
+#include "meta-wayland-types.h"
+#include "meta-cursor-renderer.h"
+
+struct _MetaWaylandTablet
+{
+  MetaWaylandTabletManager *manager;
+  ClutterInputDevice *device;
+
+  struct wl_list resource_list;
+
+  MetaWaylandSurface *current;
+};
+
+MetaWaylandTablet * meta_wayland_tablet_new          (ClutterInputDevice       *device,
+                                                      MetaWaylandTabletManager *manager);
+void                meta_wayland_tablet_free         (MetaWaylandTablet        *tablet);
+
+void                meta_wayland_tablet_update       (MetaWaylandTablet  *tablet,
+                                                      const ClutterEvent *event);
+gboolean            meta_wayland_tablet_handle_event (MetaWaylandTablet  *tablet,
+                                                      const ClutterEvent *event);
+
+struct wl_resource *
+             meta_wayland_tablet_create_new_resource (MetaWaylandTablet  *tablet,
+                                                      struct wl_client   *client,
+                                                      struct wl_resource *seat_resource,
+                                                      uint32_t            id);
+struct wl_resource *
+             meta_wayland_tablet_lookup_resource     (MetaWaylandTablet  *tablet,
+                                                      struct wl_client   *client);
+
+
+#endif /* META_WAYLAND_TABLET_H */
diff --git a/src/wayland/meta-wayland-types.h b/src/wayland/meta-wayland-types.h
index f28a34d..be73a4f 100644
--- a/src/wayland/meta-wayland-types.h
+++ b/src/wayland/meta-wayland-types.h
@@ -31,6 +31,8 @@ typedef struct _MetaWaylandTouch MetaWaylandTouch;
 typedef struct _MetaWaylandDataSource MetaWaylandDataSource;
 typedef struct _MetaWaylandDataDevice MetaWaylandDataDevice;
 
+typedef struct _MetaWaylandTablet MetaWaylandTablet;
+
 typedef struct _MetaWaylandBuffer MetaWaylandBuffer;
 typedef struct _MetaWaylandRegion MetaWaylandRegion;
 


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