backends/x11: Update MetaBackend on ClutterEvent processing

This should fix wonky handling of last used device and pointer
visibility on X11. At least does on --nested under presence of
touchscreen/tablet.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/285>
This commit is contained in:
Carlos Garnacho 2022-02-05 13:12:48 +01:00 committed by Marge Bot
parent 13330f34f3
commit a870e6b38d
6 changed files with 25 additions and 10 deletions

View File

@ -402,7 +402,7 @@ handle_host_xevent (MetaBackend *backend,
if (!bypass_clutter) if (!bypass_clutter)
{ {
handle_input_event (x11, event); handle_input_event (x11, event);
meta_x11_handle_event (event); meta_x11_handle_event (backend, event);
} }
XFreeEventData (priv->xdisplay, &event->xcookie); XFreeEventData (priv->xdisplay, &event->xcookie);

View File

@ -26,11 +26,13 @@
#include <glib.h> #include <glib.h>
#include <string.h> #include <string.h>
#include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-event-x11.h" #include "backends/x11/meta-event-x11.h"
#include "clutter/clutter-mutter.h" #include "clutter/clutter-mutter.h"
/** /**
* meta_x11_handle_event: * meta_x11_handle_event:
* @backend: backend
* @xevent: pointer to XEvent structure * @xevent: pointer to XEvent structure
* *
* This function processes a single X event; it can be used to hook * This function processes a single X event; it can be used to hook
@ -48,13 +50,13 @@
* Since: 0.8 * Since: 0.8
*/ */
MetaX11FilterReturn MetaX11FilterReturn
meta_x11_handle_event (XEvent *xevent) meta_x11_handle_event (MetaBackend *backend,
XEvent *xevent)
{ {
MetaX11FilterReturn result; MetaX11FilterReturn result;
ClutterBackend *backend; ClutterBackend *clutter_backend;
ClutterEvent *event; ClutterEvent *event;
gint spin = 1; gint spin = 1;
MetaClutterBackendX11 *backend_x11;
Display *xdisplay; Display *xdisplay;
gboolean allocated_event; gboolean allocated_event;
@ -69,16 +71,15 @@ meta_x11_handle_event (XEvent *xevent)
result = META_X11_FILTER_CONTINUE; result = META_X11_FILTER_CONTINUE;
backend = clutter_get_default_backend (); clutter_backend = meta_backend_get_clutter_backend (backend);
event = clutter_event_new (CLUTTER_NOTHING); event = clutter_event_new (CLUTTER_NOTHING);
backend_x11 = META_CLUTTER_BACKEND_X11 (backend); xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
xdisplay = backend_x11->xdisplay;
allocated_event = XGetEventData (xdisplay, &xevent->xcookie); allocated_event = XGetEventData (xdisplay, &xevent->xcookie);
if (_clutter_backend_translate_event (backend, xevent, event)) if (_clutter_backend_translate_event (clutter_backend, xevent, event))
{ {
_clutter_event_push (event, FALSE); _clutter_event_push (event, FALSE);
@ -103,6 +104,7 @@ meta_x11_handle_event (XEvent *xevent)
{ {
/* forward the event into clutter for emission etc. */ /* forward the event into clutter for emission etc. */
clutter_do_event (event); clutter_do_event (event);
meta_backend_update_from_event (backend, event);
clutter_event_free (event); clutter_event_free (event);
--spin; --spin;
} }

View File

@ -28,6 +28,7 @@
#include "backends/x11/meta-clutter-backend-x11.h" #include "backends/x11/meta-clutter-backend-x11.h"
MetaX11FilterReturn meta_x11_handle_event (XEvent *xevent); MetaX11FilterReturn meta_x11_handle_event (MetaBackend *backend,
XEvent *xevent);
#endif /* META_EVENT_X11_H */ #endif /* META_EVENT_X11_H */

View File

@ -66,6 +66,8 @@ gboolean meta_compositor_is_unredirect_inhibited (MetaCompositor *compositor);
MetaDisplay * meta_compositor_get_display (MetaCompositor *compositor); MetaDisplay * meta_compositor_get_display (MetaCompositor *compositor);
MetaBackend * meta_compositor_get_backend (MetaCompositor *compositor);
MetaWindowActor * meta_compositor_get_top_window_actor (MetaCompositor *compositor); MetaWindowActor * meta_compositor_get_top_window_actor (MetaCompositor *compositor);
ClutterStage * meta_compositor_get_stage (MetaCompositor *compositor); ClutterStage * meta_compositor_get_stage (MetaCompositor *compositor);

View File

@ -1442,6 +1442,15 @@ meta_compositor_get_stage (MetaCompositor *compositor)
return CLUTTER_STAGE (meta_backend_get_stage (priv->backend)); return CLUTTER_STAGE (meta_backend_get_stage (priv->backend));
} }
MetaBackend *
meta_compositor_get_backend (MetaCompositor *compositor)
{
MetaCompositorPrivate *priv =
meta_compositor_get_instance_private (compositor);
return priv->backend;
}
MetaWindowActor * MetaWindowActor *
meta_compositor_get_top_window_actor (MetaCompositor *compositor) meta_compositor_get_top_window_actor (MetaCompositor *compositor)
{ {

View File

@ -74,6 +74,7 @@ meta_compositor_x11_process_xevent (MetaCompositorX11 *compositor_x11,
{ {
MetaCompositor *compositor = META_COMPOSITOR (compositor_x11); MetaCompositor *compositor = META_COMPOSITOR (compositor_x11);
MetaDisplay *display = meta_compositor_get_display (compositor); MetaDisplay *display = meta_compositor_get_display (compositor);
MetaBackend *backend = meta_compositor_get_backend (compositor);
MetaX11Display *x11_display = display->x11_display; MetaX11Display *x11_display = display->x11_display;
int damage_event_base; int damage_event_base;
@ -104,7 +105,7 @@ meta_compositor_x11_process_xevent (MetaCompositorX11 *compositor_x11,
* stage is invisible * stage is invisible
*/ */
if (xevent->type == MapNotify) if (xevent->type == MapNotify)
meta_x11_handle_event (xevent); meta_x11_handle_event (backend, xevent);
} }
static void static void