mirror of
https://github.com/brl/mutter.git
synced 2024-12-26 12:52:14 +00:00
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. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1915>
This commit is contained in:
parent
6aea319c5c
commit
340acb3fdf
@ -768,28 +768,22 @@ update_device_for_event (ClutterStage *stage,
|
|||||||
{
|
{
|
||||||
ClutterInputDevice *device = clutter_event_get_device (event);
|
ClutterInputDevice *device = clutter_event_get_device (event);
|
||||||
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
||||||
ClutterActor *new_actor;
|
ClutterDeviceUpdateFlags flags = CLUTTER_DEVICE_UPDATE_NONE;
|
||||||
graphene_point_t point;
|
graphene_point_t point;
|
||||||
uint32_t time_ms;
|
uint32_t time_ms;
|
||||||
|
|
||||||
clutter_event_get_coords (event, &point.x, &point.y);
|
clutter_event_get_coords (event, &point.x, &point.y);
|
||||||
time_ms = clutter_event_get_time (event);
|
time_ms = clutter_event_get_time (event);
|
||||||
|
|
||||||
new_actor =
|
if (emit_crossing)
|
||||||
clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_REACTIVE,
|
flags |= CLUTTER_DEVICE_UPDATE_EMIT_CROSSING;
|
||||||
point.x, point.y);
|
|
||||||
|
|
||||||
/* Picking should never fail, but if it does, we bail out here */
|
return clutter_stage_pick_and_update_device (stage,
|
||||||
g_return_val_if_fail (new_actor != NULL, NULL);
|
device,
|
||||||
|
sequence,
|
||||||
clutter_stage_update_device (stage,
|
flags,
|
||||||
device, sequence,
|
point,
|
||||||
point,
|
time_ms);
|
||||||
time_ms,
|
|
||||||
new_actor,
|
|
||||||
emit_crossing);
|
|
||||||
|
|
||||||
return new_actor;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -982,19 +976,14 @@ clutter_stage_repick_device (ClutterStage *stage,
|
|||||||
ClutterInputDevice *device)
|
ClutterInputDevice *device)
|
||||||
{
|
{
|
||||||
graphene_point_t point;
|
graphene_point_t point;
|
||||||
ClutterActor *new_actor;
|
|
||||||
|
|
||||||
clutter_stage_get_device_coords (stage, device, NULL, &point);
|
clutter_stage_get_device_coords (stage, device, NULL, &point);
|
||||||
new_actor =
|
clutter_stage_pick_and_update_device (stage,
|
||||||
clutter_stage_get_actor_at_pos (stage, CLUTTER_PICK_REACTIVE,
|
device,
|
||||||
point.x, point.y);
|
NULL,
|
||||||
|
CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
|
||||||
clutter_stage_update_device (stage,
|
point,
|
||||||
device, NULL,
|
CLUTTER_CURRENT_TIME);
|
||||||
point,
|
|
||||||
CLUTTER_CURRENT_TIME,
|
|
||||||
new_actor,
|
|
||||||
TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -31,6 +31,12 @@
|
|||||||
|
|
||||||
G_BEGIN_DECLS
|
G_BEGIN_DECLS
|
||||||
|
|
||||||
|
typedef enum
|
||||||
|
{
|
||||||
|
CLUTTER_DEVICE_UPDATE_NONE = 0,
|
||||||
|
CLUTTER_DEVICE_UPDATE_EMIT_CROSSING = 1 << 0,
|
||||||
|
} ClutterDeviceUpdateFlags;
|
||||||
|
|
||||||
/* stage */
|
/* stage */
|
||||||
ClutterStageWindow *_clutter_stage_get_default_window (void);
|
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,
|
void clutter_stage_remove_device_entry (ClutterStage *self,
|
||||||
ClutterInputDevice *device,
|
ClutterInputDevice *device,
|
||||||
ClutterEventSequence *sequence);
|
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
|
G_END_DECLS
|
||||||
|
|
||||||
|
@ -170,10 +170,6 @@ static void clutter_stage_update_view_perspective (ClutterStage *stage);
|
|||||||
static void clutter_stage_set_viewport (ClutterStage *stage,
|
static void clutter_stage_set_viewport (ClutterStage *stage,
|
||||||
float width,
|
float width,
|
||||||
float height);
|
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)
|
G_DEFINE_TYPE_WITH_PRIVATE (ClutterStage, clutter_stage, CLUTTER_TYPE_ACTOR)
|
||||||
|
|
||||||
@ -914,22 +910,16 @@ clutter_stage_update_devices (ClutterStage *stage,
|
|||||||
{
|
{
|
||||||
ClutterInputDevice *device = l->data;
|
ClutterInputDevice *device = l->data;
|
||||||
PointerDeviceEntry *entry = NULL;
|
PointerDeviceEntry *entry = NULL;
|
||||||
ClutterActor *new_actor;
|
|
||||||
|
|
||||||
entry = g_hash_table_lookup (priv->pointer_devices, device);
|
entry = g_hash_table_lookup (priv->pointer_devices, device);
|
||||||
g_assert (entry != NULL);
|
g_assert (entry != NULL);
|
||||||
|
|
||||||
new_actor = _clutter_stage_do_pick (stage,
|
clutter_stage_pick_and_update_device (stage,
|
||||||
entry->coords.x,
|
device,
|
||||||
entry->coords.y,
|
NULL,
|
||||||
CLUTTER_PICK_REACTIVE);
|
CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
|
||||||
|
entry->coords,
|
||||||
clutter_stage_update_device (stage,
|
CLUTTER_CURRENT_TIME);
|
||||||
device, NULL,
|
|
||||||
entry->coords,
|
|
||||||
CLUTTER_CURRENT_TIME,
|
|
||||||
new_actor,
|
|
||||||
TRUE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3256,22 +3246,15 @@ on_device_actor_reactive_changed (ClutterActor *actor,
|
|||||||
PointerDeviceEntry *entry)
|
PointerDeviceEntry *entry)
|
||||||
{
|
{
|
||||||
ClutterStage *self = entry->stage;
|
ClutterStage *self = entry->stage;
|
||||||
ClutterActor *new_device_actor;
|
|
||||||
|
|
||||||
g_assert (!clutter_actor_get_reactive (actor));
|
g_assert (!clutter_actor_get_reactive (actor));
|
||||||
|
|
||||||
new_device_actor =
|
clutter_stage_pick_and_update_device (self,
|
||||||
_clutter_stage_do_pick (self,
|
entry->device,
|
||||||
entry->coords.x,
|
entry->sequence,
|
||||||
entry->coords.y,
|
CLUTTER_DEVICE_UPDATE_EMIT_CROSSING,
|
||||||
CLUTTER_PICK_REACTIVE);
|
entry->coords,
|
||||||
|
CLUTTER_CURRENT_TIME);
|
||||||
clutter_stage_update_device (self,
|
|
||||||
entry->device, entry->sequence,
|
|
||||||
entry->coords,
|
|
||||||
CLUTTER_CURRENT_TIME,
|
|
||||||
new_device_actor,
|
|
||||||
TRUE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -3445,3 +3428,31 @@ clutter_stage_get_device_coords (ClutterStage *stage,
|
|||||||
if (entry && coords)
|
if (entry && coords)
|
||||||
*coords = 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;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user