[gnome-shell/wip/carlosg/grabs-pt2: 5/20] st: Use ClutterGrab for StButton implicit grab
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell/wip/carlosg/grabs-pt2: 5/20] st: Use ClutterGrab for StButton implicit grab
- Date: Thu, 25 Nov 2021 10:24:10 +0000 (UTC)
commit 5634eba56d0a39a4e35e7f2491a462fefb20ccbc
Author: Carlos Garnacho <carlosg gnome org>
Date: Thu Nov 18 00:00:01 2021 +0100
st: Use ClutterGrab for StButton implicit grab
src/st/st-button.c | 35 ++++++++++++++---------------------
1 file changed, 14 insertions(+), 21 deletions(-)
---
diff --git a/src/st/st-button.c b/src/st/st-button.c
index eae245928a..c369d1a008 100644
--- a/src/st/st-button.c
+++ b/src/st/st-button.c
@@ -76,6 +76,7 @@ struct _StButtonPrivate
ClutterInputDevice *device;
ClutterEventSequence *press_sequence;
+ ClutterGrab *grab;
guint button_mask : 3;
guint is_toggle : 1;
@@ -191,8 +192,12 @@ st_button_button_press (ClutterActor *actor,
if (priv->button_mask & mask)
{
+ ClutterActor *stage;
+
+ stage = clutter_actor_get_stage (actor);
+
if (priv->grabbed == 0)
- clutter_input_device_grab (device, actor);
+ priv->grab = clutter_stage_grab (CLUTTER_STAGE (stage), actor);
priv->grabbed |= mask;
st_button_press (button, device, mask, NULL);
@@ -220,8 +225,8 @@ st_button_button_release (ClutterActor *actor,
st_button_release (button, device, mask, is_click ? event->button : 0, NULL);
priv->grabbed &= ~mask;
- if (priv->grabbed == 0)
- clutter_input_device_ungrab (device);
+ if (priv->grab && priv->grabbed == 0)
+ g_clear_pointer (&priv->grab, clutter_grab_dismiss);
return TRUE;
}
@@ -247,21 +252,16 @@ st_button_touch_event (ClutterActor *actor,
device = clutter_event_get_device ((ClutterEvent*) event);
sequence = clutter_event_get_event_sequence ((ClutterEvent*) event);
- if (event->type == CLUTTER_TOUCH_BEGIN && !priv->press_sequence)
+ if (event->type == CLUTTER_TOUCH_BEGIN && !priv->grab && !priv->press_sequence)
{
- 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;
}
else if (event->type == CLUTTER_TOUCH_END &&
priv->device == device &&
priv->press_sequence == sequence)
{
- if (!clutter_event_is_pointer_emulated ((ClutterEvent*) event))
- st_button_release (button, device, mask, 0, sequence);
-
- clutter_input_device_sequence_ungrab (device, sequence);
+ st_button_release (button, device, mask, 0, sequence);
return CLUTTER_EVENT_STOP;
}
else if (event->type == CLUTTER_TOUCH_CANCEL)
@@ -810,16 +810,9 @@ st_button_fake_release (StButton *button)
g_return_if_fail (ST_IS_BUTTON (button));
priv = st_button_get_instance_private (button);
- if (priv->device && priv->press_sequence)
- {
- clutter_input_device_sequence_ungrab (priv->device,
- priv->press_sequence);
- }
- else if (priv->grabbed)
- {
- priv->grabbed = 0;
- clutter_input_device_ungrab (priv->device);
- }
+
+ g_clear_pointer (&priv->grab, clutter_grab_dismiss);
+ priv->grabbed = 0;
if (priv->pressed || priv->press_sequence)
st_button_release (button, priv->device,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]