st-button: Ignore pointer emulated touch events

In X11, pointer emulated touch events are replicated with normal PRESS, RELEASE
pair events which are generated by the server. Thus for a single tap we get:
 - TOUCH_BEGIN -> TOUCH_END, PRESS -> RELEASE

This will cause st-button to send two "clicked" signals, instead of just one,
breaking extensions (like dash-to-dock) that show buttons in the main stage
which will be checked two times or that will receive the same signal two times.
This commit is contained in:
Marco Trevisan (Treviño) 2018-10-25 06:35:25 +02:00 committed by Marco Trevisan
parent 3217c10ff2
commit 4c11d15a07

View File

@ -248,6 +248,7 @@ st_button_touch_event (ClutterActor *actor,
if (event->type == CLUTTER_TOUCH_BEGIN && !priv->press_sequence) if (event->type == CLUTTER_TOUCH_BEGIN && !priv->press_sequence)
{ {
clutter_input_device_sequence_grab (device, sequence, actor); clutter_input_device_sequence_grab (device, sequence, actor);
if (!clutter_event_is_pointer_emulated ((ClutterEvent*) event))
st_button_press (button, device, 0, sequence); st_button_press (button, device, 0, sequence);
return CLUTTER_EVENT_STOP; return CLUTTER_EVENT_STOP;
} }
@ -255,7 +256,9 @@ st_button_touch_event (ClutterActor *actor,
priv->device == device && priv->device == device &&
priv->press_sequence == sequence) priv->press_sequence == sequence)
{ {
if (!clutter_event_is_pointer_emulated ((ClutterEvent*) event))
st_button_release (button, device, mask, 0, sequence); st_button_release (button, device, mask, 0, sequence);
clutter_input_device_sequence_ungrab (device, sequence); clutter_input_device_sequence_ungrab (device, sequence);
return CLUTTER_EVENT_STOP; return CLUTTER_EVENT_STOP;
} }