mirror of
https://github.com/brl/mutter.git
synced 2024-11-21 23:50:41 -05:00
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>
This commit is contained in:
parent
9f5c453fc7
commit
eaa04ecee5
@ -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;
|
||||
}
|
||||
|
@ -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__ */
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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;
|
||||
|
@ -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)
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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 */
|
||||
|
@ -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);
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user