[mutter/wip/carlosg/there-can-be-only-one: 22/23] backends/x11: Update MetaBackend on ClutterEvent processing




commit 6dd1f2fc479f1bcfc4dbe3b613373f064cd02199
Author: Carlos Garnacho <carlosg gnome org>
Date:   Sat Feb 5 13:12:48 2022 +0100

    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.

 src/backends/x11/meta-backend-x11.c  |  2 +-
 src/backends/x11/meta-event-x11.c    | 16 +++++++++-------
 src/backends/x11/meta-event-x11.h    |  3 ++-
 src/compositor/compositor-private.h  |  2 ++
 src/compositor/compositor.c          |  9 +++++++++
 src/compositor/meta-compositor-x11.c |  3 ++-
 6 files changed, 25 insertions(+), 10 deletions(-)
---
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 263d7d4689..fa01e3221b 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -402,7 +402,7 @@ handle_host_xevent (MetaBackend *backend,
   if (!bypass_clutter)
     {
       handle_input_event (x11, event);
-      meta_x11_handle_event (event);
+      meta_x11_handle_event (backend, event);
     }
 
   XFreeEventData (priv->xdisplay, &event->xcookie);
diff --git a/src/backends/x11/meta-event-x11.c b/src/backends/x11/meta-event-x11.c
index e6483a8156..6d5e8f9ed4 100644
--- a/src/backends/x11/meta-event-x11.c
+++ b/src/backends/x11/meta-event-x11.c
@@ -26,11 +26,13 @@
 #include <glib.h>
 #include <string.h>
 
+#include "backends/x11/meta-backend-x11.h"
 #include "backends/x11/meta-event-x11.h"
 #include "clutter/clutter-mutter.h"
 
 /**
  * meta_x11_handle_event:
+ * @backend: backend
  * @xevent: pointer to XEvent structure
  *
  * This function processes a single X event; it can be used to hook
@@ -48,13 +50,13 @@
  * Since: 0.8
  */
 MetaX11FilterReturn
-meta_x11_handle_event (XEvent *xevent)
+meta_x11_handle_event (MetaBackend *backend,
+                       XEvent      *xevent)
 {
   MetaX11FilterReturn result;
-  ClutterBackend *backend;
+  ClutterBackend *clutter_backend;
   ClutterEvent *event;
   gint spin = 1;
-  MetaClutterBackendX11 *backend_x11;
   Display *xdisplay;
   gboolean allocated_event;
 
@@ -69,16 +71,15 @@ meta_x11_handle_event (XEvent *xevent)
 
   result = META_X11_FILTER_CONTINUE;
 
-  backend = clutter_get_default_backend ();
+  clutter_backend = meta_backend_get_clutter_backend (backend);
 
   event = clutter_event_new (CLUTTER_NOTHING);
 
-  backend_x11 = META_CLUTTER_BACKEND_X11 (backend);
-  xdisplay = backend_x11->xdisplay;
+  xdisplay = meta_backend_x11_get_xdisplay (META_BACKEND_X11 (backend));
 
   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);
 
@@ -103,6 +104,7 @@ meta_x11_handle_event (XEvent *xevent)
     {
       /* forward the event into clutter for emission etc. */
       clutter_do_event (event);
+      meta_backend_update_from_event (backend, event);
       clutter_event_free (event);
       --spin;
     }
diff --git a/src/backends/x11/meta-event-x11.h b/src/backends/x11/meta-event-x11.h
index 3ddd0fd5db..f54c186a85 100644
--- a/src/backends/x11/meta-event-x11.h
+++ b/src/backends/x11/meta-event-x11.h
@@ -28,6 +28,7 @@
 
 #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 */
diff --git a/src/compositor/compositor-private.h b/src/compositor/compositor-private.h
index 2916e5e4e6..9899bd8df1 100644
--- a/src/compositor/compositor-private.h
+++ b/src/compositor/compositor-private.h
@@ -66,6 +66,8 @@ gboolean meta_compositor_is_unredirect_inhibited (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);
 
 ClutterStage * meta_compositor_get_stage (MetaCompositor *compositor);
diff --git a/src/compositor/compositor.c b/src/compositor/compositor.c
index e558d48b55..ed5fe7f040 100644
--- a/src/compositor/compositor.c
+++ b/src/compositor/compositor.c
@@ -1433,6 +1433,15 @@ meta_compositor_get_stage (MetaCompositor *compositor)
   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 *
 meta_compositor_get_top_window_actor (MetaCompositor *compositor)
 {
diff --git a/src/compositor/meta-compositor-x11.c b/src/compositor/meta-compositor-x11.c
index a16604640d..60cf005834 100644
--- a/src/compositor/meta-compositor-x11.c
+++ b/src/compositor/meta-compositor-x11.c
@@ -74,6 +74,7 @@ meta_compositor_x11_process_xevent (MetaCompositorX11 *compositor_x11,
 {
   MetaCompositor *compositor = META_COMPOSITOR (compositor_x11);
   MetaDisplay *display = meta_compositor_get_display (compositor);
+  MetaBackend *backend = meta_compositor_get_backend (compositor);
   MetaX11Display *x11_display = display->x11_display;
   int damage_event_base;
 
@@ -104,7 +105,7 @@ meta_compositor_x11_process_xevent (MetaCompositorX11 *compositor_x11,
    * stage is invisible
    */
   if (xevent->type == MapNotify)
-    meta_x11_handle_event (xevent);
+    meta_x11_handle_event (backend, xevent);
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]