[gnome-shell] st/entry: Unset key focus when made unreactive
- From: Georges Basile Stavracas Neto <gbsneto src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st/entry: Unset key focus when made unreactive
- Date: Sun, 29 Mar 2020 20:24:20 +0000 (UTC)
commit 6d3c740b376ce4ba1f344cccbeb1a5939a49e52c
Author: Florian Müllner <fmuellner gnome org>
Date: Sun Mar 29 19:36:12 2020 +0200
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 2be524bb36..9391ffb804 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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]