clutter: add hooks for kbd a11y configuration

Use a set of bitwise enum flags to set different keyboard accessibility
features and the necessary vfunc hooks in clutter input device so that
keyboard preferences can be passed to different input device
implementations.

The idea is to be able to configure either the clutter own
implementation of keyboard accessibility for evdev, or eventually
configure AccessX from the X11 clutter input device using the same
mechanism.

https://bugzilla.gnome.org/show_bug.cgi?id=788564
This commit is contained in:
Olivier Fourdan 2017-10-12 16:55:53 +02:00
parent 7d5e08c843
commit 32305b453d
3 changed files with 109 additions and 1 deletions

View File

@ -54,6 +54,9 @@ struct _ClutterDeviceManagerPrivate
{ {
/* back-pointer to the backend */ /* back-pointer to the backend */
ClutterBackend *backend; ClutterBackend *backend;
/* Keyboard a11y */
ClutterKbdA11ySettings kbd_a11y_settings;
}; };
enum enum
@ -487,3 +490,43 @@ _clutter_device_manager_compress_motion (ClutterDeviceManager *device_manager,
manager_class->compress_motion (device_manager, event, to_discard); manager_class->compress_motion (device_manager, event, to_discard);
} }
static gboolean
are_kbd_a11y_settings_equal (ClutterKbdA11ySettings *a,
ClutterKbdA11ySettings *b)
{
return (a->controls == b->controls &&
a->slowkeys_delay == b->slowkeys_delay &&
a->debounce_delay == b->debounce_delay &&
a->timeout_delay == b->timeout_delay &&
a->mousekeys_init_delay == b->mousekeys_init_delay &&
a->mousekeys_max_speed == b->mousekeys_max_speed &&
a->mousekeys_accel_time == b->mousekeys_accel_time);
}
void
clutter_device_manager_set_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings)
{
ClutterDeviceManagerClass *manager_class;
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
if (are_kbd_a11y_settings_equal (&device_manager->priv->kbd_a11y_settings, settings))
return;
device_manager->priv->kbd_a11y_settings = *settings;
manager_class = CLUTTER_DEVICE_MANAGER_GET_CLASS (device_manager);
if (manager_class->apply_kbd_a11y_settings)
manager_class->apply_kbd_a11y_settings (device_manager, settings);
}
void
clutter_device_manager_get_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings)
{
g_return_if_fail (CLUTTER_IS_DEVICE_MANAGER (device_manager));
*settings = device_manager->priv->kbd_a11y_settings;
}

View File

@ -44,6 +44,25 @@ typedef struct _ClutterDeviceManager ClutterDeviceManager;
typedef struct _ClutterDeviceManagerPrivate ClutterDeviceManagerPrivate; typedef struct _ClutterDeviceManagerPrivate ClutterDeviceManagerPrivate;
typedef struct _ClutterDeviceManagerClass ClutterDeviceManagerClass; typedef struct _ClutterDeviceManagerClass ClutterDeviceManagerClass;
/**
* ClutterKbdA11ySettings:
*
* The #ClutterKbdA11ySettings structure contains keyboard accessibility
* settings
*
*/
typedef struct _ClutterKbdA11ySettings
{
ClutterKeyboardA11yFlags controls;
gint slowkeys_delay;
gint debounce_delay;
gint timeout_delay;
gint mousekeys_init_delay;
gint mousekeys_max_speed;
gint mousekeys_accel_time;
} ClutterKbdA11ySettings;
/** /**
* ClutterDeviceManager: * ClutterDeviceManager:
* *
@ -88,7 +107,9 @@ struct _ClutterDeviceManagerClass
void (* compress_motion) (ClutterDeviceManager *device_manger, void (* compress_motion) (ClutterDeviceManager *device_manger,
ClutterEvent *event, ClutterEvent *event,
const ClutterEvent *to_discard); const ClutterEvent *to_discard);
/* Keyboard accessbility */
void (* apply_kbd_a11y_settings) (ClutterDeviceManager *device_manger,
ClutterKbdA11ySettings *settings);
/* padding */ /* padding */
gpointer _padding[6]; gpointer _padding[6];
}; };
@ -114,6 +135,13 @@ CLUTTER_AVAILABLE_IN_ALL
ClutterVirtualInputDevice *clutter_device_manager_create_virtual_device (ClutterDeviceManager *device_manager, ClutterVirtualInputDevice *clutter_device_manager_create_virtual_device (ClutterDeviceManager *device_manager,
ClutterInputDeviceType device_type); ClutterInputDeviceType device_type);
CLUTTER_AVAILABLE_IN_ALL
void clutter_device_manager_set_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings);
CLUTTER_AVAILABLE_IN_ALL
void clutter_device_manager_get_kbd_a11y_settings (ClutterDeviceManager *device_manager,
ClutterKbdA11ySettings *settings);
G_END_DECLS G_END_DECLS
#endif /* __CLUTTER_DEVICE_MANAGER_H__ */ #endif /* __CLUTTER_DEVICE_MANAGER_H__ */

