clutter/main: Use "is display server" state to decide a11y routing

We checked if we were using the usig the X11 backend to decide when to
deal with a11y event posting - in order to make the clutter code less
windowing system dependent, make this check a check whether we're a
display server or not, in contrast to a window/compositing manager
client. This is made into a vfunc ot ClutterBackendClass, implemented by
MetaClutterBackendNative and MetaClutterBackendX11.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1364
This commit is contained in:
Jonas Ådahl 2020-07-09 09:45:07 +02:00
parent e0562f192f
commit c7429e8aad
5 changed files with 32 additions and 6 deletions

View File

@ -93,6 +93,8 @@ struct _ClutterBackendClass
ClutterSeat * (* get_default_seat) (ClutterBackend *backend);
gboolean (* is_display_server) (ClutterBackend *backend);
/* signals */
void (* resolution_changed) (ClutterBackend *backend);
void (* font_changed) (ClutterBackend *backend);
@ -142,6 +144,8 @@ void clutter_backend_set_fallback_resource_scale (ClutterBackend *backend,
float clutter_backend_get_fallback_resource_scale (ClutterBackend *backend);
gboolean clutter_backend_is_display_server (ClutterBackend *backend);
G_END_DECLS
#endif /* __CLUTTER_BACKEND_PRIVATE_H__ */

View File

@ -1038,3 +1038,9 @@ clutter_backend_get_fallback_resource_scale (ClutterBackend *backend)
{
return backend->fallback_resource_scale;
}
gboolean
clutter_backend_is_display_server (ClutterBackend *backend)
{
return CLUTTER_BACKEND_GET_CLASS (backend)->is_display_server (backend);
}

View File

@ -67,6 +67,7 @@
#include "clutter-settings-private.h"
#include "clutter-stage-manager.h"
#include "clutter-stage-private.h"
#include "clutter-backend-private.h"
#ifdef CLUTTER_WINDOWING_X11
#include "x11/clutter-backend-x11.h"
@ -1669,6 +1670,11 @@ _clutter_process_event_details (ClutterActor *stage,
ClutterEvent *event)
{
ClutterInputDevice *device = clutter_event_get_device (event);
ClutterMainContext *clutter_context;
ClutterBackend *backend;
clutter_context = _clutter_context_get_default ();
backend = clutter_context->backend;
switch (event->type)
{
@ -1765,8 +1771,7 @@ _clutter_process_event_details (ClutterActor *stage,
break;
case CLUTTER_MOTION:
#ifdef CLUTTER_WINDOWING_X11
if (!clutter_check_windowing_backend (CLUTTER_WINDOWING_X11) &&
if (clutter_backend_is_display_server (backend) &&
!(event->any.flags & CLUTTER_EVENT_FLAG_SYNTHETIC))
{
if (_clutter_is_input_pointer_a11y_enabled (device))
@ -1777,7 +1782,6 @@ _clutter_process_event_details (ClutterActor *stage,
_clutter_input_pointer_a11y_on_motion_event (device, x, y);
}
}
#endif /* CLUTTER_WINDOWING_X11 */
/* only the stage gets motion events if they are enabled */
if (!clutter_stage_get_motion_events_enabled (CLUTTER_STAGE (stage)) &&
event->any.source == NULL)
@ -1808,8 +1812,7 @@ _clutter_process_event_details (ClutterActor *stage,
G_GNUC_FALLTHROUGH;
case CLUTTER_BUTTON_PRESS:
case CLUTTER_BUTTON_RELEASE:
#ifdef CLUTTER_WINDOWING_X11
if (!clutter_check_windowing_backend (CLUTTER_WINDOWING_X11))
if (clutter_backend_is_display_server (backend))
{
if (_clutter_is_input_pointer_a11y_enabled (device) && (event->type != CLUTTER_MOTION))
{
@ -1818,7 +1821,6 @@ _clutter_process_event_details (ClutterActor *stage,
event->type == CLUTTER_BUTTON_PRESS);
}
}
#endif /* CLUTTER_WINDOWING_X11 */
case CLUTTER_SCROLL:
case CLUTTER_TOUCHPAD_PINCH:
case CLUTTER_TOUCHPAD_SWIPE:

View File

@ -119,6 +119,12 @@ meta_clutter_backend_native_get_default_seat (ClutterBackend *backend)
return CLUTTER_SEAT (backend_native->main_seat);
}
static gboolean
meta_clutter_backend_native_is_display_server (ClutterBackend *backend)
{
return TRUE;
}
static void
meta_clutter_backend_native_init (MetaClutterBackendNative *clutter_backend_nativen)
{
@ -133,6 +139,7 @@ meta_clutter_backend_native_class_init (MetaClutterBackendNativeClass *klass)
clutter_backend_class->create_stage = meta_clutter_backend_native_create_stage;
clutter_backend_class->init_events = meta_clutter_backend_native_init_events;
clutter_backend_class->get_default_seat = meta_clutter_backend_native_get_default_seat;
clutter_backend_class->is_display_server = meta_clutter_backend_native_is_display_server;
}
/**

View File

@ -138,6 +138,12 @@ meta_clutter_backend_x11_get_default_seat (ClutterBackend *backend)
return CLUTTER_SEAT (backend_x11->core_seat);
}
static gboolean
meta_clutter_backend_x11_is_display_server (ClutterBackend *backend)
{
return meta_is_wayland_compositor ();
}
static void
meta_clutter_backend_x11_init (MetaClutterBackendX11 *clutter_backend_x11)
{
@ -153,4 +159,5 @@ meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
clutter_backend_class->translate_event = meta_clutter_backend_x11_translate_event;
clutter_backend_class->init_events = meta_clutter_backend_x11_init_events;
clutter_backend_class->get_default_seat = meta_clutter_backend_x11_get_default_seat;
clutter_backend_class->is_display_server = meta_clutter_backend_x11_is_display_server;
}