mirror of
https://github.com/brl/mutter.git
synced 2025-06-14 01:09:30 +00:00
backends: Move keyboard a11y into backends
And out of Clutter API. This is mainly set via settings, or the windowing itself, so we don't need to leak these details up our own backend. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:

committed by
Marge Bot

parent
4013bed6e4
commit
c3acaeb251
@ -24,6 +24,7 @@
|
||||
#include <math.h>
|
||||
#include <cairo-gobject.h>
|
||||
|
||||
#include "backends/meta-backend-private.h"
|
||||
#include "backends/native/meta-input-device-tool-native.h"
|
||||
#include "backends/native/meta-input-device-native.h"
|
||||
#include "backends/native/meta-seat-native.h"
|
||||
@ -238,11 +239,11 @@ clear_slow_keys (MetaInputDeviceNative *device)
|
||||
static guint
|
||||
get_slow_keys_delay (ClutterInputDevice *device)
|
||||
{
|
||||
MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device);
|
||||
ClutterKbdA11ySettings a11y_settings;
|
||||
MetaKbdA11ySettings a11y_settings;
|
||||
MetaInputSettings *input_settings;
|
||||
|
||||
clutter_seat_get_kbd_a11y_settings (CLUTTER_SEAT (device_native->seat),
|
||||
&a11y_settings);
|
||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
||||
meta_input_settings_get_kbd_a11y_settings (input_settings, &a11y_settings);
|
||||
/* Settings use int, we use uint, make sure we dont go negative */
|
||||
return MAX (0, a11y_settings.slowkeys_delay);
|
||||
}
|
||||
@ -263,7 +264,7 @@ trigger_slow_keys (gpointer data)
|
||||
device->slow_keys_list = g_list_remove (device->slow_keys_list, slow_keys_event);
|
||||
meta_input_device_native_free_pending_slow_key (slow_keys_event);
|
||||
|
||||
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_ACCEPT)
|
||||
if (device->a11y_flags & META_A11Y_SLOW_KEYS_BEEP_ACCEPT)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
|
||||
return G_SOURCE_REMOVE;
|
||||
@ -301,7 +302,7 @@ start_slow_keys (ClutterEvent *event,
|
||||
slow_keys_event);
|
||||
device->slow_keys_list = g_list_append (device->slow_keys_list, slow_keys_event);
|
||||
|
||||
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_PRESS)
|
||||
if (device->a11y_flags & META_A11Y_SLOW_KEYS_BEEP_PRESS)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
}
|
||||
|
||||
@ -321,7 +322,7 @@ stop_slow_keys (ClutterEvent *event,
|
||||
device->slow_keys_list = g_list_delete_link (device->slow_keys_list, item);
|
||||
meta_input_device_native_free_pending_slow_key (slow_keys_event);
|
||||
|
||||
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_BEEP_REJECT)
|
||||
if (device->a11y_flags & META_A11Y_SLOW_KEYS_BEEP_REJECT)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
|
||||
return;
|
||||
@ -334,11 +335,11 @@ stop_slow_keys (ClutterEvent *event,
|
||||
static guint
|
||||
get_debounce_delay (ClutterInputDevice *device)
|
||||
{
|
||||
MetaInputDeviceNative *device_native = META_INPUT_DEVICE_NATIVE (device);
|
||||
ClutterKbdA11ySettings a11y_settings;
|
||||
MetaKbdA11ySettings a11y_settings;
|
||||
MetaInputSettings *input_settings;
|
||||
|
||||
clutter_seat_get_kbd_a11y_settings (CLUTTER_SEAT (device_native->seat),
|
||||
&a11y_settings);
|
||||
input_settings = meta_backend_get_input_settings (meta_get_backend ());
|
||||
meta_input_settings_get_kbd_a11y_settings (input_settings, &a11y_settings);
|
||||
/* Settings use int, we use uint, make sure we dont go negative */
|
||||
return MAX (0, a11y_settings.debounce_delay);
|
||||
}
|
||||
@ -376,7 +377,7 @@ stop_bounce_keys (MetaInputDeviceNative *device)
|
||||
static void
|
||||
notify_bounce_keys_reject (MetaInputDeviceNative *device)
|
||||
{
|
||||
if (device->a11y_flags & CLUTTER_A11Y_BOUNCE_KEYS_BEEP_REJECT)
|
||||
if (device->a11y_flags & META_A11Y_BOUNCE_KEYS_BEEP_REJECT)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
}
|
||||
|
||||
@ -490,20 +491,20 @@ notify_stickykeys_change (MetaInputDeviceNative *device)
|
||||
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
|
||||
"kbd-a11y-flags-changed",
|
||||
device->a11y_flags,
|
||||
CLUTTER_A11Y_STICKY_KEYS_ENABLED);
|
||||
META_A11Y_STICKY_KEYS_ENABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
set_stickykeys_off (MetaInputDeviceNative *device)
|
||||
{
|
||||
device->a11y_flags &= ~CLUTTER_A11Y_STICKY_KEYS_ENABLED;
|
||||
device->a11y_flags &= ~META_A11Y_STICKY_KEYS_ENABLED;
|
||||
notify_stickykeys_change (device);
|
||||
}
|
||||
|
||||
static void
|
||||
set_stickykeys_on (MetaInputDeviceNative *device)
|
||||
{
|
||||
device->a11y_flags |= CLUTTER_A11Y_STICKY_KEYS_ENABLED;
|
||||
device->a11y_flags |= META_A11Y_STICKY_KEYS_ENABLED;
|
||||
notify_stickykeys_change (device);
|
||||
}
|
||||
|
||||
@ -518,23 +519,23 @@ clear_stickykeys_event (ClutterEvent *event,
|
||||
static void
|
||||
set_slowkeys_off (MetaInputDeviceNative *device)
|
||||
{
|
||||
device->a11y_flags &= ~CLUTTER_A11Y_SLOW_KEYS_ENABLED;
|
||||
device->a11y_flags &= ~META_A11Y_SLOW_KEYS_ENABLED;
|
||||
|
||||
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
|
||||
"kbd-a11y-flags-changed",
|
||||
device->a11y_flags,
|
||||
CLUTTER_A11Y_SLOW_KEYS_ENABLED);
|
||||
META_A11Y_SLOW_KEYS_ENABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
set_slowkeys_on (MetaInputDeviceNative *device)
|
||||
{
|
||||
device->a11y_flags |= CLUTTER_A11Y_SLOW_KEYS_ENABLED;
|
||||
device->a11y_flags |= META_A11Y_SLOW_KEYS_ENABLED;
|
||||
|
||||
g_signal_emit_by_name (CLUTTER_INPUT_DEVICE (device)->seat,
|
||||
"kbd-a11y-flags-changed",
|
||||
device->a11y_flags,
|
||||
CLUTTER_A11Y_SLOW_KEYS_ENABLED);
|
||||
META_A11Y_SLOW_KEYS_ENABLED);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -550,7 +551,7 @@ handle_stickykeys_press (ClutterEvent *event,
|
||||
return;
|
||||
|
||||
if (device->stickykeys_depressed_mask &&
|
||||
(device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_TWO_KEY_OFF))
|
||||
(device->a11y_flags & META_A11Y_STICKY_KEYS_TWO_KEY_OFF))
|
||||
{
|
||||
clear_stickykeys_event (event, device);
|
||||
return;
|
||||
@ -596,7 +597,7 @@ handle_stickykeys_release (ClutterEvent *event,
|
||||
|
||||
if (key_event_is_modifier (event))
|
||||
{
|
||||
if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_BEEP)
|
||||
if (device->a11y_flags & META_A11Y_STICKY_KEYS_BEEP)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
|
||||
return;
|
||||
@ -615,10 +616,10 @@ trigger_toggle_slowkeys (gpointer data)
|
||||
|
||||
device->toggle_slowkeys_timer = 0;
|
||||
|
||||
if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP)
|
||||
if (device->a11y_flags & META_A11Y_FEATURE_STATE_CHANGE_BEEP)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
|
||||
if (device->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_ENABLED)
|
||||
if (device->a11y_flags & META_A11Y_SLOW_KEYS_ENABLED)
|
||||
set_slowkeys_off (device);
|
||||
else
|
||||
set_slowkeys_on (device);
|
||||
@ -677,10 +678,10 @@ handle_enablekeys_release (ClutterEvent *event,
|
||||
{
|
||||
device->shift_count = 0;
|
||||
|
||||
if (device->a11y_flags & CLUTTER_A11Y_FEATURE_STATE_CHANGE_BEEP)
|
||||
if (device->a11y_flags & META_A11Y_FEATURE_STATE_CHANGE_BEEP)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
|
||||
if (device->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_ENABLED)
|
||||
if (device->a11y_flags & META_A11Y_STICKY_KEYS_ENABLED)
|
||||
set_stickykeys_off (device);
|
||||
else
|
||||
set_stickykeys_on (device);
|
||||
@ -747,8 +748,8 @@ emulate_button_click (MetaInputDeviceNative *device)
|
||||
#define MOUSEKEYS_CURVE (1.0 + (((double) 50.0) * 0.001))
|
||||
|
||||
static void
|
||||
update_mousekeys_params (MetaInputDeviceNative *device,
|
||||
ClutterKbdA11ySettings *settings)
|
||||
update_mousekeys_params (MetaInputDeviceNative *device,
|
||||
MetaKbdA11ySettings *settings)
|
||||
{
|
||||
/* Prevent us from broken settings values */
|
||||
device->mousekeys_max_speed = MAX (1, settings->mousekeys_max_speed);
|
||||
@ -1117,7 +1118,7 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
|
||||
if (event->key.flags & CLUTTER_EVENT_FLAG_INPUT_METHOD)
|
||||
goto emit_event;
|
||||
|
||||
if (device_evdev->a11y_flags & CLUTTER_A11Y_KEYBOARD_ENABLED)
|
||||
if (device_evdev->a11y_flags & META_A11Y_KEYBOARD_ENABLED)
|
||||
{
|
||||
if (event->type == CLUTTER_KEY_PRESS)
|
||||
handle_enablekeys_press (event, device_evdev);
|
||||
@ -1125,7 +1126,7 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
|
||||
handle_enablekeys_release (event, device_evdev);
|
||||
}
|
||||
|
||||
if (device_evdev->a11y_flags & CLUTTER_A11Y_MOUSE_KEYS_ENABLED)
|
||||
if (device_evdev->a11y_flags & META_A11Y_MOUSE_KEYS_ENABLED)
|
||||
{
|
||||
if (event->type == CLUTTER_KEY_PRESS &&
|
||||
handle_mousekeys_press (event, device_evdev))
|
||||
@ -1135,7 +1136,7 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
|
||||
return; /* swallow event */
|
||||
}
|
||||
|
||||
if ((device_evdev->a11y_flags & CLUTTER_A11Y_BOUNCE_KEYS_ENABLED) &&
|
||||
if ((device_evdev->a11y_flags & META_A11Y_BOUNCE_KEYS_ENABLED) &&
|
||||
(get_debounce_delay (device) != 0))
|
||||
{
|
||||
if ((event->type == CLUTTER_KEY_PRESS) && debounce_key (event, device_evdev))
|
||||
@ -1148,7 +1149,7 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
|
||||
start_bounce_keys (event, device_evdev);
|
||||
}
|
||||
|
||||
if ((device_evdev->a11y_flags & CLUTTER_A11Y_SLOW_KEYS_ENABLED) &&
|
||||
if ((device_evdev->a11y_flags & META_A11Y_SLOW_KEYS_ENABLED) &&
|
||||
(get_slow_keys_delay (device) != 0))
|
||||
{
|
||||
if (event->type == CLUTTER_KEY_PRESS)
|
||||
@ -1159,7 +1160,7 @@ meta_input_device_native_process_kbd_a11y_event (ClutterEvent *eve
|
||||
return;
|
||||
}
|
||||
|
||||
if (device_evdev->a11y_flags & CLUTTER_A11Y_STICKY_KEYS_ENABLED)
|
||||
if (device_evdev->a11y_flags & META_A11Y_STICKY_KEYS_ENABLED)
|
||||
{
|
||||
if (event->type == CLUTTER_KEY_PRESS)
|
||||
handle_stickykeys_press (event, device_evdev);
|
||||
@ -1172,34 +1173,34 @@ emit_event:
|
||||
}
|
||||
|
||||
void
|
||||
meta_input_device_native_apply_kbd_a11y_settings (MetaInputDeviceNative *device,
|
||||
ClutterKbdA11ySettings *settings)
|
||||
meta_input_device_native_apply_kbd_a11y_settings (MetaInputDeviceNative *device,
|
||||
MetaKbdA11ySettings *settings)
|
||||
{
|
||||
ClutterKeyboardA11yFlags changed_flags = (device->a11y_flags ^ settings->controls);
|
||||
MetaKeyboardA11yFlags changed_flags = (device->a11y_flags ^ settings->controls);
|
||||
|
||||
if (changed_flags & (CLUTTER_A11Y_KEYBOARD_ENABLED | CLUTTER_A11Y_SLOW_KEYS_ENABLED))
|
||||
if (changed_flags & (META_A11Y_KEYBOARD_ENABLED | META_A11Y_SLOW_KEYS_ENABLED))
|
||||
clear_slow_keys (device);
|
||||
|
||||
if (changed_flags & (CLUTTER_A11Y_KEYBOARD_ENABLED | CLUTTER_A11Y_BOUNCE_KEYS_ENABLED))
|
||||
if (changed_flags & (META_A11Y_KEYBOARD_ENABLED | META_A11Y_BOUNCE_KEYS_ENABLED))
|
||||
device->debounce_key = 0;
|
||||
|
||||
if (changed_flags & (CLUTTER_A11Y_KEYBOARD_ENABLED | CLUTTER_A11Y_STICKY_KEYS_ENABLED))
|
||||
if (changed_flags & (META_A11Y_KEYBOARD_ENABLED | META_A11Y_STICKY_KEYS_ENABLED))
|
||||
{
|
||||
device->stickykeys_depressed_mask = 0;
|
||||
update_internal_xkb_state (device, 0, 0);
|
||||
}
|
||||
|
||||
if (changed_flags & CLUTTER_A11Y_KEYBOARD_ENABLED)
|
||||
if (changed_flags & META_A11Y_KEYBOARD_ENABLED)
|
||||
{
|
||||
device->toggle_slowkeys_timer = 0;
|
||||
device->shift_count = 0;
|
||||
device->last_shift_time = 0;
|
||||
}
|
||||
|
||||
if (changed_flags & (CLUTTER_A11Y_KEYBOARD_ENABLED | CLUTTER_A11Y_MOUSE_KEYS_ENABLED))
|
||||
if (changed_flags & (META_A11Y_KEYBOARD_ENABLED | META_A11Y_MOUSE_KEYS_ENABLED))
|
||||
{
|
||||
if (settings->controls &
|
||||
(CLUTTER_A11Y_KEYBOARD_ENABLED | CLUTTER_A11Y_MOUSE_KEYS_ENABLED))
|
||||
(META_A11Y_KEYBOARD_ENABLED | META_A11Y_MOUSE_KEYS_ENABLED))
|
||||
enable_mousekeys (device);
|
||||
else
|
||||
disable_mousekeys (device);
|
||||
@ -1213,7 +1214,7 @@ meta_input_device_native_apply_kbd_a11y_settings (MetaInputDeviceNative *device
|
||||
void
|
||||
meta_input_device_native_a11y_maybe_notify_toggle_keys (MetaInputDeviceNative *device)
|
||||
{
|
||||
if (device->a11y_flags & CLUTTER_A11Y_TOGGLE_KEYS_ENABLED)
|
||||
if (device->a11y_flags & META_A11Y_TOGGLE_KEYS_ENABLED)
|
||||
meta_input_device_native_bell_notify (device);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user