st: Replace global grabs with input device grabs

Global grabs are being removed from Clutter in favour of input device
grabs, so only grab the input device instead and replace priv->grabbed
with checks for priv->grab_device.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/495
This commit is contained in:
Jonas Dreßler 2019-04-14 18:32:37 +02:00 committed by Florian Müllner
parent 6c33aff6d1
commit d5a1a888d9
2 changed files with 13 additions and 11 deletions

View File

@ -192,7 +192,7 @@ st_button_button_press (ClutterActor *actor,
if (priv->button_mask & mask)
{
if (priv->grabbed == 0)
clutter_grab_pointer (actor);
clutter_input_device_grab (device, actor);
priv->grabbed |= mask;
st_button_press (button, device, mask, NULL);
@ -221,7 +221,7 @@ st_button_button_release (ClutterActor *actor,
priv->grabbed &= ~mask;
if (priv->grabbed == 0)
clutter_ungrab_pointer ();
clutter_input_device_ungrab (device);
return TRUE;
}
@ -787,7 +787,7 @@ st_button_fake_release (StButton *button)
if (priv->grabbed)
{
priv->grabbed = 0;
clutter_ungrab_pointer ();
clutter_input_device_ungrab (priv->device);
}
priv->device = NULL;

View File

@ -49,10 +49,11 @@ struct _StScrollBarPrivate
{
StAdjustment *adjustment;
gboolean grabbed;
gfloat x_origin;
gfloat y_origin;
ClutterInputDevice *grab_device;
ClutterActor *trough;
ClutterActor *handle;
@ -601,13 +602,13 @@ static void
stop_scrolling (StScrollBar *bar)
{
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
if (!priv->grabbed)
if (!priv->grab_device)
return;
st_widget_remove_style_pseudo_class (ST_WIDGET (priv->handle), "active");
clutter_ungrab_pointer ();
priv->grabbed = FALSE;
clutter_input_device_ungrab (priv->grab_device);
priv->grab_device = NULL;
g_signal_emit (bar, signals[SCROLL_STOP], 0);
}
@ -617,7 +618,7 @@ handle_motion_event_cb (ClutterActor *trough,
StScrollBar *bar)
{
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
if (!priv->grabbed)
if (!priv->grab_device)
return FALSE;
move_slider (bar, event->x, event->y);
@ -642,6 +643,7 @@ handle_button_press_event_cb (ClutterActor *actor,
StScrollBar *bar)
{
StScrollBarPrivate *priv = st_scroll_bar_get_instance_private (bar);
ClutterInputDevice *device = clutter_event_get_device ((ClutterEvent*) event);
if (event->button != 1)
return FALSE;
@ -659,10 +661,10 @@ handle_button_press_event_cb (ClutterActor *actor,
priv->x_origin += clutter_actor_get_x (priv->trough);
priv->y_origin += clutter_actor_get_y (priv->trough);
g_assert (!priv->grabbed);
g_assert (!priv->grab_device);
clutter_grab_pointer (priv->handle);
priv->grabbed = TRUE;
clutter_input_device_grab (device, priv->handle);
priv->grab_device = device;
g_signal_emit (bar, signals[SCROLL_START], 0);
return TRUE;