clutter/input-device: Make clutter_input_device_get_actor() public

Make the clutter_input_device_get_actor() API public and remove
clutter_input_device_get_pointer_actor() in favour of the new function.

This allows also getting the "pointer" actor for a given touch sequence,
not only for real pointer input devices like mice.

https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1275
This commit is contained in:
Jonas Dreßler 2020-03-03 12:02:29 +01:00 committed by verdre
parent 8de91f1053
commit 7539de2320
4 changed files with 25 additions and 27 deletions

View File

@ -692,20 +692,6 @@ _clutter_input_device_free_touch_info (gpointer data)
g_slice_free (ClutterTouchInfo, data); g_slice_free (ClutterTouchInfo, data);
} }
static ClutterActor *
_clutter_input_device_get_actor (ClutterInputDevice *device,
ClutterEventSequence *sequence)
{
ClutterTouchInfo *info;
if (sequence == NULL)
return device->cursor_actor;
info = g_hash_table_lookup (device->touch_sequences_info, sequence);
return info->actor;
}
static void static void
_clutter_input_device_associate_actor (ClutterInputDevice *device, _clutter_input_device_associate_actor (ClutterInputDevice *device,
ClutterEventSequence *sequence, ClutterEventSequence *sequence,
@ -815,7 +801,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device,
ClutterActor *actor, ClutterActor *actor,
gboolean emit_crossing) gboolean emit_crossing)
{ {
ClutterActor *old_actor = _clutter_input_device_get_actor (device, sequence); ClutterActor *old_actor = clutter_input_device_get_actor (device, sequence);
if (old_actor == actor) if (old_actor == actor)
return; return;
@ -850,7 +836,7 @@ _clutter_input_device_set_actor (ClutterInputDevice *device,
} }
/* processing the event might have destroyed the actor */ /* processing the event might have destroyed the actor */
tmp_old_actor = _clutter_input_device_get_actor (device, sequence); tmp_old_actor = clutter_input_device_get_actor (device, sequence);
_clutter_input_device_unassociate_actor (device, _clutter_input_device_unassociate_actor (device,
old_actor, old_actor,
tmp_old_actor == NULL); tmp_old_actor == NULL);
@ -1054,7 +1040,7 @@ clutter_input_device_update (ClutterInputDevice *device,
clutter_input_device_get_coords (device, sequence, &point); clutter_input_device_get_coords (device, sequence, &point);
old_cursor_actor = _clutter_input_device_get_actor (device, sequence); old_cursor_actor = clutter_input_device_get_actor (device, sequence);
new_cursor_actor = new_cursor_actor =
_clutter_stage_do_pick (stage, point.x, point.y, CLUTTER_PICK_REACTIVE); _clutter_stage_do_pick (stage, point.x, point.y, CLUTTER_PICK_REACTIVE);
@ -1085,22 +1071,33 @@ clutter_input_device_update (ClutterInputDevice *device,
} }
/** /**
* clutter_input_device_get_pointer_actor: * clutter_input_device_get_actor:
* @device: a #ClutterInputDevice of type %CLUTTER_POINTER_DEVICE * @device: a #ClutterInputDevice
* @sequence: (allow-none): an optional #ClutterEventSequence
* *
* Retrieves the #ClutterActor underneath the pointer of @device * Retrieves the #ClutterActor underneath the pointer or touchpoint
* of @device and @sequence.
* *
* Return value: (transfer none): a pointer to the #ClutterActor or %NULL * Return value: (transfer none): a pointer to the #ClutterActor or %NULL
* *
* Since: 1.2 * Since: 1.2
*/ */
ClutterActor * ClutterActor *
clutter_input_device_get_pointer_actor (ClutterInputDevice *device) clutter_input_device_get_actor (ClutterInputDevice *device,
ClutterEventSequence *sequence)
{ {
g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL); ClutterTouchInfo *info;
g_return_val_if_fail (device->device_type == CLUTTER_POINTER_DEVICE, NULL);
return device->cursor_actor; g_return_val_if_fail (CLUTTER_IS_INPUT_DEVICE (device), NULL);
if (sequence == NULL)
return device->cursor_actor;
info = g_hash_table_lookup (device->touch_sequences_info, sequence);
g_return_val_if_fail (info != NULL, NULL);
return info->actor;
} }
/** /**

View File

@ -92,7 +92,8 @@ gboolean clutter_input_device_get_coords (ClutterInputDevi
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterModifierType clutter_input_device_get_modifier_state (ClutterInputDevice *device); ClutterModifierType clutter_input_device_get_modifier_state (ClutterInputDevice *device);
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterActor * clutter_input_device_get_pointer_actor (ClutterInputDevice *device); ClutterActor * clutter_input_device_get_actor (ClutterInputDevice *device,
ClutterEventSequence *sequence);
CLUTTER_EXPORT CLUTTER_EXPORT
ClutterStage * clutter_input_device_get_pointer_stage (ClutterInputDevice *device); ClutterStage * clutter_input_device_get_pointer_stage (ClutterInputDevice *device);
CLUTTER_EXPORT CLUTTER_EXPORT

View File

@ -8135,7 +8135,7 @@ window_has_pointer_wayland (MetaWindow *window)
seat = clutter_backend_get_default_seat (clutter_get_default_backend ()); seat = clutter_backend_get_default_seat (clutter_get_default_backend ());
dev = clutter_seat_get_pointer (seat); dev = clutter_seat_get_pointer (seat);
pointer_actor = clutter_input_device_get_pointer_actor (dev); pointer_actor = clutter_input_device_get_actor (dev, NULL);
window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window)); window_actor = CLUTTER_ACTOR (meta_window_get_compositor_private (window));
return pointer_actor && clutter_actor_contains (window_actor, pointer_actor); return pointer_actor && clutter_actor_contains (window_actor, pointer_actor);

View File

@ -621,7 +621,7 @@ repick_for_event (MetaWaylandPointer *pointer,
if (for_event) if (for_event)
actor = clutter_event_get_source (for_event); actor = clutter_event_get_source (for_event);
else else
actor = clutter_input_device_get_pointer_actor (pointer->device); actor = clutter_input_device_get_actor (pointer->device, NULL);
if (META_IS_SURFACE_ACTOR_WAYLAND (actor)) if (META_IS_SURFACE_ACTOR_WAYLAND (actor))
{ {