mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
clutter: Simplify backend-independent touch accounting
Coordinates are tracked by the ClutterSeat backends, we just need to track the target actor at this level. https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1403
This commit is contained in:
parent
307be1e495
commit
52da5fe4f2
@ -61,15 +61,6 @@ typedef struct _ClutterScrollInfo
|
||||
guint last_value_valid : 1;
|
||||
} ClutterScrollInfo;
|
||||
|
||||
typedef struct _ClutterTouchInfo
|
||||
{
|
||||
ClutterEventSequence *sequence;
|
||||
ClutterActor *actor;
|
||||
|
||||
float current_x;
|
||||
float current_y;
|
||||
} ClutterTouchInfo;
|
||||
|
||||
typedef struct _ClutterPtrA11yData
|
||||
{
|
||||
int n_btn_pressed;
|
||||
@ -124,8 +115,8 @@ struct _ClutterInputDevice
|
||||
int current_button_number;
|
||||
ClutterModifierType current_state;
|
||||
|
||||
/* the current touch points states */
|
||||
GHashTable *touch_sequences_info;
|
||||
/* the current touch points targets */
|
||||
GHashTable *touch_sequence_actors;
|
||||
|
||||
/* the previous state, used for click count generation */
|
||||
int previous_x;
|
||||
@ -177,9 +168,6 @@ ClutterActor * clutter_input_device_update (ClutterInputDevice *device,
|
||||
gboolean emit_crossing,
|
||||
ClutterEvent *for_event);
|
||||
CLUTTER_EXPORT
|
||||
void _clutter_input_device_add_event_sequence (ClutterInputDevice *device,
|
||||
ClutterEvent *event);
|
||||
CLUTTER_EXPORT
|
||||
void _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
|
||||
ClutterEvent *event);
|
||||
CLUTTER_EXPORT
|
||||
|
@ -76,7 +76,6 @@ enum
|
||||
PROP_LAST
|
||||
};
|
||||
|
||||
static void _clutter_input_device_free_touch_info (gpointer data);
|
||||
static void on_cursor_actor_destroy (ClutterActor *actor,
|
||||
ClutterInputDevice *device);
|
||||
static void on_cursor_actor_reactive_changed (ClutterActor *actor,
|
||||
@ -113,7 +112,7 @@ clutter_input_device_dispose (GObject *gobject)
|
||||
g_clear_pointer (&device->axes, g_array_unref);
|
||||
g_clear_pointer (&device->keys, g_array_unref);
|
||||
g_clear_pointer (&device->scroll_info, g_array_unref);
|
||||
g_clear_pointer (&device->touch_sequences_info, g_hash_table_unref);
|
||||
g_clear_pointer (&device->touch_sequence_actors, g_hash_table_unref);
|
||||
|
||||
if (device->cursor_actor)
|
||||
{
|
||||
@ -516,30 +515,10 @@ clutter_input_device_init (ClutterInputDevice *self)
|
||||
self->previous_y = -1;
|
||||
self->current_button_number = self->previous_button_number = -1;
|
||||
|
||||
self->touch_sequences_info =
|
||||
g_hash_table_new_full (NULL, NULL,
|
||||
NULL, _clutter_input_device_free_touch_info);
|
||||
self->touch_sequence_actors = g_hash_table_new (NULL, NULL);
|
||||
self->inv_touch_sequence_actors = g_hash_table_new (NULL, NULL);
|
||||
}
|
||||
|
||||
static ClutterTouchInfo *
|
||||
_clutter_input_device_ensure_touch_info (ClutterInputDevice *device,
|
||||
ClutterEventSequence *sequence)
|
||||
{
|
||||
ClutterTouchInfo *info;
|
||||
|
||||
info = g_hash_table_lookup (device->touch_sequences_info, sequence);
|
||||
|
||||
if (info == NULL)
|
||||
{
|
||||
info = g_slice_new0 (ClutterTouchInfo);
|
||||
info->sequence = sequence;
|
||||
g_hash_table_insert (device->touch_sequences_info, sequence, info);
|
||||
}
|
||||
|
||||
return info;
|
||||
}
|
||||
|
||||
/**
|
||||
* clutter_input_device_get_modifier_state:
|
||||
* @device: a #ClutterInputDevice
|
||||
@ -567,12 +546,6 @@ clutter_input_device_get_modifier_state (ClutterInputDevice *device)
|
||||
return modifiers;
|
||||
}
|
||||
|
||||
static void
|
||||
_clutter_input_device_free_touch_info (gpointer data)
|
||||
{
|
||||
g_slice_free (ClutterTouchInfo, data);
|
||||
}
|
||||
|
||||
static void
|
||||
_clutter_input_device_associate_actor (ClutterInputDevice *device,
|
||||
ClutterEventSequence *sequence,
|
||||
@ -584,11 +557,8 @@ _clutter_input_device_associate_actor (ClutterInputDevice *device,
|
||||
{
|
||||
GList *sequences =
|
||||
g_hash_table_lookup (device->inv_touch_sequence_actors, actor);
|
||||
ClutterTouchInfo *info;
|
||||
|
||||
info = _clutter_input_device_ensure_touch_info (device, sequence);
|
||||
info->actor = actor;
|
||||
|
||||
g_hash_table_insert (device->touch_sequence_actors, sequence, actor);
|
||||
g_hash_table_insert (device->inv_touch_sequence_actors,
|
||||
actor, g_list_prepend (sequences, sequence));
|
||||
}
|
||||
@ -616,13 +586,7 @@ _clutter_input_device_unassociate_actor (ClutterInputDevice *device,
|
||||
actor);
|
||||
|
||||
for (l = sequences; l != NULL; l = l->next)
|
||||
{
|
||||
ClutterTouchInfo *info =
|
||||
g_hash_table_lookup (device->touch_sequences_info, l->data);
|
||||
|
||||
if (info)
|
||||
info->actor = NULL;
|
||||
}
|
||||
g_hash_table_remove (device->touch_sequence_actors, l->data);
|
||||
|
||||
g_list_free (sequences);
|
||||
g_hash_table_remove (device->inv_touch_sequence_actors, actor);
|
||||
@ -970,18 +934,12 @@ ClutterActor *
|
||||
clutter_input_device_get_actor (ClutterInputDevice *device,
|
||||
ClutterEventSequence *sequence)
|
||||
{
|
||||
ClutterTouchInfo *info;
|
||||
|
||||
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;
|
||||
return g_hash_table_lookup (device->touch_sequence_actors, sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1422,26 +1380,6 @@ _clutter_input_device_remove_slave (ClutterInputDevice *master,
|
||||
master->slaves = g_list_remove (master->slaves, slave);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* clutter_input_device_add_sequence:
|
||||
* @device: a #ClutterInputDevice
|
||||
* @sequence: a #ClutterEventSequence
|
||||
*
|
||||
* Start tracking informations related to a touch point (position,
|
||||
* actor underneath the touch point).
|
||||
*/
|
||||
void
|
||||
_clutter_input_device_add_event_sequence (ClutterInputDevice *device,
|
||||
ClutterEvent *event)
|
||||
{
|
||||
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
||||
|
||||
if (sequence == NULL)
|
||||
return;
|
||||
|
||||
_clutter_input_device_ensure_touch_info (device, sequence);
|
||||
}
|
||||
|
||||
/*< private >
|
||||
* clutter_input_device_remove_sequence:
|
||||
* @device: a #ClutterInputDevice
|
||||
@ -1454,28 +1392,25 @@ _clutter_input_device_remove_event_sequence (ClutterInputDevice *device,
|
||||
ClutterEvent *event)
|
||||
{
|
||||
ClutterEventSequence *sequence = clutter_event_get_event_sequence (event);
|
||||
ClutterTouchInfo *info =
|
||||
g_hash_table_lookup (device->touch_sequences_info, sequence);
|
||||
ClutterActor *actor =
|
||||
g_hash_table_lookup (device->touch_sequence_actors, sequence);
|
||||
|
||||
if (info == NULL)
|
||||
return;
|
||||
|
||||
if (info->actor != NULL)
|
||||
if (actor != NULL)
|
||||
{
|
||||
GList *sequences =
|
||||
g_hash_table_lookup (device->inv_touch_sequence_actors, info->actor);
|
||||
g_hash_table_lookup (device->inv_touch_sequence_actors, actor);
|
||||
graphene_point_t point;
|
||||
|
||||
sequences = g_list_remove (sequences, sequence);
|
||||
|
||||
g_hash_table_replace (device->inv_touch_sequence_actors,
|
||||
info->actor, sequences);
|
||||
actor, sequences);
|
||||
clutter_event_get_coords (event, &point.x, &point.y);
|
||||
_clutter_input_device_set_actor (device, sequence, NULL, TRUE, point,
|
||||
clutter_event_get_time (event));
|
||||
}
|
||||
|
||||
g_hash_table_remove (device->touch_sequences_info, sequence);
|
||||
g_hash_table_remove (device->touch_sequence_actors, sequence);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1850,9 +1850,6 @@ _clutter_process_event_details (ClutterActor *stage,
|
||||
sequence =
|
||||
clutter_event_get_event_sequence (event);
|
||||
|
||||
if (event->type == CLUTTER_TOUCH_BEGIN)
|
||||
_clutter_input_device_add_event_sequence (device, event);
|
||||
|
||||
clutter_event_get_coords (event, &x, &y);
|
||||
|
||||
/* Only do a pick to find the source if source is not already set
|
||||
|
Loading…
Reference in New Issue
Block a user