mirror of
https://github.com/brl/mutter.git
synced 2024-11-22 08:00:42 -05:00
clutter: Switch to GAsyncQueue for ClutterMainContext event queue
We will be moving to having events produced in one thread and consumed in another. Make this an async event queue in preparation for that. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403>
This commit is contained in:
parent
1609d1459e
commit
b789d38f68
@ -1445,14 +1445,11 @@ ClutterEvent *
|
|||||||
clutter_event_get (void)
|
clutter_event_get (void)
|
||||||
{
|
{
|
||||||
ClutterMainContext *context = _clutter_context_get_default ();
|
ClutterMainContext *context = _clutter_context_get_default ();
|
||||||
|
ClutterEvent *event;
|
||||||
|
|
||||||
if (context->events_queue == NULL)
|
event = g_async_queue_try_pop (context->events_queue);
|
||||||
return NULL;
|
|
||||||
|
|
||||||
if (g_queue_is_empty (context->events_queue))
|
return event;
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return g_queue_pop_tail (context->events_queue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
@ -1463,9 +1460,6 @@ _clutter_event_push (const ClutterEvent *event,
|
|||||||
|
|
||||||
g_assert (context != NULL);
|
g_assert (context != NULL);
|
||||||
|
|
||||||
if (context->events_queue == NULL)
|
|
||||||
context->events_queue = g_queue_new ();
|
|
||||||
|
|
||||||
if (do_copy)
|
if (do_copy)
|
||||||
{
|
{
|
||||||
ClutterEvent *copy;
|
ClutterEvent *copy;
|
||||||
@ -1474,7 +1468,8 @@ _clutter_event_push (const ClutterEvent *event,
|
|||||||
event = copy;
|
event = copy;
|
||||||
}
|
}
|
||||||
|
|
||||||
g_queue_push_head (context->events_queue, (gpointer) event);
|
g_async_queue_push (context->events_queue, (gpointer) event);
|
||||||
|
g_main_context_wakeup (NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1511,10 +1506,7 @@ clutter_events_pending (void)
|
|||||||
|
|
||||||
g_return_val_if_fail (context != NULL, FALSE);
|
g_return_val_if_fail (context != NULL, FALSE);
|
||||||
|
|
||||||
if (context->events_queue == NULL)
|
return g_async_queue_length (context->events_queue) > 0;
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
return g_queue_is_empty (context->events_queue) == FALSE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -697,6 +697,8 @@ _clutter_context_get_default (void)
|
|||||||
ctx->settings = clutter_settings_get_default ();
|
ctx->settings = clutter_settings_get_default ();
|
||||||
_clutter_settings_set_backend (ctx->settings, ctx->backend);
|
_clutter_settings_set_backend (ctx->settings, ctx->backend);
|
||||||
|
|
||||||
|
ctx->events_queue = g_async_queue_new ();
|
||||||
|
|
||||||
ctx->last_repaint_id = 1;
|
ctx->last_repaint_id = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2286,15 +2288,22 @@ void
|
|||||||
_clutter_clear_events_queue (void)
|
_clutter_clear_events_queue (void)
|
||||||
{
|
{
|
||||||
ClutterMainContext *context = _clutter_context_get_default ();
|
ClutterMainContext *context = _clutter_context_get_default ();
|
||||||
|
ClutterEvent *event;
|
||||||
|
GAsyncQueue *events_queue;
|
||||||
|
|
||||||
if (context->events_queue != NULL)
|
if (!context->events_queue)
|
||||||
{
|
return;
|
||||||
g_queue_foreach (context->events_queue,
|
|
||||||
(GFunc) clutter_event_free,
|
g_async_queue_lock (context->events_queue);
|
||||||
NULL);
|
|
||||||
g_queue_free (context->events_queue);
|
while ((event = g_async_queue_try_pop_unlocked (context->events_queue)))
|
||||||
|
clutter_event_free (event);
|
||||||
|
|
||||||
|
events_queue = context->events_queue;
|
||||||
context->events_queue = NULL;
|
context->events_queue = NULL;
|
||||||
}
|
|
||||||
|
g_async_queue_unlock (events_queue);
|
||||||
|
g_async_queue_unref (events_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -121,7 +121,7 @@ struct _ClutterMainContext
|
|||||||
ClutterStageManager *stage_manager;
|
ClutterStageManager *stage_manager;
|
||||||
|
|
||||||
/* the main event queue */
|
/* the main event queue */
|
||||||
GQueue *events_queue;
|
GAsyncQueue *events_queue;
|
||||||
|
|
||||||
/* the event filters added via clutter_event_add_filter. these are
|
/* the event filters added via clutter_event_add_filter. these are
|
||||||
* ordered from least recently added to most recently added */
|
* ordered from least recently added to most recently added */
|
||||||
|
Loading…
Reference in New Issue
Block a user