[mutter/wip/carlosg/clutter-seat: 85/101] clutter: Move pointer a11y from ClutterDeviceManager to ClutterSeat



commit 056cda89ce6d6faa291bb19b75ceddaf28d5befe
Author: Carlos Garnacho <carlosg gnome org>
Date:   Wed Oct 2 13:42:51 2019 +0200

    clutter: Move pointer a11y from ClutterDeviceManager to ClutterSeat
    
    A11y in general may be considered a per-seat feature.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/852

 clutter/clutter/clutter-device-manager-private.h |   2 -
 clutter/clutter/clutter-device-manager.c         | 177 ----------------------
 clutter/clutter/clutter-device-manager.h         |  33 ----
 clutter/clutter/clutter-input-pointer-a11y.c     |  42 +++---
 clutter/clutter/clutter-seat.c                   | 184 ++++++++++++++++++++++-
 clutter/clutter/clutter-seat.h                   |  35 +++++
 src/backends/meta-input-settings.c               |   7 +-
 src/backends/native/meta-backend-native.c        |   4 +-
 8 files changed, 243 insertions(+), 241 deletions(-)
---
diff --git a/clutter/clutter/clutter-device-manager-private.h 
b/clutter/clutter/clutter-device-manager-private.h
index 8ed440ca2..918381c55 100644
--- a/clutter/clutter/clutter-device-manager-private.h
+++ b/clutter/clutter/clutter-device-manager-private.h
@@ -211,8 +211,6 @@ ClutterBackend *_clutter_device_manager_get_backend             (ClutterDeviceMa
 void            _clutter_device_manager_compress_motion         (ClutterDeviceManager *device_manger,
                                                                  ClutterEvent         *event,
                                                                  const ClutterEvent   *to_discard);
-CLUTTER_EXPORT
-void            clutter_device_manager_ensure_a11y_state        (ClutterDeviceManager *device_manager);
 
 /* input device */
 CLUTTER_EXPORT
diff --git a/clutter/clutter/clutter-device-manager.c b/clutter/clutter/clutter-device-manager.c
index 03b97772f..e93ceee6a 100644
--- a/clutter/clutter/clutter-device-manager.c
+++ b/clutter/clutter/clutter-device-manager.c
@@ -53,9 +53,6 @@ struct _ClutterDeviceManagerPrivate
 {
   /* back-pointer to the backend */
   ClutterBackend *backend;
-
-  /* Pointer a11y */
-  ClutterPointerA11ySettings pointer_a11y_settings;
 };
 
 enum
@@ -74,9 +71,6 @@ enum
   DEVICE_ADDED,
   DEVICE_REMOVED,
   TOOL_CHANGED,
-  PTR_A11Y_DWELL_CLICK_TYPE_CHANGED,
-  PTR_A11Y_TIMEOUT_STARTED,
-  PTR_A11Y_TIMEOUT_STOPPED,
 
   LAST_SIGNAL
 };
@@ -192,69 +186,6 @@ clutter_device_manager_class_init (ClutterDeviceManagerClass *klass)
                   G_TYPE_NONE, 2,
                   CLUTTER_TYPE_INPUT_DEVICE,
                   CLUTTER_TYPE_INPUT_DEVICE_TOOL);
