backends/x11: Handle a11y changing XKB events together with other XKB events
There's no need for an XEvent filter, since this is already code close enough to MetaBackendX11 XEvent handling and always required anyways. Make the a11y configuration checks happen directly from MetaBackendX11 event handling. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
parent
0dfb5d1c31
commit
def478edc8
@ -346,6 +346,8 @@ handle_host_xevent (MetaBackend *backend,
|
|||||||
{
|
{
|
||||||
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
|
MetaBackendX11 *x11 = META_BACKEND_X11 (backend);
|
||||||
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
|
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
|
||||||
|
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
||||||
|
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
|
||||||
MetaContext *context = meta_backend_get_context (backend);
|
MetaContext *context = meta_backend_get_context (backend);
|
||||||
gboolean bypass_clutter = FALSE;
|
gboolean bypass_clutter = FALSE;
|
||||||
MetaDisplay *display;
|
MetaDisplay *display;
|
||||||
@ -408,6 +410,17 @@ handle_host_xevent (MetaBackend *backend,
|
|||||||
layout_group);
|
layout_group);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case XkbControlsNotify:
|
||||||
|
/* 'event_type' is set to zero on notifying us of updates in
|
||||||
|
* response to client requests (including our own) and non-zero
|
||||||
|
* to notify us of key/mouse events causing changes (like
|
||||||
|
* pressing shift 5 times to enable sticky keys).
|
||||||
|
*
|
||||||
|
* We only want to update our settings when it's in response to an
|
||||||
|
* explicit user input event, so require a non-zero event_type.
|
||||||
|
*/
|
||||||
|
if (xkb_ev->ctrls.event_type != 0)
|
||||||
|
meta_seat_x11_check_xkb_a11y_settings_changed (seat);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -43,8 +43,6 @@
|
|||||||
XkbAccessXFeedbackMask | \
|
XkbAccessXFeedbackMask | \
|
||||||
XkbControlsEnabledMask
|
XkbControlsEnabledMask
|
||||||
|
|
||||||
static int _xkb_event_base;
|
|
||||||
|
|
||||||
static Display *
|
static Display *
|
||||||
xdisplay_from_seat (ClutterSeat *seat)
|
xdisplay_from_seat (ClutterSeat *seat)
|
||||||
{
|
{
|
||||||
@ -86,8 +84,8 @@ set_xkb_desc_rec (Display *xdisplay,
|
|||||||
meta_clutter_x11_untrap_x_errors ();
|
meta_clutter_x11_untrap_x_errors ();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
check_settings_changed (ClutterSeat *seat)
|
meta_seat_x11_check_xkb_a11y_settings_changed (ClutterSeat *seat)
|
||||||
{
|
{
|
||||||
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
||||||
MetaBackend *backend = meta_seat_x11_get_backend (META_SEAT_X11 (seat_x11));
|
MetaBackend *backend = meta_seat_x11_get_backend (META_SEAT_X11 (seat_x11));
|
||||||
@ -145,37 +143,11 @@ check_settings_changed (ClutterSeat *seat)
|
|||||||
XkbFreeKeyboard (desc, XkbAllComponentsMask, TRUE);
|
XkbFreeKeyboard (desc, XkbAllComponentsMask, TRUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static MetaX11FilterReturn
|
|
||||||
xkb_a11y_event_filter (XEvent *xevent,
|
|
||||||
ClutterEvent *clutter_event,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
ClutterSeat *seat = CLUTTER_SEAT (data);
|
|
||||||
XkbEvent *xkbev = (XkbEvent *) xevent;
|
|
||||||
|
|
||||||
/* 'event_type' is set to zero on notifying us of updates in
|
|
||||||
* response to client requests (including our own) and non-zero
|
|
||||||
* to notify us of key/mouse events causing changes (like
|
|
||||||
* pressing shift 5 times to enable sticky keys).
|
|
||||||
*
|
|
||||||
* We only want to update out settings when it's in response to an
|
|
||||||
* explicit user input event, so require a non-zero event_type.
|
|
||||||
*/
|
|
||||||
if (xevent->xany.type == (_xkb_event_base + XkbEventCode) &&
|
|
||||||
xkbev->any.xkb_type == XkbControlsNotify && xkbev->ctrls.event_type != 0)
|
|
||||||
check_settings_changed (seat);
|
|
||||||
|
|
||||||
return META_X11_FILTER_CONTINUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
is_xkb_available (Display *xdisplay)
|
is_xkb_available (Display *xdisplay)
|
||||||
{
|
{
|
||||||
int opcode, error_base, event_base, major, minor;
|
int opcode, error_base, event_base, major, minor;
|
||||||
|
|
||||||
if (_xkb_event_base)
|
|
||||||
return TRUE;
|
|
||||||
|
|
||||||
if (!XkbQueryExtension (xdisplay,
|
if (!XkbQueryExtension (xdisplay,
|
||||||
&opcode,
|
&opcode,
|
||||||
&event_base,
|
&event_base,
|
||||||
@ -187,8 +159,6 @@ is_xkb_available (Display *xdisplay)
|
|||||||
if (!XkbUseExtension (xdisplay, &major, &minor))
|
if (!XkbUseExtension (xdisplay, &major, &minor))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
_xkb_event_base = event_base;
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -337,11 +307,6 @@ meta_seat_x11_apply_kbd_a11y_settings (ClutterSeat *seat,
|
|||||||
gboolean
|
gboolean
|
||||||
meta_seat_x11_a11y_init (ClutterSeat *seat)
|
meta_seat_x11_a11y_init (ClutterSeat *seat)
|
||||||
{
|
{
|
||||||
MetaSeatX11 *seat_x11 = META_SEAT_X11 (seat);
|
|
||||||
MetaBackend *backend = meta_seat_x11_get_backend (META_SEAT_X11 (seat_x11));
|
|
||||||
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
|
|
||||||
MetaClutterBackendX11 *clutter_backend_x11 =
|
|
||||||
META_CLUTTER_BACKEND_X11 (clutter_backend);
|
|
||||||
Display *xdisplay = xdisplay_from_seat (seat);
|
Display *xdisplay = xdisplay_from_seat (seat);
|
||||||
guint event_mask;
|
guint event_mask;
|
||||||
|
|
||||||
@ -352,9 +317,5 @@ meta_seat_x11_a11y_init (ClutterSeat *seat)
|
|||||||
|
|
||||||
XkbSelectEvents (xdisplay, XkbUseCoreKbd, event_mask, event_mask);
|
XkbSelectEvents (xdisplay, XkbUseCoreKbd, event_mask, event_mask);
|
||||||
|
|
||||||
meta_clutter_backend_x11_add_filter (clutter_backend_x11,
|
|
||||||
xkb_a11y_event_filter,
|
|
||||||
seat);
|
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -34,3 +34,5 @@ meta_seat_x11_apply_kbd_a11y_settings (ClutterSeat *seat,
|
|||||||
|
|
||||||
gboolean
|
gboolean
|
||||||
meta_seat_x11_a11y_init (ClutterSeat *seat);
|
meta_seat_x11_a11y_init (ClutterSeat *seat);
|
||||||
|
|
||||||
|
void meta_seat_x11_check_xkb_a11y_settings_changed (ClutterSeat *seat);
|
||||||
|
Loading…
Reference in New Issue
Block a user