clutter: Remove event retrieval toggle

This is x11-specific API that was added back when clutter was out
of tree. Just remove it and directly do what we want.

https://gitlab.gnome.org/GNOME/mutter/merge_requests/672
This commit is contained in:
Carlos Garnacho 2019-03-29 14:35:37 +01:00 committed by Jonas Ådahl
parent d6aaef9954
commit ef93bb6471
5 changed files with 0 additions and 234 deletions

View File

@ -101,7 +101,6 @@ static const gchar *atom_names[] = {
#define N_ATOM_NAMES G_N_ELEMENTS (atom_names)
/* various flags corresponding to pre init setup calls */
static gboolean _no_xevent_retrieval = FALSE;
static gboolean clutter_enable_xinput = TRUE;
static gboolean clutter_enable_argb = FALSE;
static gboolean clutter_enable_stereo = FALSE;
@ -452,30 +451,6 @@ _clutter_backend_x11_events_init (ClutterBackend *backend)
CLUTTER_NOTE (EVENT, "initialising the event loop");
/* the event source is optional */
if (!_no_xevent_retrieval)
{
GSource *source;
source = _clutter_x11_event_source_new (backend_x11);
/* default priority for events
*
* XXX - at some point we'll have a common EventSource API that
* is created by the backend, and this code will most likely go
* into the default implementation of ClutterBackend
*/
g_source_set_priority (source, CLUTTER_PRIORITY_EVENTS);
/* attach the source to the default context, and transfer the
* ownership to the GMainContext itself
*/
g_source_attach (source, NULL);
g_source_unref (source);
backend_x11->event_source = source;
}
clutter_backend_x11_create_device_manager (backend_x11);
/* register keymap; unless we create a generic Keymap object, I'm
@ -945,58 +920,6 @@ clutter_x11_set_display (Display *xdpy)
_foreign_dpy= xdpy;
}
/**
* clutter_x11_disable_event_retrieval:
*
* Disables the internal polling of X11 events in the main loop.
*
* Libraries or applications calling this function will be responsible of
* polling all X11 events.
*
* You also must call clutter_x11_handle_event() to let Clutter process
* events and maintain its internal state.
*
* This function can only be called before calling clutter_init().
*
* Even with event handling disabled, Clutter will still select
* all the events required to maintain its internal state on the stage
* Window; compositors using Clutter and input regions to pass events
* through to application windows should not rely on an empty input
* region, and should instead clear it themselves explicitly using the
* XFixes extension.
*
* This function should not be normally used by applications.
*
* Since: 0.8
*/
void
clutter_x11_disable_event_retrieval (void)
{
if (_clutter_context_is_initialized ())
{
g_warning ("%s() can only be used before calling clutter_init()",
G_STRFUNC);
return;
}
_no_xevent_retrieval = TRUE;
}
/**
* clutter_x11_has_event_retrieval:
*
* Queries the X11 backend to check if event collection has been disabled.
*
* Return value: TRUE if event retrival has been disabled. FALSE otherwise.
*
* Since: 0.8
*/
gboolean
clutter_x11_has_event_retrieval (void)
{
return !_no_xevent_retrieval;
}
/**
* clutter_x11_get_default_screen:
*

View File

@ -82,7 +82,6 @@ struct _ClutterBackendX11
Window xwin_root;
/* event source */
GSource *event_source;
GSList *event_filters;
/* props */
@ -119,8 +118,6 @@ ClutterBackend *clutter_backend_x11_new (void);
void _clutter_backend_x11_events_init (ClutterBackend *backend);
GSource * _clutter_x11_event_source_new (ClutterBackendX11 *backend_x11);
/* Private to glx/eglx backends */
XVisualInfo * _clutter_backend_x11_get_visual_info (ClutterBackendX11 *backend_x11);

View File

@ -63,17 +63,6 @@
static Window ParentEmbedderWin = None;
#endif
typedef struct _ClutterEventSource ClutterEventSource;
struct _ClutterEventSource
{
GSource source;
ClutterBackendX11 *backend;
GPollFD event_poll_fd;
};
ClutterEventX11 *
_clutter_event_x11_new (void)
{
@ -96,49 +85,6 @@ _clutter_event_x11_free (ClutterEventX11 *event_x11)
g_slice_free (ClutterEventX11, event_x11);
}
static gboolean clutter_event_prepare (GSource *source,
gint *timeout);
static gboolean clutter_event_check (GSource *source);
static gboolean clutter_event_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data);
static GSourceFuncs event_funcs = {
clutter_event_prepare,
clutter_event_check,
clutter_event_dispatch,
NULL
};
GSource *
_clutter_x11_event_source_new (ClutterBackendX11 *backend_x11)
{
ClutterEventSource *event_source;
int connection_number;
GSource *source;
gchar *name;
connection_number = ConnectionNumber (backend_x11->xdpy);
CLUTTER_NOTE (EVENT, "Connection number: %d", connection_number);
source = g_source_new (&event_funcs, sizeof (ClutterEventSource));
event_source = (ClutterEventSource *) source;
name = g_strdup_printf ("Clutter X11 Event (connection: %d)",
connection_number);
g_source_set_name (source, name);
g_free (name);
event_source->backend = backend_x11;
event_source->event_poll_fd.fd = connection_number;
event_source->event_poll_fd.events = G_IO_IN;
g_source_add_poll (source, &event_source->event_poll_fd);
g_source_set_can_recurse (source, TRUE);
return source;
}
/**
* clutter_x11_handle_event:
* @xevent: pointer to XEvent structure
@ -147,9 +93,6 @@ _clutter_x11_event_source_new (ClutterBackendX11 *backend_x11)
* into external X11 event processing (for example, a GDK filter
* function).
*
* If clutter_x11_disable_event_retrieval() has been called, you must
* let this function process events to update Clutter's internal state.
*
* Return value: #ClutterX11FilterReturn. %CLUTTER_X11_FILTER_REMOVE
* indicates that Clutter has internally handled the event and the
* caller should do no further processing. %CLUTTER_X11_FILTER_CONTINUE
@ -230,95 +173,6 @@ out:
return result;
}
static gboolean
clutter_event_prepare (GSource *source,
gint *timeout)
{
ClutterBackendX11 *backend = ((ClutterEventSource *) source)->backend;
gboolean retval;
_clutter_threads_acquire_lock ();
*timeout = -1;
retval = (clutter_events_pending () || XPending (backend->xdpy));
_clutter_threads_release_lock ();
return retval;
}
static gboolean
clutter_event_check (GSource *source)
{
ClutterEventSource *event_source = (ClutterEventSource *) source;
ClutterBackendX11 *backend = event_source->backend;
gboolean retval;
_clutter_threads_acquire_lock ();
if (event_source->event_poll_fd.revents & G_IO_IN)
retval = (clutter_events_pending () || XPending (backend->xdpy));
else
retval = FALSE;
_clutter_threads_release_lock ();
return retval;
}
static void
events_queue (ClutterBackendX11 *backend_x11)
{
ClutterBackend *backend = CLUTTER_BACKEND (backend_x11);
Display *xdisplay = backend_x11->xdpy;
ClutterEvent *event;
XEvent xevent;
while (!clutter_events_pending () && XPending (xdisplay))
{
XNextEvent (xdisplay, &xevent);
event = clutter_event_new (CLUTTER_NOTHING);
XGetEventData (xdisplay, &xevent.xcookie);
if (_clutter_backend_translate_event (backend, &xevent, event))
_clutter_event_push (event, FALSE);
else
clutter_event_free (event);
XFreeEventData (xdisplay, &xevent.xcookie);
}
}
static gboolean
clutter_event_dispatch (GSource *source,
GSourceFunc callback,
gpointer user_data)
{
ClutterBackendX11 *backend = ((ClutterEventSource *) source)->backend;
ClutterEvent *event;
_clutter_threads_acquire_lock ();
/* Grab the event(s), translate and figure out double click.
* The push onto queue (stack) if valid.
*/
events_queue (backend);
/* Pop an event off the queue if any */
event = clutter_event_get ();
if (event != NULL)
{
/* forward the event into clutter for emission etc. */
_clutter_stage_queue_event (event->any.stage, event, FALSE);
}
_clutter_threads_release_lock ();
return TRUE;
}
/**
* clutter_x11_get_current_event_time: (skip)
*

View File

@ -120,11 +120,6 @@ void clutter_x11_remove_filter (ClutterX11FilterFunc func,
CLUTTER_EXPORT
ClutterX11FilterReturn clutter_x11_handle_event (XEvent *xevent);
CLUTTER_EXPORT
void clutter_x11_disable_event_retrieval (void);
CLUTTER_EXPORT
gboolean clutter_x11_has_event_retrieval (void);
CLUTTER_EXPORT
ClutterStage *clutter_x11_get_stage_from_window (Window win);

View File

@ -793,9 +793,6 @@ meta_backend_x11_init (MetaBackendX11 *x11)
* to hopefully call it before any other use of XLib.
*/
XInitThreads();
/* We do X11 event retrieval ourselves */
clutter_x11_disable_event_retrieval ();
}
Display *