GdkDeviceTool: Add GdkAxisFlags info to tablet tools
authorStephen Chandler Paul <thatslyude@gmail.com>
Mon, 22 Jun 2015 15:19:16 +0000 (17:19 +0200)
committerCarlos Garnacho <carlosg@gnome.org>
Wed, 6 Apr 2016 13:43:29 +0000 (15:43 +0200)
Different tools may have different sets of axes, we should store that
info somewhere.

gdk/gdkdevice.c
gdk/gdkdeviceprivate.h
gdk/x11/gdkdevicemanager-xi2.c

index bd1240d521d5954050c0eb624613fee9d18b327c..58c5d24fab165c41c102d6ad40e41cdb32cb2fda 100644 (file)
@@ -2031,6 +2031,7 @@ enum {
   TOOL_PROP_0,
   TOOL_PROP_SERIAL,
   TOOL_PROP_TOOL_TYPE,
+  TOOL_PROP_AXES,
   N_TOOL_PROPS
 };
 
@@ -2052,6 +2053,9 @@ gdk_device_tool_set_property (GObject      *object,
     case TOOL_PROP_TOOL_TYPE:
       tool->type = g_value_get_enum (value);
       break;
+    case TOOL_PROP_AXES:
+      tool->tool_axes = g_value_get_flags (value);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2074,6 +2078,9 @@ gdk_device_tool_get_property (GObject    *object,
     case TOOL_PROP_TOOL_TYPE:
       g_value_set_enum (value, tool->type);
       break;
+    case TOOL_PROP_AXES:
+      g_value_set_flags (value, tool->tool_axes);
+      break;
     default:
       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
       break;
@@ -2101,6 +2108,12 @@ gdk_device_tool_class_init (GdkDeviceToolClass *klass)
                                                        GDK_DEVICE_TOOL_TYPE_UNKNOWN,
                                                        G_PARAM_READWRITE |
                                                        G_PARAM_CONSTRUCT_ONLY);
+  tool_props[TOOL_PROP_AXES] = g_param_spec_flags ("axes",
+                                                   "Axes",
+                                                   "Tool axes",
+                                                   GDK_TYPE_AXIS_FLAGS, 0,
+                                                   G_PARAM_READWRITE |
+                                                   G_PARAM_CONSTRUCT_ONLY);
 
   g_object_class_install_properties (object_class, N_TOOL_PROPS, tool_props);
 }
@@ -2112,11 +2125,13 @@ gdk_device_tool_init (GdkDeviceTool *tool)
 
 GdkDeviceTool *
 gdk_device_tool_new (guint64           serial,
-                     GdkDeviceToolType type)
+                     GdkDeviceToolType type,
+                     GdkAxisFlags      tool_axes)
 {
   return g_object_new (GDK_TYPE_DEVICE_TOOL,
                        "serial", serial,
                        "tool-type", type,
+                       "axes", tool_axes,
                        NULL);
 }
 
index 6a0221ff00944b144375faeb2bc999ef056865de..d0007ea9b42e36708c5813fc63ab34e94f28d9ca 100644 (file)
@@ -38,6 +38,7 @@ struct _GdkDeviceTool
   GObject parent_instance;
   guint64 serial;
   GdkDeviceToolType type;
+  GdkAxisFlags tool_axes;
 };
 
 struct _GdkDeviceToolClass
@@ -200,7 +201,8 @@ void  gdk_device_set_seat  (GdkDevice *device,
 
 /* Device tools */
 GdkDeviceTool *gdk_device_tool_new    (guint64            serial,
-                                       GdkDeviceToolType  type);
+                                       GdkDeviceToolType  type,
+                                       GdkAxisFlags       tool_axes);
 void           gdk_device_update_tool (GdkDevice     *device,
                                        GdkDeviceTool *tool);
 
index 71d014d353c0d8bea015ecc90d18c4556992a0af..310e24ec9f1820f8e2c59f54d6211934a4d0535d 100644 (file)
@@ -1023,7 +1023,7 @@ handle_property_change (GdkX11DeviceManagerXI2 *device_manager,
           if (!tool && serial_id > 0)
             {
               tool = gdk_device_tool_new (serial_id,
-                                          GDK_DEVICE_TOOL_TYPE_UNKNOWN);
+                                          GDK_DEVICE_TOOL_TYPE_UNKNOWN, 0);
               gdk_seat_default_add_tool (GDK_SEAT_DEFAULT (seat), tool);
             }
         }