backends/x11: Call cogl xlib event handler directly when handling XEvents
We are pretty much guaranteed that the first event will be handled after the cogl renderer has been set up. We can avoid the loop through ClutterBackend vmethods and X11 event filters, and call this directly from the code that is already close to the MetaClutterBackendX11. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3153>
This commit is contained in:
parent
a08eea7f10
commit
0dfb5d1c31
@ -82,32 +82,6 @@ static gboolean clutter_enable_stereo = FALSE;
|
|||||||
static int TrappedErrorCode = 0;
|
static int TrappedErrorCode = 0;
|
||||||
static int (* old_error_handler) (Display *, XErrorEvent *);
|
static int (* old_error_handler) (Display *, XErrorEvent *);
|
||||||
|
|
||||||
static MetaX11FilterReturn
|
|
||||||
cogl_xlib_filter (XEvent *xevent,
|
|
||||||
ClutterEvent *event,
|
|
||||||
gpointer data)
|
|
||||||
{
|
|
||||||
ClutterBackend *clutter_backend = data;
|
|
||||||
MetaX11FilterReturn retval;
|
|
||||||
CoglFilterReturn ret;
|
|
||||||
|
|
||||||
ret = cogl_xlib_renderer_handle_event (clutter_backend->cogl_renderer,
|
|
||||||
xevent);
|
|
||||||
switch (ret)
|
|
||||||
{
|
|
||||||
case COGL_FILTER_REMOVE:
|
|
||||||
retval = META_X11_FILTER_REMOVE;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case COGL_FILTER_CONTINUE:
|
|
||||||
default:
|
|
||||||
retval = META_X11_FILTER_CONTINUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
return retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
meta_clutter_backend_x11_finish_init (ClutterBackend *clutter_backend,
|
meta_clutter_backend_x11_finish_init (ClutterBackend *clutter_backend,
|
||||||
GError **error)
|
GError **error)
|
||||||
@ -121,11 +95,6 @@ meta_clutter_backend_x11_finish_init (ClutterBackend *clutter_backend,
|
|||||||
|
|
||||||
clutter_backend_x11->xdisplay = meta_backend_x11_get_xdisplay (backend_x11);
|
clutter_backend_x11->xdisplay = meta_backend_x11_get_xdisplay (backend_x11);
|
||||||
|
|
||||||
/* add event filter for Cogl events */
|
|
||||||
meta_clutter_backend_x11_add_filter (clutter_backend_x11,
|
|
||||||
cogl_xlib_filter,
|
|
||||||
clutter_backend);
|
|
||||||
|
|
||||||
XInternAtoms (clutter_backend_x11->xdisplay,
|
XInternAtoms (clutter_backend_x11->xdisplay,
|
||||||
(char **) atom_names, N_ATOM_NAMES,
|
(char **) atom_names, N_ATOM_NAMES,
|
||||||
False, atoms);
|
False, atoms);
|
||||||
@ -144,18 +113,6 @@ meta_clutter_backend_x11_finish_init (ClutterBackend *clutter_backend,
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
meta_clutter_backend_x11_finalize (GObject *gobject)
|
|
||||||
{
|
|
||||||
MetaClutterBackendX11 *clutter_backend_x11 = META_CLUTTER_BACKEND_X11 (gobject);
|
|
||||||
|
|
||||||
meta_clutter_backend_x11_remove_filter (clutter_backend_x11,
|
|
||||||
cogl_xlib_filter,
|
|
||||||
clutter_backend_x11);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (meta_clutter_backend_x11_parent_class)->finalize (gobject);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
update_last_event_time (MetaClutterBackendX11 *clutter_backend_x11,
|
update_last_event_time (MetaClutterBackendX11 *clutter_backend_x11,
|
||||||
XEvent *xevent)
|
XEvent *xevent)
|
||||||
@ -406,11 +363,8 @@ meta_clutter_backend_x11_init (MetaClutterBackendX11 *clutter_backend_x11)
|
|||||||
static void
|
static void
|
||||||
meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
|
meta_clutter_backend_x11_class_init (MetaClutterBackendX11Class *klass)
|
||||||
{
|
{
|
||||||
GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
|
|
||||||
ClutterBackendClass *clutter_backend_class = CLUTTER_BACKEND_CLASS (klass);
|
ClutterBackendClass *clutter_backend_class = CLUTTER_BACKEND_CLASS (klass);
|
||||||
|
|
||||||
gobject_class->finalize = meta_clutter_backend_x11_finalize;
|
|
||||||
|
|
||||||
clutter_backend_class->finish_init = meta_clutter_backend_x11_finish_init;
|
clutter_backend_class->finish_init = meta_clutter_backend_x11_finish_init;
|
||||||
|
|
||||||
clutter_backend_class->get_display = meta_clutter_backend_x11_get_display;
|
clutter_backend_class->get_display = meta_clutter_backend_x11_get_display;
|
||||||
|
@ -29,6 +29,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 "clutter/clutter-mutter.h"
|
#include "clutter/clutter-mutter.h"
|
||||||
|
#include "cogl/cogl-xlib.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* meta_x11_handle_event:
|
* meta_x11_handle_event:
|
||||||
@ -77,6 +78,13 @@ meta_x11_handle_event (MetaBackend *backend,
|
|||||||
|
|
||||||
allocated_event = XGetEventData (xdisplay, &xevent->xcookie);
|
allocated_event = XGetEventData (xdisplay, &xevent->xcookie);
|
||||||
|
|
||||||
|
if (cogl_xlib_renderer_handle_event (clutter_backend->cogl_renderer,
|
||||||
|
xevent) == COGL_FILTER_REMOVE)
|
||||||
|
{
|
||||||
|
clutter_event_free (event);
|
||||||
|
goto out;
|
||||||
|
}
|
||||||
|
|
||||||
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);
|
||||||
|
Loading…
Reference in New Issue
Block a user