clutter: Use ClutterGrab for ClutterText implicit grab
This is used to temporarily redirect input to the entry, while text is being selected. Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2099>
This commit is contained in:
parent
3a79b7b066
commit
0e234d76f4
1 changed files with 14 additions and 18 deletions
|
@ -187,6 +187,8 @@ struct _ClutterTextPrivate
|
|||
ClutterInputContentHintFlags input_hints;
|
||||
ClutterInputContentPurpose input_purpose;
|
||||
|
||||
ClutterGrab *grab;
|
||||
|
||||
float last_click_x;
|
||||
float last_click_y;
|
||||
uint32_t last_click_time_ms;
|
||||
|
@ -2208,6 +2210,7 @@ clutter_text_press (ClutterActor *actor,
|
|||
ClutterText *self = CLUTTER_TEXT (actor);
|
||||
ClutterTextPrivate *priv = self->priv;
|
||||
ClutterEventType type = clutter_event_type (event);
|
||||
ClutterActor *stage;
|
||||
gboolean res = FALSE;
|
||||
gfloat x, y;
|
||||
gint index_;
|
||||
|
@ -2288,18 +2291,11 @@ clutter_text_press (ClutterActor *actor,
|
|||
/* grab the pointer */
|
||||
priv->in_select_drag = TRUE;
|
||||
|
||||
if (type == CLUTTER_BUTTON_PRESS)
|
||||
{
|
||||
clutter_input_device_grab (clutter_event_get_device (event),
|
||||
actor);
|
||||
}
|
||||
else
|
||||
{
|
||||
clutter_input_device_sequence_grab (clutter_event_get_device (event),
|
||||
clutter_event_get_event_sequence (event),
|
||||
actor);
|
||||
priv->in_select_touch = TRUE;
|
||||
}
|
||||
stage = clutter_actor_get_stage (actor);
|
||||
priv->grab = clutter_stage_grab (CLUTTER_STAGE (stage), actor);
|
||||
|
||||
if (type != CLUTTER_BUTTON_PRESS)
|
||||
priv->in_select_touch = TRUE;
|
||||
|
||||
return CLUTTER_EVENT_STOP;
|
||||
}
|
||||
|
@ -2346,11 +2342,16 @@ clutter_text_release (ClutterActor *actor,
|
|||
|
||||
if (priv->in_select_drag)
|
||||
{
|
||||
if (priv->grab)
|
||||
{
|
||||
clutter_grab_dismiss (priv->grab);
|
||||
g_clear_pointer (&priv->grab, clutter_grab_unref);
|
||||
}
|
||||
|
||||
if (type == CLUTTER_BUTTON_RELEASE)
|
||||
{
|
||||
if (!priv->in_select_touch)
|
||||
{
|
||||
clutter_input_device_ungrab (clutter_event_get_device (event));
|
||||
priv->in_select_drag = FALSE;
|
||||
|
||||
return CLUTTER_EVENT_STOP;
|
||||
|
@ -2360,11 +2361,6 @@ clutter_text_release (ClutterActor *actor,
|
|||
{
|
||||
if (priv->in_select_touch)
|
||||
{
|
||||
ClutterInputDevice *device = clutter_event_get_device (event);
|
||||
ClutterEventSequence *sequence =
|
||||
clutter_event_get_event_sequence (event);
|
||||
|
||||
clutter_input_device_sequence_ungrab (device, sequence);
|
||||
priv->in_select_touch = FALSE;
|
||||
priv->in_select_drag = FALSE;
|
||||
|
||||
|
|
Loading…
Reference in a new issue