View File

@ -396,6 +396,43 @@ typedef enum {
CLUTTER_MODIFIER_MASK = 0x5c001fff CLUTTER_MODIFIER_MASK = 0x5c001fff
} ClutterModifierType; } ClutterModifierType;
/**
* ClutterKeyboardA11yFlags:
* @CLUTTER_A11Y_KEYBOARD_ENABLED:
* @CLUTTER_A11Y_TIMEOUT_ENABLED:
* @CLUTTER_A11Y_MOUSE_KEYS_ENABLED:
* @CLUTTER_A11Y_SLOW_KEYS_ENABLED:
* @CLUTTER_A11Y_SLOW_KEYS_BEEP_PRESS:
* @CLUTTER_A11Y_SLOW_KEYS_BEEP_ACCEPT:
* @CLUTTER_A11Y_SLOW_KEYS_BEEP_REJECT:
* @CLUTTER_A11Y_BOUNCE_KEYS_ENABLED:
* @CLUTTER_A11Y_BOUNCE_KEYS_BEEP_REJECT:
* @CLUTTER_A11Y_TOGGLE_KEYS_ENABLED:
* @CLUTTER_A11Y_STICKY_KEYS_ENABLED:
* @CLUTTER_A11Y_STICKY_KEYS_TWO_KEY_OFF:
* @CLUTTER_A11Y_STICKY_KEYS_BEEP:
* @CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP:
*
* Keyboard accessibility features applied to a ClutterInputDevice keyboard.
*
*/
typedef enum {
CLUTTER_A11Y_KEYBOARD_ENABLED = 1 << 0,
CLUTTER_A11Y_TIMEOUT_ENABLED = 1 << 1,
CLUTTER_A11Y_MOUSE_KEYS_ENABLED = 1 << 2,
CLUTTER_A11Y_SLOW_KEYS_ENABLED = 1 << 3,
CLUTTER_A11Y_SLOW_KEYS_BEEP_PRESS = 1 << 4,
CLUTTER_A11Y_SLOW_KEYS_BEEP_ACCEPT = 1 << 5,
CLUTTER_A11Y_SLOW_KEYS_BEEP_REJECT = 1 << 6,
CLUTTER_A11Y_BOUNCE_KEYS_ENABLED = 1 << 7,
CLUTTER_A11Y_BOUNCE_KEYS_BEEP_REJECT = 1 << 8,
CLUTTER_A11Y_TOGGLE_KEYS_ENABLED = 1 << 9,
CLUTTER_A11Y_STICKY_KEYS_ENABLED = 1 << 10,
CLUTTER_A11Y_STICKY_KEYS_TWO_KEY_OFF = 1 << 11,
CLUTTER_A11Y_STICKY_KEYS_BEEP = 1 << 12,
CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP = 1 << 13,
} ClutterKeyboardA11yFlags;
/** /**
* ClutterActorFlags: * ClutterActorFlags:
* @CLUTTER_ACTOR_MAPPED: the actor will be painted (is visible, and inside * @CLUTTER_ACTOR_MAPPED: the actor will be painted (is visible, and inside