[gtk+/wip/wayland-tablet-v2: 9/19] gdk: Add GdkDevicePad
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/wayland-tablet-v2: 9/19] gdk: Add GdkDevicePad
- Date: Thu, 4 Aug 2016 17:59:32 +0000 (UTC)
commit fb24e7650da6bbdb362709796aeffe13b59d36c2
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Aug 4 19:12:57 2016 +0200
gdk: Add GdkDevicePad
This is an interface meant to be implemented by the "pad" devices.
This device-specific interface exposes the mapping of all pad features,
it allows retrieving:
- The number of buttons/rings/strips
- The number of groups
- The number of modes a group has
- Whether a given button/ring/strip belongs to a given group
gdk/Makefile.am | 3 ++
gdk/gdk.h | 1 +
gdk/gdkdevicepad.c | 75 +++++++++++++++++++++++++++++++++++++++++++++
gdk/gdkdevicepad.h | 66 +++++++++++++++++++++++++++++++++++++++
gdk/gdkdevicepadprivate.h | 45 +++++++++++++++++++++++++++
5 files changed, 190 insertions(+), 0 deletions(-)
---
diff --git a/gdk/Makefile.am b/gdk/Makefile.am
index 188ff56..4267588 100644
--- a/gdk/Makefile.am
+++ b/gdk/Makefile.am
@@ -71,6 +71,7 @@ gdk_public_h_sources = \
gdkcairo.h \
gdkcursor.h \
gdkdevice.h \
+ gdkdevicepad.h \
gdkdevicetool.h \
gdkdevicemanager.h \
gdkdisplay.h \
@@ -114,6 +115,7 @@ gdk_private_headers = \
gdkcursorprivate.h \
gdkdevicemanagerprivate.h \
gdkdeviceprivate.h \
+ gdkdevicepadprivate.h \
gdkdevicetoolprivate.h \
gdkdisplaymanagerprivate.h \
gdkdisplayprivate.h \
@@ -144,6 +146,7 @@ gdk_c_sources = \
gdkcursor.c \
gdkdeprecated.c \
gdkdevice.c \
+ gdkdevicepad.c \
gdkdevicetool.c \
gdkdevicemanager.c \
gdkdisplay.c \
diff --git a/gdk/gdk.h b/gdk/gdk.h
index 92bafe1..3878f10 100644
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -33,6 +33,7 @@
#include <gdk/gdkcairo.h>
#include <gdk/gdkcursor.h>
#include <gdk/gdkdevice.h>
+#include <gdk/gdkdevicepad.h>
#include <gdk/gdkdevicetool.h>
#include <gdk/gdkdevicemanager.h>
#include <gdk/gdkdisplay.h>
diff --git a/gdk/gdkdevicepad.c b/gdk/gdkdevicepad.c
new file mode 100644
index 0000000..b8983a6
--- /dev/null
+++ b/gdk/gdkdevicepad.c
@@ -0,0 +1,75 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2016 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>
+ */
+
+#include "config.h"
+
+#include "gdkdevicepad.h"
+#include "gdkdevicepadprivate.h"
+#include "gdkdeviceprivate.h"
+
+G_DEFINE_INTERFACE (GdkDevicePad, gdk_device_pad, GDK_TYPE_DEVICE)
+
+static void
+gdk_device_pad_default_init (GdkDevicePadInterface *pad)
+{
+}
+
+gint
+gdk_device_pad_get_n_groups (GdkDevicePad *pad)
+{
+ GdkDevicePadInterface *iface = GDK_DEVICE_PAD_GET_IFACE (pad);
+
+ g_return_val_if_fail (GDK_IS_DEVICE_PAD (pad), 0);
+
+ return iface->get_n_groups (pad);
+}
+
+gint
+gdk_device_pad_get_n_group_modes (GdkDevicePad *pad,
+ gint group)
+{
+ GdkDevicePadInterface *iface = GDK_DEVICE_PAD_GET_IFACE (pad);
+
+ g_return_val_if_fail (GDK_IS_DEVICE_PAD (pad), 0);
+
+ return iface->get_n_group_modes (pad, group);
+}
+
+gint
+gdk_device_pad_get_n_features (GdkDevicePad *pad,
+ GdkDevicePadFeature feature)
+{
+ GdkDevicePadInterface *iface = GDK_DEVICE_PAD_GET_IFACE (pad);
+
+ g_return_val_if_fail (GDK_IS_DEVICE_PAD (pad), 0);
+
+ return iface->get_n_features (pad, feature);
+}
+
+gint
+gdk_device_pad_get_feature_group (GdkDevicePad *pad,
+ GdkDevicePadFeature feature,
+ gint idx)
+{
+ GdkDevicePadInterface *iface = GDK_DEVICE_PAD_GET_IFACE (pad);
+
+ g_return_val_if_fail (GDK_IS_DEVICE_PAD (pad), -1);
+
+ return iface->get_feature_group (pad, feature, idx);
+}
diff --git a/gdk/gdkdevicepad.h b/gdk/gdkdevicepad.h
new file mode 100644
index 0000000..19253f4
--- /dev/null
+++ b/gdk/gdkdevicepad.h
@@ -0,0 +1,66 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2016 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 __GDK_DEVICE_PAD_H__
+#define __GDK_DEVICE_PAD_H__
+
+#if !defined (__GDK_H_INSIDE__) && !defined (GDK_COMPILATION)
+#error "Only <gdk/gdk.h> can be included directly."
+#endif
+
+#include <gdk/gdkversionmacros.h>
+#include <gdk/gdktypes.h>
+
+G_BEGIN_DECLS
+
+#define GDK_TYPE_DEVICE_PAD (gdk_device_pad_get_type ())
+#define GDK_DEVICE_PAD(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GDK_TYPE_DEVICE_PAD, GdkDevicePad))
+#define GDK_IS_DEVICE_PAD(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GDK_TYPE_DEVICE_PAD))
+
+typedef struct _GdkDevicePad GdkDevicePad;
+typedef struct _GdkDevicePadInterface GdkDevicePadInterface;
+
+typedef enum {
+ GDK_DEVICE_PAD_FEATURE_BUTTON,
+ GDK_DEVICE_PAD_FEATURE_RING,
+ GDK_DEVICE_PAD_FEATURE_STRIP
+} GdkDevicePadFeature;
+
+GDK_AVAILABLE_IN_3_22
+GType gdk_device_pad_get_type (void) G_GNUC_CONST;
+
+GDK_AVAILABLE_IN_3_22
+gint gdk_device_pad_get_n_groups (GdkDevicePad *pad);
+
+GDK_AVAILABLE_IN_3_22
+gint gdk_device_pad_get_n_group_modes (GdkDevicePad *pad,
+ gint group);
+
+GDK_AVAILABLE_IN_3_22
+gint gdk_device_pad_get_n_features (GdkDevicePad *pad,
+ GdkDevicePadFeature feature);
+
+GDK_AVAILABLE_IN_3_22
+gint gdk_device_pad_get_feature_group (GdkDevicePad *pad,
+ GdkDevicePadFeature feature,
+ gint idx);
+
+G_END_DECLS
+
+#endif /* __GDK_DEVICE_PAD_H__ */
diff --git a/gdk/gdkdevicepadprivate.h b/gdk/gdkdevicepadprivate.h
new file mode 100644
index 0000000..9334850
--- /dev/null
+++ b/gdk/gdkdevicepadprivate.h
@@ -0,0 +1,45 @@
+/* GDK - The GIMP Drawing Kit
+ * Copyright (C) 2016 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 __GDK_DEVICE_PAD_PRIVATE_H__
+#define __GDK_DEVICE_PAD_PRIVATE_H__
+
+#include "gdkdevicepad.h"
+
+G_BEGIN_DECLS
+
+#define GDK_DEVICE_PAD_GET_IFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GDK_TYPE_DEVICE_PAD,
GdkDevicePadInterface))
+
+struct _GdkDevicePadInterface {
+ GTypeInterface parent_interface;
+
+ gint (* get_n_groups) (GdkDevicePad *pad);
+
+ gint (* get_n_group_modes) (GdkDevicePad *pad,
+ gint group);
+ gint (* get_n_features) (GdkDevicePad *pad,
+ GdkDevicePadFeature feature);
+ gint (* get_feature_group) (GdkDevicePad *pad,
+ GdkDevicePadFeature feature,
+ gint idx);
+};
+
+G_END_DECLS
+
+#endif /* __GDK_DEVICE_PAD_PRIVATE_H__ */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]