-
-  /**
-   * ClutterDeviceManager::ptr-a11y-dwell-click-type-changed:
-   * @manager: the #ClutterDeviceManager that emitted the signal
-   * @click_type: the new #ClutterPointerA11yDwellClickType mode
-   *
-   * The ::ptr-a11y-dwell-click-type-changed signal is emitted each time
-   * the ClutterPointerA11yDwellClickType mode is changed as the result
-   * of pointer accessibility operations.
-   */
-  manager_signals[PTR_A11Y_DWELL_CLICK_TYPE_CHANGED] =
-    g_signal_new (I_("ptr-a11y-dwell-click-type-changed"),
-                  G_TYPE_FROM_CLASS (klass),
-                  G_SIGNAL_RUN_LAST,
-                  0, NULL, NULL,
-                  g_cclosure_marshal_VOID__FLAGS,
-                  G_TYPE_NONE, 1,
-                  CLUTTER_TYPE_POINTER_A11Y_DWELL_CLICK_TYPE);
-
-  /**
-   * ClutterDeviceManager::ptr-a11y-timeout-started:
-   * @manager: the #ClutterDeviceManager that emitted the signal
-   * @device: the core pointer #ClutterInputDevice
-   * @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
-   * @delay: the delay in ms before secondary-click is triggered.
-   *
-   * The ::ptr-a11y-timeout-started signal is emitted when a
-   * pointer accessibility timeout delay is started, so that upper
-   * layers can notify the user with some visual feedback.
-   */
-  manager_signals[PTR_A11Y_TIMEOUT_STARTED] =
-    g_signal_new (I_("ptr-a11y-timeout-started"),
-                  G_TYPE_FROM_CLASS (klass),
-                  G_SIGNAL_RUN_LAST,
-                  0, NULL, NULL,
-                  _clutter_marshal_VOID__OBJECT_FLAGS_UINT,
-                  G_TYPE_NONE, 3,
-                  CLUTTER_TYPE_INPUT_DEVICE,
-                  CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
-                  G_TYPE_UINT);
-
-  /**
-   * ClutterDeviceManager::ptr-a11y-timeout-stopped:
-   * @manager: the #ClutterDeviceManager that emitted the signal
-   * @device: the core pointer #ClutterInputDevice
-   * @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
-   * @clicked: %TRUE if the timeout finished and triggered a click
-   *
-   * The ::ptr-a11y-timeout-stopped signal is emitted when a running
-   * pointer accessibility timeout delay is stopped, either because
-   * it's triggered at the end of the delay or cancelled, so that
-   * upper layers can notify the user with some visual feedback.
-   */
-  manager_signals[PTR_A11Y_TIMEOUT_STOPPED] =
-    g_signal_new (I_("ptr-a11y-timeout-stopped"),
-                  G_TYPE_FROM_CLASS (klass),
-                  G_SIGNAL_RUN_LAST,
-                  0, NULL, NULL,
-                  _clutter_marshal_VOID__OBJECT_FLAGS_BOOLEAN,
-                  G_TYPE_NONE, 3,
-                  CLUTTER_TYPE_INPUT_DEVICE,
-                  CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
-                  G_TYPE_BOOLEAN);
 }
 
 static void
@@ -562,111 +493,3 @@ _clutter_device_manager_compress_motion (ClutterDeviceManager *device_manager,
 
   manager_class->compress_motion (device_manager, event, to_discard);
 }
-
-void
-clutter_device_manager_ensure_a11y_state (ClutterDeviceManager *device_manager)
-{
-  ClutterInputDevice *core_pointer;
-
-  core_pointer = clutter_device_manager_get_core_device (device_manager,
-                                                         CLUTTER_POINTER_DEVICE);
-  if (core_pointer)
-    {
-      if (_clutter_is_input_pointer_a11y_enabled (core_pointer))
-        _clutter_input_pointer_a11y_add_device (core_pointer);
-    }
-}
-
-static gboolean
-are_pointer_a11y_settings_equal (ClutterPointerA11ySettings *a,
-                                 ClutterPointerA11ySettings *b)
-{
-  return (memcmp (a, b, sizeof (ClutterPointerA11ySettings)) == 0);
-}
-
-static void
-clutter_device_manager_enable_pointer_a11y (ClutterDeviceManager *device_manager)
-{
-  ClutterInputDevice *core_pointer;
-
-  core_pointer = clutter_device_manager_get_core_device (device_manager,
-                                                         CLUTTER_POINTER_DEVICE);
-
-  _clutter_input_pointer_a11y_add_device (core_pointer);
-}
-
-static void
-clutter_device_manager_disable_pointer_a11y (ClutterDeviceManager *device_manager)
-{
-  ClutterInputDevice *core_pointer;
-
-  core_pointer = clutter_device_manager_get_core_device (device_manager,
-                                                         CLUTTER_POINTER_DEVICE);
-
-  _clutter_input_pointer_a11y_remove_device (core_pointer);
-}
-
-/**
- * clutter_device_manager_set_pointer_a11y_settings:
- * @device_manager: a #ClutterDeviceManager
- * @settings: a pointer to a #ClutterPointerA11ySettings
- *
- * Sets the pointer accessibility settings
- **/
-void
-clutter_device_manager_set_pointer_a11y_settings (ClutterDeviceManager       *device_manager,
-                                                  ClutterPointerA11ySettings *settings)
-{
-  ClutterDeviceManagerPrivate *priv =
-    clutter_device_manager_get_instance_private (device_manager);
-
-  g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
-
-  if (are_pointer_a11y_settings_equal (&priv->pointer_a11y_settings, settings))
-    return;
-
-  if (priv->pointer_a11y_settings.controls == 0 && settings->controls != 0)
-    clutter_device_manager_enable_pointer_a11y (device_manager);
-  else if (priv->pointer_a11y_settings.controls != 0 && settings->controls == 0)
-    clutter_device_manager_disable_pointer_a11y (device_manager);
-
-  priv->pointer_a11y_settings = *settings;
-}
-
-/**
- * clutter_device_manager_get_pointer_a11y_settings:
- * @device_manager: a #ClutterDeviceManager
- * @settings: a pointer to a #ClutterPointerA11ySettings
- *
- * Gets the current pointer accessibility settings
- **/
-void
-clutter_device_manager_get_pointer_a11y_settings (ClutterDeviceManager       *device_manager,
-                                                  ClutterPointerA11ySettings *settings)
-{
-  ClutterDeviceManagerPrivate *priv =
-    clutter_device_manager_get_instance_private (device_manager);
-
-  g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
-
-  *settings = priv->pointer_a11y_settings;
-}
-
-/**
- * clutter_device_manager_set_pointer_a11y_dwell_click_type:
- * @device_manager: a #ClutterDeviceManager
- * @click_type: type of click as #ClutterPointerA11yDwellClickType
- *
- * Sets the dwell click type
- **/
-void
-clutter_device_manager_set_pointer_a11y_dwell_click_type (ClutterDeviceManager             *device_manager,
-                                                          ClutterPointerA11yDwellClickType  click_type)
-{
-  ClutterDeviceManagerPrivate *priv =
-    clutter_device_manager_get_instance_private (device_manager);
-
-  g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
-
-  priv->pointer_a11y_settings.dwell_click_type = click_type;
-}
diff --git a/clutter/clutter/clutter-device-manager.h b/clutter/clutter/clutter-device-manager.h
index 057473f4c..46b3227fb 100644
--- a/clutter/clutter/clutter-device-manager.h
+++ b/clutter/clutter/clutter-device-manager.h
@@ -51,27 +51,6 @@ typedef enum _ClutterVirtualDeviceType
   CLUTTER_VIRTUAL_DEVICE_TYPE_TOUCHSCREEN = 1 << 2,
 } ClutterVirtualDeviceType;
 
-/**
- * ClutterPointerA11ySettings:
- *
- * The #ClutterPointerA11ySettings structure contains pointer accessibility
- * settings
- *
- */
-typedef struct _ClutterPointerA11ySettings
-{
-  ClutterPointerA11yFlags controls;
-  ClutterPointerA11yDwellClickType dwell_click_type;
-  ClutterPointerA11yDwellMode dwell_mode;
-  ClutterPointerA11yDwellDirection dwell_gesture_single;
-  ClutterPointerA11yDwellDirection dwell_gesture_double;
-  ClutterPointerA11yDwellDirection dwell_gesture_drag;
-  ClutterPointerA11yDwellDirection dwell_gesture_secondary;
-  gint secondary_click_delay;
-  gint dwell_delay;
-  gint dwell_threshold;
-} ClutterPointerA11ySettings;
-
 /**
  * ClutterDeviceManagerClass:
  *
@@ -128,18 +107,6 @@ ClutterVirtualInputDevice *clutter_device_manager_create_virtual_device (Clutter
 CLUTTER_EXPORT
 ClutterVirtualDeviceType clutter_device_manager_get_supported_virtual_device_types (ClutterDeviceManager 
*device_manager);
 
-CLUTTER_EXPORT
-void clutter_device_manager_set_pointer_a11y_settings (ClutterDeviceManager       *device_manager,
-                                                       ClutterPointerA11ySettings *settings);
-
-CLUTTER_EXPORT
-void clutter_device_manager_get_pointer_a11y_settings (ClutterDeviceManager       *device_manager,
-                                                       ClutterPointerA11ySettings *settings);
-
-CLUTTER_EXPORT
-void clutter_device_manager_set_pointer_a11y_dwell_click_type (ClutterDeviceManager             
*device_manager,
-                                                               ClutterPointerA11yDwellClickType  click_type);
-
 G_END_DECLS
 
 #endif /* __CLUTTER_DEVICE_MANAGER_H__ */
