[mutter/wip/carlosg/unthrottled-wayland: 7/14] clutter: Unify picking and device updating
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/unthrottled-wayland: 7/14] clutter: Unify picking and device updating
- Date: Sat, 17 Jul 2021 13:44:59 +0000 (UTC)
commit b96c8a43b0e076ed949ea89639e8cb3a184768d0
Author: Carlos Garnacho <carlosg gnome org>
Date: Fri Jun 25 19:50:26 2021 +0200
clutter: Unify picking and device updating
Add a clutter_stage_pick_and_update_device() method that is the only
single entry point for updating a device position as seen by the
stage.
Also, update all callers to use it.
clutter/clutter/clutter-main.c | 41 ++++++++-------------
clutter/clutter/clutter-stage-private.h | 12 ++++++
clutter/clutter/clutter-stage.c | 65 ++++++++++++++++++++-------------
3 files changed, 67 insertions(+), 51 deletions(-)
---
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 39e1b90e4c..7a0905d382 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -1193,28 +1193,22 @@ update_device_for_event (ClutterStage *stage,
{
ClutterInputDevice *device = clutter_event_get_device (event);
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
- ClutterActor *new_actor;
+ ClutterDeviceUpdateFlags flags = CLUTTER_DEVICE_UPDATE_NONE;
graphene_point_t point;
uint32_t time_ms;
clutter_event_get_coords (event, &point.x, &point.y);
time_ms = clutter_event_get_time (event);
- new_actor =
- clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_REACTIVE,
- point.x, point.y);
+ if (emit_crossing)
+ flags |= CLUTTER_DEVICE_UPDATE_EMIT_CROSSING;
- /* Picking should never fail, but if it does, we bail out here */
- g_return_val_if_fail (new_actor != NULL, NULL);
-
- clutter_stage_update_device (stage,
- device, sequence,
- point,
- time_ms,
- new_actor,
- emit_crossing);
-
- return new_actor;
+ return clutter_stage_pick_and_update_device (stage,
+ device,
+ sequence,
+ flags,
+ point,
+ time_ms);
}
/**
@@ -1401,19 +1395,14 @@ clutter_stage_repick_device (ClutterStage *stage,
ClutterInputDevice *device)
{
graphene_point_t point;
- ClutterActor *new_actor;
clutter_stage_get_device_coords (stage, device, NULL, &point);
- new_actor =
- clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_REACTIVE,
- point.x, point.y);
-
- clutter_stage_update_device (stage,
- device, NULL,
- point,
- CLUTTER_CURRENT_TIME,
- new_actor,
- TRUE);
+ clutter_stage_pick_and_update_device (stage,
+ device,
+ NULL,
+ CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
+ point,
+ CLUTTER_CURRENT_TIME);
}
static void
diff --git a/clutter/clutter/clutter-stage-private.h b/clutter/clutter/clutter-stage-private.h
index a71b5df826..0fc4711b03 100644
--- a/clutter/clutter/clutter-stage-private.h
+++ b/clutter/clutter/clutter-stage-private.h
@@ -31,6 +31,12 @@
G_BEGIN_DECLS
+typedef enum
+{
+ CLUTTER_DEVICE_UPDATE_NONE = 0,
+ CLUTTER_DEVICE_UPDATE_EMIT_CROSSING = 1 << 0,
+} ClutterDeviceUpdateFlags;
+
/* stage */
ClutterStageWindow *_clutter_stage_get_default_window (void);
@@ -134,6 +140,12 @@ void clutter_stage_update_device_entry (ClutterStage *self,
void clutter_stage_remove_device_entry (ClutterStage *self,
ClutterInputDevice *device,
ClutterEventSequence *sequence);
+ClutterActor * clutter_stage_pick_and_update_device (ClutterStage *stage,
+ ClutterInputDevice *device,
+ ClutterEventSequence *sequence,
+ ClutterDeviceUpdateFlags flags,
+ graphene_point_t point,
+ uint32_t time_ms);
G_END_DECLS
diff --git a/clutter/clutter/clutter-stage.c b/clutter/clutter/clutter-stage.c
index 6be7dec20e..cf4023d54b 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -977,22 +977,16 @@ clutter_stage_update_devices (ClutterStage *stage,
{
ClutterInputDevice *device = l->data;
PointerDeviceEntry *entry = NULL;
- ClutterActor *new_actor;
entry = g_hash_table_lookup (priv->pointer_devices, device);
g_assert (entry != NULL);
- new_actor = _clutter_stage_do_pick (stage,
- entry->coords.x,
- entry->coords.y,
- CLUTTER_PICK_REACTIVE);
-
- clutter_stage_update_device (stage,
- device, NULL,
- entry->coords,
- CLUTTER_CURRENT_TIME,
- new_actor,
- TRUE);
+ clutter_stage_pick_and_update_device (stage,
+ device,
+ NULL,
+ CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
+ entry->coords,
+ CLUTTER_CURRENT_TIME);
}
}
@@ -3408,22 +3402,15 @@ on_device_actor_reactive_changed (ClutterActor *actor,
PointerDeviceEntry *entry)
{
ClutterStage *self = entry->stage;
- ClutterActor *new_device_actor;
g_assert (!clutter_actor_get_reactive (actor));
- new_device_actor =
- _clutter_stage_do_pick (self,
- entry->coords.x,
- entry->coords.y,
- CLUTTER_PICK_REACTIVE);
-
- clutter_stage_update_device (self,
- entry->device, entry->sequence,
- entry->coords,
- CLUTTER_CURRENT_TIME,
- new_device_actor,
- TRUE);
+ clutter_stage_pick_and_update_device (self,
+ entry->device,
+ entry->sequence,
+ CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
+ entry->coords,
+ CLUTTER_CURRENT_TIME);
}
static void
@@ -3597,3 +3584,31 @@ clutter_stage_get_device_coords (ClutterStage *stage,
if (entry && coords)
*coords = entry->coords;
}
+
+ClutterActor *
+clutter_stage_pick_and_update_device (ClutterStage *stage,
+ ClutterInputDevice *device,
+ ClutterEventSequence *sequence,
+ ClutterDeviceUpdateFlags flags,
+ graphene_point_t point,
+ uint32_t time_ms)
+{
+ ClutterActor *new_actor;
+
+ new_actor = _clutter_stage_do_pick (stage,
+ point.x,
+ point.y,
+ CLUTTER_PICK_REACTIVE);
+
+ /* Picking should never fail, but if it does, we bail out here */
+ g_return_val_if_fail (new_actor != NULL, NULL);
+
+ clutter_stage_update_device (stage,
+ device, sequence,
+ point,
+ time_ms,
+ new_actor,
+ !!(flags & CLUTTER_DEVICE_UPDATE_EMIT_CROSSING));
+
+ return new_actor;
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]