From eb1d1883c22dfcbfcd95bcc924f1116a7e9af5dd Mon Sep 17 00:00:00 2001 From: Bilal Elmoussaoui Date: Fri, 8 Mar 2024 12:29:21 +0100 Subject: [PATCH] Revert "plugin-manager: Drop MetaPluginClass.xevent_filter" This reverts commit 917526ee9da8a1bdadda56ddfbc5050a34f45c4e. As it is currently used by GNOME Kiosk, until upstream figures out how to replace that code path, let us revert the commit Part-of: --- src/backends/x11/meta-backend-x11.c | 16 +++++++++++++++- src/compositor/meta-plugin-manager.c | 10 ++++++++++ src/compositor/meta-plugin-manager.h | 5 +++++ src/compositor/meta-plugin.c | 16 ++++++++++++++++ src/meta/meta-plugin.h | 16 ++++++++++++++++ 5 files changed, 62 insertions(+), 1 deletion(-) diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c index c5d2c4ec6..3b44920f6 100644 --- a/src/backends/x11/meta-backend-x11.c +++ b/src/backends/x11/meta-backend-x11.c @@ -348,7 +348,9 @@ handle_host_xevent (MetaBackend *backend, 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); gboolean bypass_clutter = FALSE; + MetaDisplay *display; switch (event->type) { @@ -363,7 +365,19 @@ handle_host_xevent (MetaBackend *backend, XGetEventData (priv->xdisplay, &event->xcookie); - bypass_clutter = meta_backend_x11_handle_host_xevent (x11, event); + display = meta_context_get_display (context); + if (display) + { + MetaCompositor *compositor = display->compositor; + MetaPluginManager *plugin_mgr = + meta_compositor_get_plugin_manager (compositor); + + if (meta_plugin_manager_xevent_filter (plugin_mgr, event)) + bypass_clutter = TRUE; + } + + bypass_clutter = (meta_backend_x11_handle_host_xevent (x11, event) || + bypass_clutter); if (event->type == (priv->xsync_event_base + XSyncAlarmNotify)) handle_alarm_notify (backend, (XSyncAlarmNotifyEvent *) event); diff --git a/src/compositor/meta-plugin-manager.c b/src/compositor/meta-plugin-manager.c index de415ce71..404ea5e5b 100644 --- a/src/compositor/meta-plugin-manager.c +++ b/src/compositor/meta-plugin-manager.c @@ -26,6 +26,7 @@ #include #include +#include "backends/x11/meta-clutter-backend-x11.h" #include "compositor/compositor-private.h" #include "compositor/meta-module.h" #include "core/meta-inhibit-shortcuts-dialog-default-private.h" @@ -331,6 +332,15 @@ meta_plugin_manager_filter_keybinding (MetaPluginManager *plugin_mgr, return FALSE; } +gboolean +meta_plugin_manager_xevent_filter (MetaPluginManager *plugin_mgr, + XEvent *xev) +{ + MetaPlugin *plugin = plugin_mgr->plugin; + + return _meta_plugin_xevent_filter (plugin, xev); +} + void meta_plugin_manager_confirm_display_change (MetaPluginManager *plugin_mgr) { diff --git a/src/compositor/meta-plugin-manager.h b/src/compositor/meta-plugin-manager.h index 04f3cc68a..3e6ed75dd 100644 --- a/src/compositor/meta-plugin-manager.h +++ b/src/compositor/meta-plugin-manager.h @@ -70,6 +70,11 @@ gboolean meta_plugin_manager_switch_workspace (MetaPluginManager *mgr, gboolean meta_plugin_manager_filter_keybinding (MetaPluginManager *mgr, MetaKeyBinding *binding); +gboolean meta_plugin_manager_xevent_filter (MetaPluginManager *mgr, + XEvent *xev); +gboolean _meta_plugin_xevent_filter (MetaPlugin *plugin, + XEvent *xev); + void meta_plugin_manager_confirm_display_change (MetaPluginManager *mgr); gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr, diff --git a/src/compositor/meta-plugin.c b/src/compositor/meta-plugin.c index c96302436..8c25563a5 100644 --- a/src/compositor/meta-plugin.c +++ b/src/compositor/meta-plugin.c @@ -30,8 +30,12 @@ #include "meta/meta-plugin.h" #include +#include +#include +#include #include "backends/meta-monitor-manager-private.h" +#include "backends/x11/meta-clutter-backend-x11.h" #include "compositor/compositor-private.h" #include "compositor/meta-window-actor-private.h" #include "compositor/meta-plugin-manager.h" @@ -67,6 +71,18 @@ meta_plugin_get_info (MetaPlugin *plugin) return NULL; } +gboolean +_meta_plugin_xevent_filter (MetaPlugin *plugin, + XEvent *xev) +{ + MetaPluginClass *klass = META_PLUGIN_GET_CLASS (plugin); + + if (klass->xevent_filter) + return klass->xevent_filter (plugin, xev); + else + return FALSE; +} + void meta_plugin_switch_workspace_completed (MetaPlugin *plugin) { diff --git a/src/meta/meta-plugin.h b/src/meta/meta-plugin.h index f63bc40c9..f522673b9 100644 --- a/src/meta/meta-plugin.h +++ b/src/meta/meta-plugin.h @@ -21,6 +21,7 @@ #pragma once +#include #include #include "clutter/clutter.h" @@ -51,6 +52,7 @@ typedef struct _MetaPluginInfo MetaPluginInfo; * as if the effect terminated naturally * @kill_switch_workspace: virtual function called when the workspace-switching * effect needs to be killed prematurely + * @xevent_filter: virtual function called when handling each event * @keybinding_filter: virtual function called when handling each keybinding * @plugin_info: virtual function that returns information about the * #MetaPlugin @@ -163,6 +165,20 @@ struct _MetaPluginClass */ void (*kill_switch_workspace) (MetaPlugin *plugin); + /** + * MetaPluginClass::xevent_filter: + * @event: (type xlib.XEvent): + * + * Virtual function called when handling each event. + * + * Returns: %TRUE if the plugin handled the event type (i.e., if the return + * value is %FALSE, there will be no subsequent call to the manager + * completed() callback, and the compositor must ensure that any appropriate + * post-effect cleanup is carried out. + */ + gboolean (*xevent_filter) (MetaPlugin *plugin, + XEvent *event); + /** * MetaPluginClass::keybinding_filter: * @binding: a #MetaKeyBinding