backends: Add a11y interface methods to subscribe to key event input
This adds a pair of methods to signal an interest in receiving all key events without grabbing them, e. g. the previously expected behavior by screen readers. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/4217>
This commit is contained in:
parent
800981c40c
commit
20c9b8cf0c
@ -16,7 +16,7 @@
|
|||||||
GrabKeyboard:
|
GrabKeyboard:
|
||||||
|
|
||||||
Starts grabbing all key events. The client receives the events
|
Starts grabbing all key events. The client receives the events
|
||||||
through the KeyEvent signal as always, but the events aren't handled
|
through the KeyEvent signal, and in addition, the events aren't handled
|
||||||
normally by the compositor. This includes changes to the state
|
normally by the compositor. This includes changes to the state
|
||||||
of toggles like Caps Lock, Num Lock, and Scroll Lock.
|
of toggles like Caps Lock, Num Lock, and Scroll Lock.
|
||||||
|
|
||||||
@ -33,9 +33,36 @@
|
|||||||
|
|
||||||
After calling this method, the key grabs specified in the last call
|
After calling this method, the key grabs specified in the last call
|
||||||
to SetKeyGrabs, if any, are still in effect.
|
to SetKeyGrabs, if any, are still in effect.
|
||||||
|
Also, the client will still receive key events through the KeyEvent
|
||||||
|
signal, if it has called WatchKeyboard.
|
||||||
-->
|
-->
|
||||||
<method name="UngrabKeyboard" />
|
<method name="UngrabKeyboard" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
WatchKeyboard:
|
||||||
|
|
||||||
|
Starts watching all key events. The client receives the events
|
||||||
|
through the KeyEvent signal, but the events are still handled
|
||||||
|
normally by the compositor. This includes changes to the state
|
||||||
|
of toggles like Caps Lock, Num Lock, and Scroll Lock.
|
||||||
|
|
||||||
|
This behavior stays in effect until the same client calls
|
||||||
|
UnwatchKeyboard or closes its D-Bus connection.
|
||||||
|
-->
|
||||||
|
<method name="WatchKeyboard" />
|
||||||
|
|
||||||
|
<!--
|
||||||
|
UnwatchKeyboard:
|
||||||
|
|
||||||
|
Reverses the effect of calling WatchKeyboard. If WatchKeyboard wasn't
|
||||||
|
previously called, this method does nothing.
|
||||||
|
|
||||||
|
After calling this method, the key grabs specified in the last call
|
||||||
|
to SetKeyGrabs, if any, are still in effect,
|
||||||
|
but other key events are no longer reported to this client.
|
||||||
|
-->
|
||||||
|
<method name="UnwatchKeyboard" />
|
||||||
|
|
||||||
<!--
|
<!--
|
||||||
SetKeyGrabs:
|
SetKeyGrabs:
|
||||||
@modifiers: set of custom modifiers to grab
|
@modifiers: set of custom modifiers to grab
|
||||||
@ -43,7 +70,7 @@
|
|||||||
|
|
||||||
Sets the current key grabs for the calling client, overriding
|
Sets the current key grabs for the calling client, overriding
|
||||||
any previous call to this method. For grabbed key events, the
|
any previous call to this method. For grabbed key events, the
|
||||||
KeyEvent signal is still emitted, but normal key event handling
|
KeyEvent signal is emitted, and normal key event handling
|
||||||
is suppressed, including state changes for toggles like Caps Lock
|
is suppressed, including state changes for toggles like Caps Lock
|
||||||
and Num Lock.
|
and Num Lock.
|
||||||
|
|
||||||
|
@ -63,6 +63,7 @@ typedef struct _MetaA11yKeyGrabber
|
|||||||
char *bus_name;
|
char *bus_name;
|
||||||
guint bus_name_watcher_id;
|
guint bus_name_watcher_id;
|
||||||
gboolean grab_all;
|
gboolean grab_all;
|
||||||
|
gboolean watch_all;
|
||||||
GArray *modifiers;
|
GArray *modifiers;
|
||||||
GArray *keystrokes;
|
GArray *keystrokes;
|
||||||
} MetaA11yKeyGrabber;
|
} MetaA11yKeyGrabber;
|
||||||
@ -209,6 +210,34 @@ handle_ungrab_keyboard (MetaDBusKeyboardMonitor *skeleton,
|
|||||||
return G_DBUS_METHOD_INVOCATION_HANDLED;
|
return G_DBUS_METHOD_INVOCATION_HANDLED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_watch_keyboard (MetaDBusKeyboardMonitor *skeleton,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
MetaA11yManager *a11y_manager)
|
||||||
|
{
|
||||||
|
MetaA11yKeyGrabber *grabber;
|
||||||
|
|
||||||
|
grabber = ensure_key_grabber (a11y_manager, invocation);
|
||||||
|
grabber->watch_all = TRUE;
|
||||||
|
meta_dbus_keyboard_monitor_complete_watch_keyboard (skeleton, invocation);
|
||||||
|
|
||||||
|
return G_DBUS_METHOD_INVOCATION_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
handle_unwatch_keyboard (MetaDBusKeyboardMonitor *skeleton,
|
||||||
|
GDBusMethodInvocation *invocation,
|
||||||
|
MetaA11yManager *a11y_manager)
|
||||||
|
{
|
||||||
|
MetaA11yKeyGrabber *grabber;
|
||||||
|
|
||||||
|
grabber = ensure_key_grabber (a11y_manager, invocation);
|
||||||
|
grabber->watch_all = FALSE;
|
||||||
|
meta_dbus_keyboard_monitor_complete_unwatch_keyboard (skeleton, invocation);
|
||||||
|
|
||||||
|
return G_DBUS_METHOD_INVOCATION_HANDLED;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
handle_set_key_grabs (MetaDBusKeyboardMonitor *skeleton,
|
handle_set_key_grabs (MetaDBusKeyboardMonitor *skeleton,
|
||||||
GDBusMethodInvocation *invocation,
|
GDBusMethodInvocation *invocation,
|
||||||
@ -257,6 +286,10 @@ on_bus_acquired (GDBusConnection *connection,
|
|||||||
G_CALLBACK (handle_grab_keyboard), manager);
|
G_CALLBACK (handle_grab_keyboard), manager);
|
||||||
g_signal_connect (manager->keyboard_monitor_skeleton, "handle-ungrab-keyboard",
|
g_signal_connect (manager->keyboard_monitor_skeleton, "handle-ungrab-keyboard",
|
||||||
G_CALLBACK (handle_ungrab_keyboard), manager);
|
G_CALLBACK (handle_ungrab_keyboard), manager);
|
||||||
|
g_signal_connect (manager->keyboard_monitor_skeleton, "handle-watch-keyboard",
|
||||||
|
G_CALLBACK (handle_watch_keyboard), manager);
|
||||||
|
g_signal_connect (manager->keyboard_monitor_skeleton, "handle-unwatch-keyboard",
|
||||||
|
G_CALLBACK (handle_unwatch_keyboard), manager);
|
||||||
g_signal_connect (manager->keyboard_monitor_skeleton, "handle-set-key-grabs",
|
g_signal_connect (manager->keyboard_monitor_skeleton, "handle-set-key-grabs",
|
||||||
G_CALLBACK (handle_set_key_grabs), manager);
|
G_CALLBACK (handle_set_key_grabs), manager);
|
||||||
|
|
||||||
@ -422,6 +455,18 @@ should_grab_keypress (MetaA11yManager *a11y_manager,
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
should_watch_keypress (MetaA11yManager *a11y_manager,
|
||||||
|
MetaA11yKeyGrabber *grabber,
|
||||||
|
uint32_t keysym,
|
||||||
|
ClutterModifierType modifiers)
|
||||||
|
{
|
||||||
|
if (grabber->watch_all)
|
||||||
|
return TRUE;
|
||||||
|
|
||||||
|
return should_grab_keypress (a11y_manager, grabber, keysym, modifiers);
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_grabbed_modifier_key (MetaA11yManager *a11y_manager,
|
is_grabbed_modifier_key (MetaA11yManager *a11y_manager,
|
||||||
uint32_t keysym)
|
uint32_t keysym)
|
||||||
@ -481,7 +526,7 @@ meta_a11y_manager_notify_clients (MetaA11yManager *a11y_manager,
|
|||||||
{
|
{
|
||||||
MetaA11yKeyGrabber *grabber = l->data;
|
MetaA11yKeyGrabber *grabber = l->data;
|
||||||
|
|
||||||
if (should_grab_keypress (a11y_manager, grabber, keysym, state))
|
if (should_watch_keypress (a11y_manager, grabber, keysym, state))
|
||||||
{
|
{
|
||||||
notify_client (a11y_manager, grabber, released,
|
notify_client (a11y_manager, grabber, released,
|
||||||
state, keysym, unichar, keycode);
|
state, keysym, unichar, keycode);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user