[mutter/wip/carlosg/input-thread: 52/104] clutter: Simplify backend-independent touch accounting
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/input-thread: 52/104] clutter: Simplify backend-independent touch accounting
- Date: Thu, 8 Oct 2020 21:41:42 +0000 (UTC)
commit 17d74185a84e06e9035b9001507770f6ccac78e4
Author: Carlos Garnacho <carlosg gnome org>
Date: Sat Jun 6 12:48:16 2020 +0200
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
clutter/clutter/clutter-input-device-private.h | 16 +----
clutter/clutter/clutter-input-device.c | 87 ++++----------------------
clutter/clutter/clutter-main.c | 3 -
3 files changed, 13 insertions(+), 93 deletions(-)
---
diff --git a/clutter/clutter/clutter-input-device-private.h b/clutter/clutter/clutter-input-device-private.h
index c37419255b..a085947e0c 100644
--- a/clutter/clutter/clutter-input-device-private.h
+++ b/clutter/clutter/clutter-input-device-private.h
@@ -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
diff --git a/clutter/clutter/clutter-input-device.c b/clutter/clutter/clutter-input-device.c
index c63024d889..e920552aed 100644
--- a/clutter/clutter/clutter-input-device.c
+++ b/clutter/clutter/clutter-input-device.c
@@ -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_physical_device (ClutterInputDevice *logical,
logical->physical_devices = g_list_remove (logical->physical_devices, physical);
}
-/*< private >
- * clutter_input_device_add_sequence:
- * @device: a #ClutterInputDevice
- * @sequence: a #ClutterEventSequence
- *
- * Start tracking information 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);
}
/**
diff --git a/clutter/clutter/clutter-main.c b/clutter/clutter/clutter-main.c
index 7d789ad365..1b8a26c6ad 100644
--- a/clutter/clutter/clutter-main.c
+++ b/clutter/clutter/clutter-main.c
@@ -1853,9 +1853,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
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]