diff --git a/clutter/clutter/clutter-input-pointer-a11y.c b/clutter/clutter/clutter-input-pointer-a11y.c
index e790fdad3..33af9978c 100644
--- a/clutter/clutter/clutter-input-pointer-a11y.c
+++ b/clutter/clutter/clutter-input-pointer-a11y.c
@@ -38,7 +38,7 @@ is_secondary_click_enabled (ClutterInputDevice *device)
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   return (settings.controls & CLUTTER_A11Y_SECONDARY_CLICK_ENABLED);
 }
@@ -48,7 +48,7 @@ is_dwell_click_enabled (ClutterInputDevice *device)
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   return (settings.controls & CLUTTER_A11Y_DWELL_ENABLED);
 }
@@ -58,7 +58,7 @@ get_secondary_click_delay (ClutterInputDevice *device)
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   return settings.secondary_click_delay;
 }
@@ -68,7 +68,7 @@ get_dwell_delay (ClutterInputDevice *device)
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   return settings.dwell_delay;
 }
@@ -78,7 +78,7 @@ get_dwell_threshold (ClutterInputDevice *device)
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   return settings.dwell_threshold;
 }
@@ -88,7 +88,7 @@ get_dwell_mode (ClutterInputDevice *device)
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   return settings.dwell_mode;
 }
@@ -98,7 +98,7 @@ get_dwell_click_type (ClutterInputDevice *device)
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   return settings.dwell_click_type;
 }
