[mutter/wip/tablet-protocol-v2: 43/65] clutter: Add clutter_input_device_[gs]et_mapping()



commit c6bc114570e2166c30e18d8bb9888d430465a217
Author: Carlos Garnacho <carlosg gnome org>
Date:   Fri May 13 19:57:51 2016 +0200

    clutter: Add clutter_input_device_[gs]et_mapping()
    
    This function call only applies to tablets, and thus will error
    out unless it's called with CLUTTER_TABLET_DEVICEs. This will
    allow setting absolute/relative mapping on those on the fly, as
    this is optional.

 clutter/clutter/clutter-device-manager-private.h |    2 +
 clutter/clutter/clutter-enums.h                  |    5 ++
 clutter/clutter/clutter-input-device.c           |   44 ++++++++++++++++++++++
 clutter/clutter/clutter-input-device.h           |    7 +++
 4 files changed, 58 insertions(+), 0 deletions(-)
---
diff --git a/clutter/clutter/clutter-device-manager-private.h 
b/clutter/clutter/clutter-device-manager-private.h
index bafc024..7efe768 100644
--- a/clutter/clutter/clutter-device-manager-private.h
+++ b/clutter/clutter/clutter-device-manager-private.h
@@ -139,6 +139,8 @@ struct _ClutterInputDevice
   gint n_strips;
   gint n_mode_groups;
 
+  ClutterInputDeviceMapping mapping_mode;
+
   guint has_cursor : 1;
   guint is_enabled : 1;
 };
diff --git a/clutter/clutter/clutter-enums.h b/clutter/clutter/clutter-enums.h
index 6f779c5..03c0395 100644
--- a/clutter/clutter/clutter-enums.h
+++ b/clutter/clutter/clutter-enums.h
@@ -1531,6 +1531,11 @@ typedef enum {
   CLUTTER_INPUT_DEVICE_PAD_SOURCE_FINGER,
 } ClutterInputDevicePadSource;
 
+typedef enum {
+  CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE,
+  CLUTTER_INPUT_DEVICE_MAPPING_RELATIVE,
+} ClutterInputDeviceMapping;
+
 G_END_DECLS
 
 #endif /* __CLUTTER_ENUMS_H__ */
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index 4b0d169..ca3b073 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -74,6 +74,7 @@ enum
   PROP_N_RINGS,
   PROP_N_MODE_GROUPS,
   PROP_DEVICE_NODE,
+  PROP_MAPPING_MODE,
 
   PROP_LAST
 };
@@ -216,6 +217,10 @@ clutter_input_device_set_property (GObject      *gobject,
       self->node_path = g_value_dup_string (value);
       break;
 
+    case PROP_MAPPING_MODE:
+      self->mapping_mode = g_value_get_enum (value);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -292,6 +297,10 @@ clutter_input_device_get_property (GObject    *gobject,
       g_value_set_string (value, self->node_path);
       break;
 
+    case PROP_MAPPING_MODE:
+      g_value_set_enum (value, self->mapping_mode);
+      break;
+
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (gobject, prop_id, pspec);
       break;
@@ -497,6 +506,14 @@ clutter_input_device_class_init (ClutterInputDeviceClass *klass)
                          NULL,
                          CLUTTER_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY);
 
+  obj_props[PROP_MAPPING_MODE] =
+    g_param_spec_enum ("mapping-mode",
+                       P_("Device mapping mode"),
+                       P_("Device mapping mode"),
+                       CLUTTER_TYPE_INPUT_DEVICE_MAPPING,
+                       CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE,
+                       CLUTTER_PARAM_READWRITE);
+
   gobject_class->dispose = clutter_input_device_dispose;
   gobject_class->set_property = clutter_input_device_set_property;
   gobject_class->get_property = clutter_input_device_get_property;
@@ -2165,3 +2182,30 @@ clutter_input_device_get_device_node (ClutterInputDevice *device)
 
   return device->node_path;
 }
+
+ClutterInputDeviceMapping
+clutter_input_device_get_mapping_mode (ClutterInputDevice *device)
+{
+  g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device),
+                        CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE);
+  g_return_val_if_fail (clutter_input_device_get_device_type (device) ==
+                        CLUTTER_TABLET_DEVICE,
+                        CLUTTER_INPUT_DEVICE_MAPPING_ABSOLUTE);
+
+  return device->mapping_mode;
+}
+
+void
+clutter_input_device_set_mapping_mode (ClutterInputDevice        *device,
+                                       ClutterInputDeviceMapping  mapping)
+{
+  g_return_if_fail (CLUTTER_IS_INPUT_DEVICE (device));
+  g_return_if_fail (clutter_input_device_get_device_type (device) ==
+                    CLUTTER_TABLET_DEVICE);
+
+  if (device->mapping_mode == mapping)
+    return;
+
+  device->mapping_mode = mapping;
+  g_object_notify (G_OBJECT (device), "mapping-mode");
+}
diff --git a/clutter/clutter/clutter-input-device.h b/clutter/clutter/clutter-input-device.h
index 9b55d35..66b2a58 100644
--- a/clutter/clutter/clutter-input-device.h
+++ b/clutter/clutter/clutter-input-device.h
@@ -150,6 +150,13 @@ gint                    clutter_input_device_get_n_mode_groups  (ClutterInputDev
 CLUTTER_AVAILABLE_IN_ALL
 const gchar *           clutter_input_device_get_device_node    (ClutterInputDevice *device);
 
+CLUTTER_AVAILABLE_IN_ALL
+ClutterInputDeviceMapping clutter_input_device_get_mapping_mode (ClutterInputDevice *device);
+
+CLUTTER_AVAILABLE_IN_ALL
+void                      clutter_input_device_set_mapping_mode (ClutterInputDevice        *device,
+                                                                 ClutterInputDeviceMapping  mapping);
+
 G_END_DECLS
 
 #endif /* __CLUTTER_INPUT_DEVICE_H__ */


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