Revert "plugin-manager: Drop MetaPluginClass.xevent_filter"

This reverts commit 917526ee9d.

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: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3652>
This commit is contained in:
Bilal Elmoussaoui 2024-03-08 12:29:21 +01:00
parent 35335e65af
commit eb1d1883c2
5 changed files with 62 additions and 1 deletions

View File

@ -348,7 +348,9 @@ handle_host_xevent (MetaBackend *backend,
MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11); MetaBackendX11Private *priv = meta_backend_x11_get_instance_private (x11);
ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend); ClutterBackend *clutter_backend = meta_backend_get_clutter_backend (backend);
ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend); ClutterSeat *seat = clutter_backend_get_default_seat (clutter_backend);
MetaContext *context = meta_backend_get_context (backend);
gboolean bypass_clutter = FALSE; gboolean bypass_clutter = FALSE;
MetaDisplay *display;
switch (event->type) switch (event->type)
{ {
@ -363,7 +365,19 @@ handle_host_xevent (MetaBackend *backend,
XGetEventData (priv->xdisplay, &event->xcookie); 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)) if (event->type == (priv->xsync_event_base + XSyncAlarmNotify))
handle_alarm_notify (backend, (XSyncAlarmNotifyEvent *) event); handle_alarm_notify (backend, (XSyncAlarmNotifyEvent *) event);

View File

@ -26,6 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "backends/x11/meta-clutter-backend-x11.h"
#include "compositor/compositor-private.h" #include "compositor/compositor-private.h"
#include "compositor/meta-module.h" #include "compositor/meta-module.h"
#include "core/meta-inhibit-shortcuts-dialog-default-private.h" #include "core/meta-inhibit-shortcuts-dialog-default-private.h"
@ -331,6 +332,15 @@ meta_plugin_manager_filter_keybinding (MetaPluginManager *plugin_mgr,
return FALSE; 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 void
meta_plugin_manager_confirm_display_change (MetaPluginManager *plugin_mgr) meta_plugin_manager_confirm_display_change (MetaPluginManager *plugin_mgr)
{ {

View File

@ -70,6 +70,11 @@ gboolean meta_plugin_manager_switch_workspace (MetaPluginManager *mgr,
gboolean meta_plugin_manager_filter_keybinding (MetaPluginManager *mgr, gboolean meta_plugin_manager_filter_keybinding (MetaPluginManager *mgr,
MetaKeyBinding *binding); 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); void meta_plugin_manager_confirm_display_change (MetaPluginManager *mgr);
gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr, gboolean meta_plugin_manager_show_tile_preview (MetaPluginManager *mgr,

View File

@ -30,8 +30,12 @@
#include "meta/meta-plugin.h" #include "meta/meta-plugin.h"
#include <string.h> #include <string.h>
#include <X11/Xlib.h>
#include <X11/extensions/Xfixes.h>
#include <X11/extensions/shape.h>
#include "backends/meta-monitor-manager-private.h" #include "backends/meta-monitor-manager-private.h"
#include "backends/x11/meta-clutter-backend-x11.h"
#include "compositor/compositor-private.h" #include "compositor/compositor-private.h"
#include "compositor/meta-window-actor-private.h" #include "compositor/meta-window-actor-private.h"
#include "compositor/meta-plugin-manager.h" #include "compositor/meta-plugin-manager.h"
@ -67,6 +71,18 @@ meta_plugin_get_info (MetaPlugin *plugin)
return NULL; 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 void
meta_plugin_switch_workspace_completed (MetaPlugin *plugin) meta_plugin_switch_workspace_completed (MetaPlugin *plugin)
{ {

View File

@ -21,6 +21,7 @@
#pragma once #pragma once
#include <X11/extensions/Xfixes.h>
#include <gmodule.h> #include <gmodule.h>
#include "clutter/clutter.h" #include "clutter/clutter.h"
@ -51,6 +52,7 @@ typedef struct _MetaPluginInfo MetaPluginInfo;
* as if the effect terminated naturally * as if the effect terminated naturally
* @kill_switch_workspace: virtual function called when the workspace-switching * @kill_switch_workspace: virtual function called when the workspace-switching
* effect needs to be killed prematurely * effect needs to be killed prematurely
* @xevent_filter: virtual function called when handling each event
* @keybinding_filter: virtual function called when handling each keybinding * @keybinding_filter: virtual function called when handling each keybinding
* @plugin_info: virtual function that returns information about the * @plugin_info: virtual function that returns information about the
* #MetaPlugin * #MetaPlugin
@ -163,6 +165,20 @@ struct _MetaPluginClass
*/ */
void (*kill_switch_workspace) (MetaPlugin *plugin); 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: * MetaPluginClass::keybinding_filter:
* @binding: a #MetaKeyBinding * @binding: a #MetaKeyBinding