@@ -109,7 +109,7 @@ get_dwell_click_type_for_direction (ClutterInputDevice               *device,
 {
   ClutterPointerA11ySettings settings;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   if (direction == settings.dwell_gesture_single)
     return CLUTTER_A11Y_DWELL_CLICK_TYPE_PRIMARY;
@@ -168,7 +168,7 @@ trigger_secondary_click (gpointer data)
   device->ptr_a11y_data->secondary_click_triggered = TRUE;
   device->ptr_a11y_data->secondary_click_timer = 0;
 
-  g_signal_emit_by_name (device->device_manager,
+  g_signal_emit_by_name (device->seat,
                          "ptr-a11y-timeout-stopped",
                          device,
                          CLUTTER_A11Y_TIMEOUT_TYPE_SECONDARY_CLICK,
@@ -185,7 +185,7 @@ start_secondary_click_timeout (ClutterInputDevice *device)
   device->ptr_a11y_data->secondary_click_timer =
     clutter_threads_add_timeout (delay, trigger_secondary_click, device);
 
-  g_signal_emit_by_name (device->device_manager,
+  g_signal_emit_by_name (device->seat,
                          "ptr-a11y-timeout-started",
                          device,
                          CLUTTER_A11Y_TIMEOUT_TYPE_SECONDARY_CLICK,
@@ -200,7 +200,7 @@ stop_secondary_click_timeout (ClutterInputDevice *device)
       g_clear_handle_id (&device->ptr_a11y_data->secondary_click_timer,
                          g_source_remove);
 
-      g_signal_emit_by_name (device->device_manager,
+      g_signal_emit_by_name (device->seat,
                              "ptr-a11y-timeout-stopped",
                              device,
                              CLUTTER_A11Y_TIMEOUT_TYPE_SECONDARY_CLICK,
@@ -304,7 +304,7 @@ update_dwell_click_type (ClutterInputDevice *device)
   ClutterPointerA11ySettings settings;
   ClutterPointerA11yDwellClickType dwell_click_type;
 
-  clutter_device_manager_get_pointer_a11y_settings (device->device_manager, &settings);
+  clutter_seat_get_pointer_a11y_settings (device->seat, &settings);
 
   dwell_click_type = settings.dwell_click_type;
   switch (dwell_click_type)
@@ -329,10 +329,9 @@ update_dwell_click_type (ClutterInputDevice *device)
   if (dwell_click_type != settings.dwell_click_type)
     {
       settings.dwell_click_type = dwell_click_type;
-      clutter_device_manager_set_pointer_a11y_settings (device->device_manager,
-                                                        &settings);
+      clutter_seat_set_pointer_a11y_settings (device->seat, &settings);
 
-      g_signal_emit_by_name (device->device_manager,
+      g_signal_emit_by_name (device->seat,
                              "ptr-a11y-dwell-click-type-changed",
                              dwell_click_type);
     }
@@ -437,7 +436,7 @@ trigger_dwell_gesture (gpointer data)
   device->ptr_a11y_data->dwell_timer =
     clutter_threads_add_timeout (delay, trigger_clear_dwell_gesture, device);
 
-  g_signal_emit_by_name (device->device_manager,
+  g_signal_emit_by_name (device->seat,
                          "ptr-a11y-timeout-stopped",
                          device,
                          CLUTTER_A11Y_TIMEOUT_TYPE_GESTURE,
@@ -455,7 +454,7 @@ start_dwell_gesture_timeout (ClutterInputDevice *device)
     clutter_threads_add_timeout (delay, trigger_dwell_gesture, device);
   device->ptr_a11y_data->dwell_gesture_started = TRUE;
 
-  g_signal_emit_by_name (device->device_manager,
+  g_signal_emit_by_name (device->seat,
                          "ptr-a11y-timeout-started",
                          device,
                          CLUTTER_A11Y_TIMEOUT_TYPE_GESTURE,
@@ -469,7 +468,7 @@ trigger_dwell_click (gpointer data)
 
   device->ptr_a11y_data->dwell_timer = 0;
 
-  g_signal_emit_by_name (device->device_manager,
+  g_signal_emit_by_name (device->seat,
                          "ptr-a11y-timeout-stopped",
                          device,
                          CLUTTER_A11Y_TIMEOUT_TYPE_DWELL,
@@ -499,7 +498,7 @@ start_dwell_timeout (ClutterInputDevice *device)
   device->ptr_a11y_data->dwell_timer =
     clutter_threads_add_timeout (delay, trigger_dwell_click, device);
 
-  g_signal_emit_by_name (device->device_manager,
+  g_signal_emit_by_name (device->seat,
                          "ptr-a11y-timeout-started",
                          device,
                          CLUTTER_A11Y_TIMEOUT_TYPE_DWELL,
@@ -514,7 +513,7 @@ stop_dwell_timeout (ClutterInputDevice *device)
       g_clear_handle_id (&device->ptr_a11y_data->dwell_timer, g_source_remove);
       device->ptr_a11y_data->dwell_gesture_started = FALSE;
 
-      g_signal_emit_by_name (device->device_manager,
+      g_signal_emit_by_name (device->seat,
                              "ptr-a11y-timeout-stopped",
                              device,
                              CLUTTER_A11Y_TIMEOUT_TYPE_DWELL,
@@ -573,8 +572,7 @@ is_device_core_pointer (ClutterInputDevice *device)
 {
   ClutterInputDevice *core_pointer;
 
-  core_pointer = clutter_device_manager_get_core_device (device->device_manager,
-                                                         CLUTTER_POINTER_DEVICE);
+  core_pointer = clutter_seat_get_pointer (device->seat);
   if (core_pointer == NULL)
     return FALSE;
 
diff --git a/clutter/clutter/clutter-seat.c b/clutter/clutter/clutter-seat.c
index 1d7ab32f1..9621e0d10 100644
--- a/clutter/clutter/clutter-seat.c
+++ b/clutter/clutter/clutter-seat.c
@@ -25,6 +25,7 @@
 
 #include "clutter-backend-private.h"
 #include "clutter-input-device-tool.h"
+#include "clutter-input-pointer-a11y-private.h"
 #include "clutter-marshal.h"
 #include "clutter-private.h"
 #include "clutter-seat.h"
@@ -36,6 +37,9 @@ enum
   TOOL_CHANGED,
   KBD_A11Y_MASK_CHANGED,
   KBD_A11Y_FLAGS_CHANGED,
+  PTR_A11Y_DWELL_CLICK_TYPE_CHANGED,
+  PTR_A11Y_TIMEOUT_STARTED,
+  PTR_A11Y_TIMEOUT_STOPPED,
   N_SIGNALS,
 };
 
@@ -58,6 +62,9 @@ struct _ClutterSeatPrivate
 
   /* Keyboard a11y */
   ClutterKbdA11ySettings kbd_a11y_settings;
+
+  /* Pointer a11y */
+  ClutterPointerA11ySettings pointer_a11y_settings;
 };
 
 G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (ClutterSeat, clutter_seat, G_TYPE_OBJECT)
@@ -202,6 +209,78 @@ clutter_seat_class_init (ClutterSeatClass *klass)
                               G_TYPE_FROM_CLASS (object_class),
                               _clutter_marshal_VOID__UINT_UINTv);
 
+  /**
+   * ClutterSeat::ptr-a11y-dwell-click-type-changed:
+   * @seat: the #ClutterSeat that emitted the signal
+   * @click_type: the new #ClutterPointerA11yDwellClickType mode
+   *
+   * The ::ptr-a11y-dwell-click-type-changed signal is emitted each time
+   * the ClutterPointerA11yDwellClickType mode is changed as the result
+   * of pointer accessibility operations.
+   */
+  signals[PTR_A11Y_DWELL_CLICK_TYPE_CHANGED] =
+    g_signal_new (I_("ptr-a11y-dwell-click-type-changed"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  g_cclosure_marshal_VOID__FLAGS,
+                  G_TYPE_NONE, 1,
+                  CLUTTER_TYPE_POINTER_A11Y_DWELL_CLICK_TYPE);
+  g_signal_set_va_marshaller (signals[PTR_A11Y_DWELL_CLICK_TYPE_CHANGED],
+                              G_TYPE_FROM_CLASS (object_class),
+                              g_cclosure_marshal_VOID__FLAGSv);
+
+  /**
+   * ClutterSeat::ptr-a11y-timeout-started:
+   * @seat: the #ClutterSeat that emitted the signal
+   * @device: the core pointer #ClutterInputDevice
+   * @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
+   * @delay: the delay in ms before secondary-click is triggered.
+   *
+   * The ::ptr-a11y-timeout-started signal is emitted when a
+   * pointer accessibility timeout delay is started, so that upper
+   * layers can notify the user with some visual feedback.
+   */
+  signals[PTR_A11Y_TIMEOUT_STARTED] =
+    g_signal_new (I_("ptr-a11y-timeout-started"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  _clutter_marshal_VOID__OBJECT_FLAGS_UINT,
+                  G_TYPE_NONE, 3,
+                  CLUTTER_TYPE_INPUT_DEVICE,
+                  CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
+                  G_TYPE_UINT);
+  g_signal_set_va_marshaller (signals[PTR_A11Y_TIMEOUT_STARTED],
+                              G_TYPE_FROM_CLASS (object_class),
+                              _clutter_marshal_VOID__OBJECT_FLAGS_UINTv);
+
+  /**
+   * ClutterSeat::ptr-a11y-timeout-stopped:
+   * @seat: the #ClutterSeat that emitted the signal
+   * @device: the core pointer #ClutterInputDevice
+   * @timeout_type: the type of timeout #ClutterPointerA11yTimeoutType
+   * @clicked: %TRUE if the timeout finished and triggered a click
+   *
+   * The ::ptr-a11y-timeout-stopped signal is emitted when a running
+   * pointer accessibility timeout delay is stopped, either because
+   * it's triggered at the end of the delay or cancelled, so that
+   * upper layers can notify the user with some visual feedback.
+   */
+  signals[PTR_A11Y_TIMEOUT_STOPPED] =
+    g_signal_new (I_("ptr-a11y-timeout-stopped"),
+                  G_TYPE_FROM_CLASS (klass),
+                  G_SIGNAL_RUN_LAST,
+                  0, NULL, NULL,
+                  _clutter_marshal_VOID__OBJECT_FLAGS_BOOLEAN,
+                  G_TYPE_NONE, 3,
+                  CLUTTER_TYPE_INPUT_DEVICE,
+                  CLUTTER_TYPE_POINTER_A11Y_TIMEOUT_TYPE,
+                  G_TYPE_BOOLEAN);
+  g_signal_set_va_marshaller (signals[PTR_A11Y_TIMEOUT_STOPPED],
+                              G_TYPE_FROM_CLASS (object_class),
+                              _clutter_marshal_VOID__OBJECT_FLAGS_BOOLEANv);
+
   props[PROP_BACKEND] =
     g_param_spec_object ("backend",
                          P_("Backend"),
@@ -306,7 +385,7 @@ clutter_seat_set_kbd_a11y_settings (ClutterSeat            *seat,
 
   priv->kbd_a11y_settings = *settings;
 
-  seat_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (seat);
+  seat_class = CLUTTER_SEAT_GET_CLASS (seat);
   if (seat_class->apply_kbd_a11y_settings)
     seat_class->apply_kbd_a11y_settings (seat, settings);
 }
@@ -321,3 +400,106 @@ clutter_seat_get_kbd_a11y_settings (ClutterSeat            *seat,
 
   *settings = priv->kbd_a11y_settings;
 }
+
+void
+clutter_seat_ensure_a11y_state (ClutterSeat *seat)
+{
+  ClutterInputDevice *core_pointer;
+
+  core_pointer = clutter_seat_get_pointer (seat);
+
+  if (core_pointer)
+    {
+      if (_clutter_is_input_pointer_a11y_enabled (core_pointer))
+        _clutter_input_pointer_a11y_add_device (core_pointer);
+    }
+}
+
+static gboolean
+are_pointer_a11y_settings_equal (ClutterPointerA11ySettings *a,
+                                 ClutterPointerA11ySettings *b)
+{
+  return (memcmp (a, b, sizeof (ClutterPointerA11ySettings)) == 0);
+}
+
+static void
+clutter_seat_enable_pointer_a11y (ClutterSeat *seat)
+{
+  ClutterInputDevice *core_pointer;
+
+  core_pointer = clutter_seat_get_pointer (seat);
+
+  _clutter_input_pointer_a11y_add_device (core_pointer);
+}
+
+static void
+clutter_seat_disable_pointer_a11y (ClutterSeat *seat)
+{
+  ClutterInputDevice *core_pointer;
+
+  core_pointer = clutter_seat_get_pointer (seat);
+
+  _clutter_input_pointer_a11y_remove_device (core_pointer);
+}
+
+/**
+ * clutter_seat_set_pointer_a11y_settings:
+ * @seat: a #ClutterSeat
+ * @settings: a pointer to a #ClutterPointerA11ySettings
+ *
+ * Sets the pointer accessibility settings
+ **/
+void
+clutter_seat_set_pointer_a11y_settings (ClutterSeat                *seat,
+                                        ClutterPointerA11ySettings *settings)
+{
+  ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
+
+  g_return_if_fail (CLUTTER_IS_SEAT (seat));
+
+  if (are_pointer_a11y_settings_equal (&priv->pointer_a11y_settings, settings))
+    return;
+
+  if (priv->pointer_a11y_settings.controls == 0 && settings->controls != 0)
+    clutter_seat_enable_pointer_a11y (seat);
+  else if (priv->pointer_a11y_settings.controls != 0 && settings->controls == 0)
+    clutter_seat_disable_pointer_a11y (seat);
+
+  priv->pointer_a11y_settings = *settings;
+}
+
+/**
+ * clutter_seat_get_pointer_a11y_settings:
+ * @seat: a #ClutterSeat
+ * @settings: a pointer to a #ClutterPointerA11ySettings
+ *
+ * Gets the current pointer accessibility settings
+ **/
+void
+clutter_seat_get_pointer_a11y_settings (ClutterSeat                *seat,
+                                        ClutterPointerA11ySettings *settings)
+{
+  ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
+
+  g_return_if_fail (CLUTTER_IS_SEAT (seat));
+
+  *settings = priv->pointer_a11y_settings;
+}
+
+/**
+ * clutter_seat_set_pointer_a11y_dwell_click_type:
+ * @seat: a #ClutterSeat
+ * @click_type: type of click as #ClutterPointerA11yDwellClickType
+ *
+ * Sets the dwell click type
+ **/
+void
+clutter_seat_set_pointer_a11y_dwell_click_type (ClutterSeat                      *seat,
+                                                ClutterPointerA11yDwellClickType  click_type)
+{
+  ClutterSeatPrivate *priv = clutter_seat_get_instance_private (seat);
+
+  g_return_if_fail (CLUTTER_IS_SEAT (seat));
+
+  priv->pointer_a11y_settings.dwell_click_type = click_type;
+}
diff --git a/clutter/clutter/clutter-seat.h b/clutter/clutter/clutter-seat.h
index a2de10851..16d447eef 100644
--- a/clutter/clutter/clutter-seat.h
+++ b/clutter/clutter/clutter-seat.h
@@ -54,6 +54,27 @@ typedef struct _ClutterKbdA11ySettings
   gint mousekeys_accel_time;
 } ClutterKbdA11ySettings;
 
+/**
+ * ClutterPointerA11ySettings:
+ *
+ * The #ClutterPointerA11ySettings structure contains pointer accessibility
+ * settings
+ *
+ */
+typedef struct _ClutterPointerA11ySettings
+{
+  ClutterPointerA11yFlags controls;
+  ClutterPointerA11yDwellClickType dwell_click_type;
+  ClutterPointerA11yDwellMode dwell_mode;
+  ClutterPointerA11yDwellDirection dwell_gesture_single;
+  ClutterPointerA11yDwellDirection dwell_gesture_double;
+  ClutterPointerA11yDwellDirection dwell_gesture_drag;
+  ClutterPointerA11yDwellDirection dwell_gesture_secondary;
+  gint secondary_click_delay;
+  gint dwell_delay;
+  gint dwell_threshold;
+} ClutterPointerA11ySettings;
+
 typedef struct _ClutterSeatClass ClutterSeatClass;
 
 struct _ClutterSeatClass
@@ -99,5 +120,19 @@ void clutter_seat_set_kbd_a11y_settings (ClutterSeat            *seat,
 CLUTTER_EXPORT
 void clutter_seat_get_kbd_a11y_settings (ClutterSeat            *seat,
                                          ClutterKbdA11ySettings *settings);
+CLUTTER_EXPORT
+void clutter_seat_ensure_a11y_state     (ClutterSeat            *seat);
+
+CLUTTER_EXPORT
+void clutter_seat_set_pointer_a11y_settings (ClutterSeat                *seat,
+                                             ClutterPointerA11ySettings *settings);
+
+CLUTTER_EXPORT
+void clutter_seat_get_pointer_a11y_settings (ClutterSeat                *seat,
+                                             ClutterPointerA11ySettings *settings);
+
+CLUTTER_EXPORT
+void clutter_seat_set_pointer_a11y_dwell_click_type (ClutterSeat                      *seat,
+                                                     ClutterPointerA11yDwellClickType  click_type);
 
 #endif /* CLUTTER_SEAT_H */
diff --git a/src/backends/meta-input-settings.c b/src/backends/meta-input-settings.c
index 414ffef23..3c8c71349 100644
--- a/src/backends/meta-input-settings.c
+++ b/src/backends/meta-input-settings.c
@@ -1322,14 +1322,15 @@ load_pointer_a11y_settings (MetaInputSettings  *input_settings,
   ClutterPointerA11ySettings pointer_a11y_settings;
   ClutterInputDevice *core_pointer;
   GDesktopMouseDwellMode dwell_mode;
-
+  ClutterSeat *seat;
   guint i;
 
   core_pointer = clutter_device_manager_get_core_device (priv->device_manager, CLUTTER_POINTER_DEVICE);
   if (device && device != core_pointer)
     return;
 
-  clutter_device_manager_get_pointer_a11y_settings (priv->device_manager, &pointer_a11y_settings);
+  seat = clutter_input_device_get_seat (device);
+  clutter_seat_get_pointer_a11y_settings (seat, &pointer_a11y_settings);
   pointer_a11y_settings.controls = 0;
   for (i = 0; i < G_N_ELEMENTS (pointer_a11y_settings_flags_pair); i++)
     {
@@ -1361,7 +1362,7 @@ load_pointer_a11y_settings (MetaInputSettings  *input_settings,
   pointer_a11y_settings.dwell_gesture_secondary =
     pointer_a11y_dwell_direction_from_setting (input_settings, "dwell-gesture-secondary");
 
-  clutter_device_manager_set_pointer_a11y_settings (priv->device_manager, &pointer_a11y_settings);
+  clutter_seat_set_pointer_a11y_settings (seat, &pointer_a11y_settings);
 }
 
 static void
diff --git a/src/backends/native/meta-backend-native.c b/src/backends/native/meta-backend-native.c
index c279d0cca..6f989a79c 100644
--- a/src/backends/native/meta-backend-native.c
+++ b/src/backends/native/meta-backend-native.c
@@ -825,7 +825,6 @@ void meta_backend_native_resume (MetaBackendNative *native)
     META_MONITOR_MANAGER_KMS (monitor_manager);
   MetaInputSettings *input_settings;
   MetaIdleMonitor *idle_monitor;
-  ClutterDeviceManager *device_manager;
   ClutterBackend *clutter_backend = clutter_get_default_backend ();
   MetaSeatNative *seat =
     META_SEAT_NATIVE (clutter_backend_get_default_seat (clutter_backend));
@@ -848,6 +847,5 @@ void meta_backend_native_resume (MetaBackendNative *native)
   input_settings = meta_backend_get_input_settings (backend);
   meta_input_settings_maybe_restore_numlock_state (input_settings);
 
-  device_manager = clutter_device_manager_get_default ();
-  clutter_device_manager_ensure_a11y_state (device_manager);
+  clutter_seat_ensure_a11y_state (CLUTTER_SEAT (seat));
 }


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