backends/x11: Handle stage events from the main XEvent handler

This does not do any event translation, so does not need to be
handled through the translate_event() ClutterBackend vfunc.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
Carlos Garnacho 2023-08-02 12:36:59 +02:00
parent 830a5c0caa
commit 990a50539e
4 changed files with 14 additions and 24 deletions

View File

@ -221,14 +221,8 @@ meta_clutter_backend_x11_translate_event (ClutterBackend *clutter_backend,
META_CLUTTER_BACKEND_X11 (clutter_backend); META_CLUTTER_BACKEND_X11 (clutter_backend);
MetaClutterBackendX11Private *priv = MetaClutterBackendX11Private *priv =
meta_clutter_backend_x11_get_instance_private (clutter_backend_x11); meta_clutter_backend_x11_get_instance_private (clutter_backend_x11);
MetaStageX11 *stage_x11;
ClutterSeat *seat; ClutterSeat *seat;
stage_x11 =
META_STAGE_X11 (clutter_backend_get_stage_window (clutter_backend));
if (meta_stage_x11_translate_event (stage_x11, native, event))
return TRUE;
seat = meta_backend_get_default_seat (priv->backend); seat = meta_backend_get_default_seat (priv->backend);
if (meta_seat_x11_translate_event (META_SEAT_X11 (seat), native, event)) if (meta_seat_x11_translate_event (META_SEAT_X11 (seat), native, event))
return TRUE; return TRUE;

View File

@ -28,6 +28,7 @@
#include "backends/x11/meta-backend-x11.h" #include "backends/x11/meta-backend-x11.h"
#include "backends/x11/meta-event-x11.h" #include "backends/x11/meta-event-x11.h"
#include "backends/x11/meta-stage-x11.h"
#include "clutter/clutter-mutter.h" #include "clutter/clutter-mutter.h"
#include "cogl/cogl-xlib.h" #include "cogl/cogl-xlib.h"
@ -55,6 +56,7 @@ meta_x11_handle_event (MetaBackend *backend,
MetaX11FilterReturn result; MetaX11FilterReturn result;
ClutterBackend *clutter_backend; ClutterBackend *clutter_backend;
ClutterEvent *event; ClutterEvent *event;
MetaStageX11 *stage_x11;
gint spin = 1; gint spin = 1;
Display *xdisplay; Display *xdisplay;
gboolean allocated_event; gboolean allocated_event;
@ -85,6 +87,10 @@ meta_x11_handle_event (MetaBackend *backend,
goto out; goto out;
} }
stage_x11 =
META_STAGE_X11 (clutter_backend_get_stage_window (clutter_backend));
meta_stage_x11_handle_event (stage_x11, xevent);
if (_clutter_backend_translate_event (clutter_backend, xevent, event)) if (_clutter_backend_translate_event (clutter_backend, xevent, event))
{ {
_clutter_event_push (event, FALSE); _clutter_event_push (event, FALSE);

View File

@ -628,21 +628,19 @@ clipped_redraws_cool_off_cb (void *data)
return G_SOURCE_REMOVE; return G_SOURCE_REMOVE;
} }
gboolean void
meta_stage_x11_translate_event (MetaStageX11 *stage_x11, meta_stage_x11_handle_event (MetaStageX11 *stage_x11,
XEvent *xevent, XEvent *xevent)
ClutterEvent *event)
{ {
MetaClutterBackendX11 *clutter_backend_x11 = MetaClutterBackendX11 *clutter_backend_x11 =
clutter_backend_x11_from_stage (stage_x11); clutter_backend_x11_from_stage (stage_x11);
MetaBackend *backend; MetaBackend *backend;
MetaStageImpl *stage_impl; MetaStageImpl *stage_impl;
gboolean res = FALSE;
ClutterStage *stage; ClutterStage *stage;
stage_impl = meta_x11_get_stage_window_from_window (xevent->xany.window); stage_impl = meta_x11_get_stage_window_from_window (xevent->xany.window);
if (stage_impl == NULL) if (stage_impl == NULL)
return FALSE; return;
backend = meta_stage_impl_get_backend (stage_impl); backend = meta_stage_impl_get_backend (stage_impl);
stage = stage_impl->wrapper; stage = stage_impl->wrapper;
@ -789,10 +787,8 @@ meta_stage_x11_translate_event (MetaStageX11 *stage_x11,
g_debug ("Destroy notification received for stage, win:0x%x", g_debug ("Destroy notification received for stage, win:0x%x",
(unsigned int) xevent->xany.window); (unsigned int) xevent->xany.window);
g_return_val_if_fail (META_IS_STAGE_X11_NESTED (stage_x11), g_return_if_fail (META_IS_STAGE_X11_NESTED (stage_x11));
FALSE);
meta_context_terminate (meta_backend_get_context (backend)); meta_context_terminate (meta_backend_get_context (backend));
res = FALSE;
break; break;
case ClientMessage: case ClientMessage:
@ -803,21 +799,16 @@ meta_stage_x11_translate_event (MetaStageX11 *stage_x11,
{ {
if (handle_wm_protocols_event (stage_x11, xevent)) if (handle_wm_protocols_event (stage_x11, xevent))
{ {
g_return_val_if_fail (META_IS_STAGE_X11_NESTED (stage_x11), g_return_if_fail (META_IS_STAGE_X11_NESTED (stage_x11));
FALSE);
meta_context_terminate (meta_backend_get_context (backend)); meta_context_terminate (meta_backend_get_context (backend));
res = FALSE;
} }
} }
break; break;
default: default:
res = FALSE;
break; break;
} }
return res;
} }
Window Window

View File

@ -79,9 +79,8 @@ GType meta_stage_x11_get_type (void) G_GNUC_CONST;
void meta_stage_x11_set_user_time (MetaStageX11 *stage_x11, void meta_stage_x11_set_user_time (MetaStageX11 *stage_x11,
guint32 user_time); guint32 user_time);
gboolean meta_stage_x11_translate_event (MetaStageX11 *stage_x11, void meta_stage_x11_handle_event (MetaStageX11 *stage_x11,
XEvent *xevent, XEvent *xevent);
ClutterEvent *event);
ClutterStage *meta_x11_get_stage_from_window (Window win); ClutterStage *meta_x11_get_stage_from_window (Window win);