[gtk/device-cleanup] gdk: Drop axis labels



commit edda2860c55d7576da500fe6731750301f421261
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Jun 9 15:26:04 2020 -0400

    gdk: Drop axis labels
    
    This was only ever implemented on X11, and the labels
    here were atom names, so unlikely to be useful for
    anything interesting.

 gdk/broadway/gdkdevice-broadway.c |   4 +-
 gdk/gdkdevice.c                   | 116 +++-----------------------------------
 gdk/gdkdevice.h                   |   3 -
 gdk/gdkdeviceprivate.h            |  12 ++--
 gdk/wayland/gdkdevice-wayland.c   |  25 ++++----
 gdk/x11/gdkdevicemanager-xi2.c    |   2 +-
 6 files changed, 29 insertions(+), 133 deletions(-)
---
diff --git a/gdk/broadway/gdkdevice-broadway.c b/gdk/broadway/gdkdevice-broadway.c
index 4ab5295c7d..756a052e73 100644
--- a/gdk/broadway/gdkdevice-broadway.c
+++ b/gdk/broadway/gdkdevice-broadway.c
@@ -73,8 +73,8 @@ gdk_broadway_device_init (GdkBroadwayDevice *device_core)
 
   device = GDK_DEVICE (device_core);
 
-  _gdk_device_add_axis (device, NULL, GDK_AXIS_X, 0, 0, 1);
-  _gdk_device_add_axis (device, NULL, GDK_AXIS_Y, 0, 0, 1);
+  _gdk_device_add_axis (device, GDK_AXIS_X, 0, 0, 1);
+  _gdk_device_add_axis (device, GDK_AXIS_Y, 0, 0, 1);
 }
 
 static void
diff --git a/gdk/gdkdevice.c b/gdk/gdkdevice.c
index a6c8347f91..8072aea51e 100644
--- a/gdk/gdkdevice.c
+++ b/gdk/gdkdevice.c
@@ -51,9 +51,7 @@ typedef struct _GdkAxisInfo GdkAxisInfo;
 
 struct _GdkAxisInfo
 {
-  char *label;
   GdkAxisUse use;
-
   gdouble min_axis;
   gdouble max_axis;
   gdouble min_value;
@@ -366,19 +364,10 @@ gdk_device_class_init (GdkDeviceClass *klass)
                   G_TYPE_NONE, 1, GDK_TYPE_DEVICE_TOOL);
 }
 
-static void
-gdk_device_axis_info_clear (gpointer data)
-{
-  GdkAxisInfo *info = data;
-
-  g_free (info->label);
-}
-
 static void
 gdk_device_init (GdkDevice *device)
 {
   device->axes = g_array_new (FALSE, TRUE, sizeof (GdkAxisInfo));
-  g_array_set_clear_func (device->axes, gdk_device_axis_info_clear);
 }
 
 static void
@@ -872,89 +861,6 @@ gdk_device_get_n_axes (GdkDevice *device)
   return device->axes->len;
 }
 
