[mutter/wip/carlosg/event-cleanup: 13/18] backends: Unify touch sequence to slot conversion
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [mutter/wip/carlosg/event-cleanup: 13/18] backends: Unify touch sequence to slot conversion
- Date: Tue, 8 Dec 2020 15:37:42 +0000 (UTC)
commit eaa04ecee5eefb957987650fef1c6ab6c34b03b7
Author: Carlos Garnacho <carlosg gnome org>
Date: Tue Dec 8 12:51:56 2020 +0100
backends: Unify touch sequence to slot conversion
We had code in both backends that sort of independently associated
sequences to slots. Make both transform slots to sequences the same
way, so they may share the implementation convert those back to slots.
This helper now lives in Clutter API.
Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1623>
clutter/clutter/clutter-event.c | 8 ++++++++
clutter/clutter/clutter-event.h | 3 +++
src/backends/native/meta-event-native.c | 20 --------------------
src/backends/native/meta-event-native.h | 2 --
src/backends/native/meta-seat-impl.c | 2 +-
src/backends/x11/meta-backend-x11.c | 2 +-
src/backends/x11/meta-event-x11.c | 8 --------
src/backends/x11/meta-event-x11.h | 2 --
src/backends/x11/meta-seat-x11.c | 6 ++++--
src/wayland/meta-wayland-touch.c | 2 +-
10 files changed, 18 insertions(+), 37 deletions(-)
---
diff --git a/clutter/clutter/clutter-event.c b/clutter/clutter/clutter-event.c
index 793884f007..19ec29f325 100644
--- a/clutter/clutter/clutter-event.c
+++ b/clutter/clutter/clutter-event.c
@@ -2134,3 +2134,11 @@ clutter_event_get_event_code (const ClutterEvent *event)
return 0;
}
+
+int32_t
+clutter_event_sequence_get_slot (const ClutterEventSequence *sequence)
+{
+ g_return_val_if_fail (sequence != NULL, -1);
+
+ return GPOINTER_TO_INT (sequence) - 1;
+}
diff --git a/clutter/clutter/clutter-event.h b/clutter/clutter/clutter-event.h
index 5ff8ae8f9e..7c3d364639 100644
--- a/clutter/clutter/clutter-event.h
+++ b/clutter/clutter/clutter-event.h
@@ -788,6 +788,9 @@ gboolean clutter_event_get_pad_event_details (const Clut
CLUTTER_EXPORT
uint32_t clutter_event_get_event_code (const ClutterEvent *event);
+CLUTTER_EXPORT
+int32_t clutter_event_sequence_get_slot (const ClutterEventSequence *sequence);
+
G_END_DECLS
#endif /* __CLUTTER_EVENT_H__ */
diff --git a/src/backends/native/meta-event-native.c b/src/backends/native/meta-event-native.c
index b7e719468e..8d59e62876 100644
--- a/src/backends/native/meta-event-native.c
+++ b/src/backends/native/meta-event-native.c
@@ -154,23 +154,3 @@ meta_event_native_get_relative_motion (const ClutterEvent *event,
else
return FALSE;
}
-
-/**
- * meta_event_native_sequence_get_slot:
- * @sequence: a #ClutterEventSequence
- *
- * Retrieves the touch slot triggered by this @sequence
- *
- * Returns: the libinput touch slot.
- *
- * Since: 1.20
- * Stability: unstable
- **/
-int32_t
-meta_event_native_sequence_get_slot (const ClutterEventSequence *sequence)
-{
- if (!sequence)
- return -1;
-
- return GPOINTER_TO_INT (sequence) - 1;
-}
diff --git a/src/backends/native/meta-event-native.h b/src/backends/native/meta-event-native.h
index fc546530a6..43cf7b9299 100644
--- a/src/backends/native/meta-event-native.h
+++ b/src/backends/native/meta-event-native.h
@@ -42,6 +42,4 @@ gboolean meta_event_native_get_relative_motion (const ClutterEvent *eve
double *dx_unaccel,
double *dy_unaccel);
-int32_t meta_event_native_sequence_get_slot (const ClutterEventSequence *sequence);
-
#endif /* META_EVENT_NATIVE_H */
diff --git a/src/backends/native/meta-seat-impl.c b/src/backends/native/meta-seat-impl.c
index 033a9e3dfe..bc68e0e990 100644
--- a/src/backends/native/meta-seat-impl.c
+++ b/src/backends/native/meta-seat-impl.c
@@ -2890,7 +2890,7 @@ meta_seat_impl_query_state (MetaSeatImpl *seat_impl,
MetaTouchState *touch_state;
int slot;
- slot = meta_event_native_sequence_get_slot (sequence);
+ slot = clutter_event_sequence_get_slot (sequence);
touch_state = meta_seat_impl_lookup_touch_state_in_impl (seat_impl, slot);
if (!touch_state)
goto out;
diff --git a/src/backends/x11/meta-backend-x11.c b/src/backends/x11/meta-backend-x11.c
index 94a13e7cdb..f79b0d6d4f 100644
--- a/src/backends/x11/meta-backend-x11.c
+++ b/src/backends/x11/meta-backend-x11.c
@@ -691,7 +691,7 @@ meta_backend_x11_finish_touch_sequence (MetaBackend *backend,
XIAllowTouchEvents (priv->xdisplay,
META_VIRTUAL_CORE_POINTER_ID,
- meta_x11_event_sequence_get_touch_detail (sequence),
+ clutter_event_sequence_get_slot (sequence),
DefaultRootWindow (priv->xdisplay), event_mode);
if (state == META_SEQUENCE_REJECTED)
diff --git a/src/backends/x11/meta-event-x11.c b/src/backends/x11/meta-event-x11.c
index 8217e3db7e..fa287ead34 100644
--- a/src/backends/x11/meta-event-x11.c
+++ b/src/backends/x11/meta-event-x11.c
@@ -113,11 +113,3 @@ out:
return result;
}
-
-guint
-meta_x11_event_sequence_get_touch_detail (const ClutterEventSequence *sequence)
-{
- g_return_val_if_fail (sequence != NULL, 0);
-
- return GPOINTER_TO_UINT (sequence);
-}
diff --git a/src/backends/x11/meta-event-x11.h b/src/backends/x11/meta-event-x11.h
index 6e0b54eee2..ceb363ab0e 100644
--- a/src/backends/x11/meta-event-x11.h
+++ b/src/backends/x11/meta-event-x11.h
@@ -28,8 +28,6 @@
#include "clutter/x11/clutter-x11.h"
-guint meta_x11_event_sequence_get_touch_detail (const ClutterEventSequence *sequence);
-
ClutterX11FilterReturn meta_x11_handle_event (XEvent *xevent);
#endif /* META_EVENT_X11_H */
diff --git a/src/backends/x11/meta-seat-x11.c b/src/backends/x11/meta-seat-x11.c
index 1fea4553a0..b04da4a977 100644
--- a/src/backends/x11/meta-seat-x11.c
+++ b/src/backends/x11/meta-seat-x11.c
@@ -2213,7 +2213,8 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
GUINT_TO_POINTER (xev->detail));
}
- event->touch.sequence = GUINT_TO_POINTER (xev->detail);
+ /* "NULL" sequences are special cased in clutter */
+ event->touch.sequence = GINT_TO_POINTER (MAX (1, xev->detail + 1));
if (xev->flags & XITouchEmulatingPointer)
_clutter_event_set_pointer_emulated (event, TRUE);
@@ -2242,7 +2243,8 @@ meta_seat_x11_translate_event (MetaSeatX11 *seat,
event->touch.type = event->type = CLUTTER_TOUCH_UPDATE;
event->touch.stage = stage;
event->touch.time = xev->time;
- event->touch.sequence = GUINT_TO_POINTER (xev->detail);
+ /* "NULL" sequences are special cased in clutter */
+ event->touch.sequence = GINT_TO_POINTER (MAX (1, xev->detail + 1));
translate_coords (stage_x11, xev->event_x, xev->event_y, &event->touch.x, &event->touch.y);
clutter_event_set_source_device (event, source_device);
diff --git a/src/wayland/meta-wayland-touch.c b/src/wayland/meta-wayland-touch.c
index bf11fc5909..147c3845e9 100644
--- a/src/wayland/meta-wayland-touch.c
+++ b/src/wayland/meta-wayland-touch.c
@@ -188,7 +188,7 @@ touch_get_info (MetaWaylandTouch *touch,
if (!touch_info && create)
{
touch_info = g_new0 (MetaWaylandTouchInfo, 1);
- touch_info->slot = meta_event_native_sequence_get_slot (sequence);
+ touch_info->slot = clutter_event_sequence_get_slot (sequence);
g_hash_table_insert (touch->touches, sequence, touch_info);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]