From 6d3c740b376ce4ba1f344cccbeb1a5939a49e52c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Sun, 29 Mar 2020 19:36:12 +0200 Subject: [PATCH] st/entry: Unset key focus when made unreactive It seems reasonable that an entry shouldn't allow entering text when not reactive. The same could be achieved by changing the text's :editable property, however that will disable scrolling if the text doesn't fit, which may result in an unwanted size change. https://gitlab.gnome.org/GNOME/gnome-shell/issues/2423 --- src/st/st-entry.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/st/st-entry.c b/src/st/st-entry.c index 2be524bb3..9391ffb80 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -513,6 +513,26 @@ st_entry_allocate (ClutterActor *actor, clutter_actor_allocate (priv->entry, &child_box, flags); } +static void +clutter_text_reactive_changed_cb (ClutterActor *text, + GParamSpec *pspec, + gpointer user_data) +{ + ClutterActor *stage; + + if (clutter_actor_get_reactive (text)) + return; + + if (!clutter_actor_has_key_focus (text)) + return; + + stage = clutter_actor_get_stage (text); + if (stage == NULL) + return; + + clutter_stage_set_key_focus (CLUTTER_STAGE (stage), NULL); +} + static void clutter_text_focus_in_cb (ClutterText *text, ClutterActor *actor) @@ -981,6 +1001,9 @@ st_entry_init (StEntry *entry) priv->entry, "reactive", G_BINDING_DEFAULT); + g_signal_connect(priv->entry, "notify::reactive", + G_CALLBACK (clutter_text_reactive_changed_cb), entry); + g_signal_connect (priv->entry, "key-focus-in", G_CALLBACK (clutter_text_focus_in_cb), entry);