-/**
- * gdk_device_get_axis_names:
- * @device: a #GdkDevice
- *
- * Returns a null-terminated array of strings, containing the labels for
- * the axes that @device currently has.
- * If the device has no axes, %NULL is returned.
- *
- * Returns: (nullable) (transfer full): A null-terminated string array,
- *     free with g_strfreev().
- **/
-char **
-gdk_device_get_axis_names (GdkDevice *device)
-{
-  GPtrArray *axes;
-  gint i;
-
-  g_return_val_if_fail (GDK_IS_DEVICE (device), NULL);
-  g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, NULL);
-
-  if (device->axes->len == 0)
-    return NULL;
-
-  axes = g_ptr_array_new ();
-
-  for (i = 0; i < device->axes->len; i++)
-    {
-      GdkAxisInfo axis_info;
-
-      axis_info = g_array_index (device->axes, GdkAxisInfo, i);
-      g_ptr_array_add (axes, g_strdup (axis_info.label));
-    }
-
-  g_ptr_array_add (axes, NULL);
-
-  return (char **) g_ptr_array_free (axes, FALSE);
-}
-
-/**
- * gdk_device_get_axis_value: (skip)
- * @device: a pointer #GdkDevice.
- * @axes: (array): pointer to an array of axes
- * @axis_label: name of the label
- * @value: (out): location to store the found value.
- *
- * Interprets an array of double as axis values for a given device,
- * and locates the value in the array for a given axis label, as returned
- * by gdk_device_get_axes()
- *
- * Returns: %TRUE if the given axis use was found, otherwise %FALSE.
- **/
-gboolean
-gdk_device_get_axis_value (GdkDevice  *device,
-                           gdouble    *axes,
-                           const char *axis_label,
-                           gdouble    *value)
-{
-  gint i;
-
-  g_return_val_if_fail (GDK_IS_DEVICE (device), FALSE);
-  g_return_val_if_fail (device->source != GDK_SOURCE_KEYBOARD, FALSE);
-
-  if (axes == NULL)
-    return FALSE;
-
-  for (i = 0; i < device->axes->len; i++)
-    {
-      GdkAxisInfo axis_info;
-
-      axis_info = g_array_index (device->axes, GdkAxisInfo, i);
-
-      if (!g_str_equal (axis_info.label, axis_label))
-        continue;
-
-      if (value)
-        *value = axes[i];
-
-      return TRUE;
-    }
-
-  return FALSE;
-}
-
 /**
  * gdk_device_get_axis: (skip)
  * @device: a #GdkDevice
@@ -1091,7 +997,6 @@ _gdk_device_reset_axes (GdkDevice *device)
 
 guint
 _gdk_device_add_axis (GdkDevice   *device,
-                      const char  *label_name,
                       GdkAxisUse   use,
                       gdouble      min_value,
                       gdouble      max_value,
@@ -1101,7 +1006,6 @@ _gdk_device_add_axis (GdkDevice   *device,
   guint pos;
 
   axis_info.use = use;
-  axis_info.label = g_strdup (label_name);
   axis_info.min_value = min_value;
   axis_info.max_value = max_value;
   axis_info.resolution = resolution;
@@ -1137,12 +1041,11 @@ _gdk_device_add_axis (GdkDevice   *device,
 
 void
 _gdk_device_get_axis_info (GdkDevice   *device,
-                          guint        index_,
-                          const char **label_name,
-                          GdkAxisUse   *use,
-                          gdouble      *min_value,
-                          gdouble      *max_value,
-                          gdouble      *resolution)
+                           guint        index_,
+                           GdkAxisUse   *use,
+                           gdouble      *min_value,
+                           gdouble      *max_value,
+                           gdouble      *resolution)
 {
   GdkAxisInfo *info;
 
@@ -1151,7 +1054,6 @@ _gdk_device_get_axis_info (GdkDevice   *device,
 
   info = &g_array_index (device->axes, GdkAxisInfo, index_);
 
-  *label_name = info->label;
   *use = info->use;
   *min_value = info->min_value;
   *max_value = info->max_value;
@@ -1178,10 +1080,10 @@ find_axis_info (GArray     *array,
 
 gboolean
 _gdk_device_translate_surface_coord (GdkDevice *device,
-                                    GdkSurface *surface,
-                                    guint      index_,
-                                    gdouble    value,
-                                    gdouble   *axis_value)
+                                     GdkSurface *surface,
+                                     guint      index_,
+                                     gdouble    value,
+                                     gdouble   *axis_value)
 {
   GdkAxisInfo axis_info;
   GdkAxisInfo *axis_info_x, *axis_info_y;
diff --git a/gdk/gdkdevice.h b/gdk/gdkdevice.h
index 56b76d49a0..bd5a55bcf4 100644
--- a/gdk/gdkdevice.h
+++ b/gdk/gdkdevice.h
@@ -133,11 +133,8 @@ GdkSurface * gdk_device_get_surface_at_position (GdkDevice *device,
 GDK_AVAILABLE_IN_ALL
 gint     gdk_device_get_n_axes     (GdkDevice       *device);
 GDK_AVAILABLE_IN_ALL
-char **  gdk_device_get_axis_names (GdkDevice       *device);
-GDK_AVAILABLE_IN_ALL
 gboolean gdk_device_get_axis_value (GdkDevice       *device,
                                     gdouble         *axes,
-                                    const char      *axis_label,
                                     gdouble         *value);
 
 GDK_AVAILABLE_IN_ALL
diff --git a/gdk/gdkdeviceprivate.h b/gdk/gdkdeviceprivate.h
index 4ca7c99694..e48c06f0b2 100644
--- a/gdk/gdkdeviceprivate.h
+++ b/gdk/gdkdeviceprivate.h
@@ -97,18 +97,16 @@ void  _gdk_device_set_associated_device (GdkDevice *device,
 
 void  _gdk_device_reset_axes (GdkDevice   *device);
 guint _gdk_device_add_axis   (GdkDevice   *device,
-                              const char  *label_atom,
                               GdkAxisUse   use,
                               gdouble      min_value,
                               gdouble      max_value,
                               gdouble      resolution);
 void _gdk_device_get_axis_info (GdkDevice  *device,
-                               guint       index,
-                               const char**label_atom,
-                               GdkAxisUse *use,
-                               gdouble    *min_value,
-                               gdouble    *max_value,
-                               gdouble    *resolution);
+                                guint       index,
+                                GdkAxisUse *use,
+                                gdouble    *min_value,
+                                gdouble    *max_value,
+                                gdouble    *resolution);
 
 gboolean   _gdk_device_translate_surface_coord (GdkDevice *device,
                                                 GdkSurface *surface,
diff --git a/gdk/wayland/gdkdevice-wayland.c b/gdk/wayland/gdkdevice-wayland.c
index 17001aff1b..4c6fb513ef 100644
--- a/gdk/wayland/gdkdevice-wayland.c
+++ b/gdk/wayland/gdkdevice-wayland.c
@@ -832,8 +832,8 @@ gdk_wayland_device_init (GdkWaylandDevice *device_core)
 
   device = GDK_DEVICE (device_core);
 
-  _gdk_device_add_axis (device, NULL, GDK_AXIS_X, 0, 0, 1);
-  _gdk_device_add_axis (device, NULL, GDK_AXIS_Y, 0, 0, 1);
+  _gdk_device_add_axis (device, GDK_AXIS_X, 0, 0, 1);
+  _gdk_device_add_axis (device, GDK_AXIS_Y, 0, 0, 1);
 }
 
 static gint
@@ -3386,42 +3386,42 @@ gdk_wayland_device_tablet_clone_tool_axes (GdkWaylandTabletData *tablet,
   g_object_freeze_notify (G_OBJECT (tablet->current_device));
   _gdk_device_reset_axes (tablet->current_device);
 
-  _gdk_device_add_axis (tablet->current_device, NULL, GDK_AXIS_X, 0, 0, 0);
-  _gdk_device_add_axis (tablet->current_device, NULL, GDK_AXIS_Y, 0, 0, 0);
+  _gdk_device_add_axis (tablet->current_device, GDK_AXIS_X, 0, 0, 0);
+  _gdk_device_add_axis (tablet->current_device, GDK_AXIS_Y, 0, 0, 0);
 
   if (tool->tool_axes & (GDK_AXIS_FLAG_XTILT | GDK_AXIS_FLAG_YTILT))
     {
-      axis_pos = _gdk_device_add_axis (tablet->current_device, NULL,
+      axis_pos = _gdk_device_add_axis (tablet->current_device,
                                        GDK_AXIS_XTILT, -90, 90, 0);
       tablet->axis_indices[GDK_AXIS_XTILT] = axis_pos;
 
-      axis_pos = _gdk_device_add_axis (tablet->current_device, NULL,
+      axis_pos = _gdk_device_add_axis (tablet->current_device,
                                        GDK_AXIS_YTILT, -90, 90, 0);
       tablet->axis_indices[GDK_AXIS_YTILT] = axis_pos;
     }
   if (tool->tool_axes & GDK_AXIS_FLAG_DISTANCE)
     {
-      axis_pos = _gdk_device_add_axis (tablet->current_device, NULL,
+      axis_pos = _gdk_device_add_axis (tablet->current_device,
                                        GDK_AXIS_DISTANCE, 0, 65535, 0);
       tablet->axis_indices[GDK_AXIS_DISTANCE] = axis_pos;
     }
   if (tool->tool_axes & GDK_AXIS_FLAG_PRESSURE)
     {
-      axis_pos = _gdk_device_add_axis (tablet->current_device, NULL,
+      axis_pos = _gdk_device_add_axis (tablet->current_device,
                                        GDK_AXIS_PRESSURE, 0, 65535, 0);
       tablet->axis_indices[GDK_AXIS_PRESSURE] = axis_pos;
     }
 
   if (tool->tool_axes & GDK_AXIS_FLAG_ROTATION)
     {
-      axis_pos = _gdk_device_add_axis (tablet->current_device, NULL,
+      axis_pos = _gdk_device_add_axis (tablet->current_device,
                                        GDK_AXIS_ROTATION, 0, 360, 0);
       tablet->axis_indices[GDK_AXIS_ROTATION] = axis_pos;
     }
 
   if (tool->tool_axes & GDK_AXIS_FLAG_SLIDER)
     {
-      axis_pos = _gdk_device_add_axis (tablet->current_device, NULL,
+      axis_pos = _gdk_device_add_axis (tablet->current_device,
                                        GDK_AXIS_SLIDER, -65535, 65535, 0);
       tablet->axis_indices[GDK_AXIS_SLIDER] = axis_pos;
     }
@@ -3440,7 +3440,6 @@ gdk_wayland_mimic_device_axes (GdkDevice *master,
                                GdkDevice *slave)
 {
   gdouble axis_min, axis_max, axis_resolution;
-  const char *axis_label;
   GdkAxisUse axis_use;
   gint axis_count;
   gint i;
@@ -3451,9 +3450,9 @@ gdk_wayland_mimic_device_axes (GdkDevice *master,
 
   for (i = 0; i < axis_count; i++)
     {
-      _gdk_device_get_axis_info (slave, i, &axis_label, &axis_use, &axis_min,
+      _gdk_device_get_axis_info (slave, i, &axis_use, &axis_min,
                                  &axis_max, &axis_resolution);
-      _gdk_device_add_axis (master, axis_label, axis_use, axis_min,
+      _gdk_device_add_axis (master, axis_use, axis_min,
                             axis_max, axis_resolution);
     }
 
diff --git a/gdk/x11/gdkdevicemanager-xi2.c b/gdk/x11/gdkdevicemanager-xi2.c
index 13197cccf4..51aff731dd 100644
--- a/gdk/x11/gdkdevicemanager-xi2.c
+++ b/gdk/x11/gdkdevicemanager-xi2.c
@@ -239,7 +239,7 @@ translate_valuator_class (GdkDisplay          *display,
   else
     label = NULL;
 
-  _gdk_device_add_axis (device, label, use, min, max, resolution);
+  _gdk_device_add_axis (device, use, min, max, resolution);
   GDK_DISPLAY_NOTE (display, INPUT, g_message ("\n\taxis: %s %s", label, use == GDK_AXIS_IGNORE ? 
"(ignored)" : "(used)"));
 }
 


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