clutter: Update all devices in a view in ClutterStage code
Avoid open-coding the process of figuring out the affected devices on view changes and repick on those, in exchange for a ClutterStage method to do this altogether. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/3696>
This commit is contained in:
parent
5220bc61b4
commit
4ab868154f
3 changed files with 40 additions and 66 deletions
|
@ -81,10 +81,6 @@ CLUTTER_EXPORT
|
|||
void _clutter_stage_maybe_setup_viewport (ClutterStage *stage,
|
||||
ClutterStageView *view);
|
||||
void clutter_stage_maybe_relayout (ClutterActor *stage);
|
||||
GSList * clutter_stage_find_updated_devices (ClutterStage *stage,
|
||||
ClutterStageView *view);
|
||||
void clutter_stage_update_devices (ClutterStage *stage,
|
||||
GSList *devices);
|
||||
void clutter_stage_finish_layout (ClutterStage *stage);
|
||||
|
||||
CLUTTER_EXPORT
|
||||
|
@ -159,4 +155,7 @@ GPtrArray * clutter_stage_get_active_gestures_array (ClutterStage *self);
|
|||
ClutterActor * clutter_stage_update_device_for_event (ClutterStage *stage,
|
||||
ClutterEvent *event);
|
||||
|
||||
void clutter_stage_update_devices_in_view (ClutterStage *stage,
|
||||
ClutterStageView *view);
|
||||
|
||||
G_END_DECLS
|
||||
|
|
|
@ -869,7 +869,6 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
|
|||
clutter_stage_view_get_instance_private (view);
|
||||
ClutterStage *stage = priv->stage;
|
||||
ClutterStageWindow *stage_window = _clutter_stage_get_window (stage);
|
||||
g_autoptr (GSList) devices = NULL;
|
||||
|
||||
if (CLUTTER_ACTOR_IN_DESTRUCTION (stage))
|
||||
return CLUTTER_FRAME_RESULT_IDLE;
|
||||
|
@ -890,9 +889,6 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
|
|||
|
||||
clutter_stage_finish_layout (stage);
|
||||
|
||||
if (priv->needs_update_devices)
|
||||
devices = clutter_stage_find_updated_devices (stage, view);
|
||||
|
||||
_clutter_stage_window_prepare_frame (stage_window, view, frame);
|
||||
clutter_stage_emit_prepare_frame (stage, view, frame);
|
||||
|
||||
|
@ -913,8 +909,11 @@ handle_frame_clock_frame (ClutterFrameClock *frame_clock,
|
|||
|
||||
_clutter_stage_window_finish_frame (stage_window, view, frame);
|
||||
|
||||
clutter_stage_update_devices (stage, devices);
|
||||
priv->needs_update_devices = FALSE;
|
||||
if (priv->needs_update_devices)
|
||||
{
|
||||
clutter_stage_update_devices_in_view (stage, view);
|
||||
priv->needs_update_devices = FALSE;
|
||||
}
|
||||
|
||||
_clutter_run_repaint_functions (CLUTTER_REPAINT_FLAGS_POST_PAINT);
|
||||
clutter_stage_after_update (stage, view, frame);
|
||||
|
|
|
@ -891,35 +891,6 @@ clutter_stage_maybe_relayout (ClutterActor *actor)
|
|||
clutter_stage_invalidate_devices (stage);
|
||||
}
|
||||
|
||||
GSList *
|
||||
clutter_stage_find_updated_devices (ClutterStage *stage,
|
||||
ClutterStageView *view)
|
||||
{
|
||||
ClutterStagePrivate *priv = clutter_stage_get_instance_private (stage);
|
||||
GSList *updating = NULL;
|
||||
GHashTableIter iter;
|
||||
gpointer value;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->pointer_devices);
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
PointerDeviceEntry *entry = value;
|
||||
ClutterStageView *pointer_view;
|
||||
|
||||
pointer_view = clutter_stage_get_view_at (stage,
|
||||
entry->coords.x,
|
||||
entry->coords.y);
|
||||
if (!pointer_view)
|
||||
continue;
|
||||
if (pointer_view != view)
|
||||
continue;
|
||||
|
||||
updating = g_slist_prepend (updating, entry->device);
|
||||
}
|
||||
|
||||
return updating;
|
||||
}
|
||||
|
||||
void
|
||||
clutter_stage_finish_layout (ClutterStage *stage)
|
||||
{
|
||||
|
@ -954,33 +925,6 @@ clutter_stage_finish_layout (ClutterStage *stage)
|
|||
g_warn_if_fail (!priv->actor_needs_immediate_relayout);
|
||||
}
|
||||
|
||||
void
|
||||
clutter_stage_update_devices (ClutterStage *stage,
|
||||
GSList *devices)
|
||||
{
|
||||
ClutterStagePrivate *priv = clutter_stage_get_instance_private (stage);
|
||||
GSList *l;
|
||||
|
||||
COGL_TRACE_BEGIN_SCOPED (ClutterStageUpdateDevices, "Clutter::Stage::update_devices()");
|
||||
|
||||
for (l = devices; l; l = l->next)
|
||||
{
|
||||
ClutterInputDevice *device = l->data;
|
||||
PointerDeviceEntry *entry = NULL;
|
||||
|
||||
entry = g_hash_table_lookup (priv->pointer_devices, device);
|
||||
g_assert (entry != NULL);
|
||||
|
||||
clutter_stage_pick_and_update_device (stage,
|
||||
device,
|
||||
NULL, NULL,
|
||||
CLUTTER_DEVICE_UPDATE_IGNORE_CACHE |
|
||||
CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
|
||||
entry->coords,
|
||||
CLUTTER_CURRENT_TIME);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
clutter_stage_real_queue_relayout (ClutterActor *self)
|
||||
{
|
||||
|
@ -4626,3 +4570,35 @@ clutter_stage_update_device_for_event (ClutterStage *stage,
|
|||
point,
|
||||
time_ms);
|
||||
}
|
||||
|
||||
void
|
||||
clutter_stage_update_devices_in_view (ClutterStage *stage,
|
||||
ClutterStageView *view)
|
||||
{
|
||||
ClutterStagePrivate *priv = clutter_stage_get_instance_private (stage);
|
||||
GHashTableIter iter;
|
||||
gpointer value;
|
||||
|
||||
g_hash_table_iter_init (&iter, priv->pointer_devices);
|
||||
while (g_hash_table_iter_next (&iter, NULL, &value))
|
||||
{
|
||||
PointerDeviceEntry *entry = value;
|
||||
ClutterStageView *pointer_view;
|
||||
|
||||
pointer_view = clutter_stage_get_view_at (stage,
|
||||
entry->coords.x,
|
||||
entry->coords.y);
|
||||
if (!pointer_view)
|
||||
continue;
|
||||
if (pointer_view != view)
|
||||
continue;
|
||||
|
||||
clutter_stage_pick_and_update_device (stage,
|
||||
entry->device,
|
||||
NULL, NULL,
|
||||
CLUTTER_DEVICE_UPDATE_IGNORE_CACHE |
|
||||
CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
|
||||
entry->coords,
|
||||
CLUTTER_CURRENT_TIME);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue