[mutter/wip/carlosg/unthrottled-wayland: 12/24] 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: 12/24] clutter: Unify picking and device updating
- Date: Fri, 27 Aug 2021 12:22:40 +0000 (UTC)
commit cde5be4b71ed9bef871ed6c539a32bbef7811f3a
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 | 69 +++++++++++++++++++--------------
3 files changed, 67 insertions(+), 55 deletions(-)
---
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 3c0c44bef1..7d6438e641 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -1194,28 +1194,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);
}
/**
@@ -1407,19 +1401,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 334d1a70fd..7308e273d9 100644
--- a/clutter/clutter/clutter-stage.c
+++ b/clutter/clutter/clutter-stage.c
@@ -179,10 +179,6 @@ static void clutter_stage_update_view_perspective (ClutterStage *stage);
static void clutter_stage_set_viewport (ClutterStage *stage,
float width,
float height);
-static ClutterActor * _clutter_stage_do_pick (ClutterStage *stage,
- float x,
- float y,
- ClutterPickMode mode);
G_DEFINE_TYPE_WITH_PRIVATE (ClutterStage, clutter_stage, CLUTTER_TYPE_ACTOR)
@@ -981,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);
}
}
@@ -3470,22 +3460,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
@@ -3659,3 +3642,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]