[gtk: 1/2] gtktext: Make sure input method sees focus in
- From: Carlos Garnacho <carlosg src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk: 1/2] gtktext: Make sure input method sees focus in
- Date: Thu, 27 Jan 2022 14:13:57 +0000 (UTC)
commit a580547f4758762a6962d707522a92823b98c507
Author: Guido Günther <agx sigxcpu org>
Date: Wed Jan 19 14:40:43 2022 +0100
gtktext: Make sure input method sees focus in
Currently when the widget is realized after the focus in event the input
method isn't activated as enable is never sent. The call trace is
gtk_text_focus_changed ->
gtk_im_context_focus_in ->
gtk_im_context_wayland_focus_in
which returns early as self->widget is NULL since it's set up in
gtk_text_realize() via gtk_im_context_set_client_widget(). Handle that
case by invoking gtk_im_context_focus_in() from gtk_text_realize() too.
A case where the above happens is a GtkSearchEntry in a GtkSearchBar.
E.g. in gtk4-demo when starting the demo and then hitting the search
button right away.
gtk/gtktext.c | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index b4767f7c13..a9aab3405f 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -2211,6 +2211,18 @@ gtk_text_unmap (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_text_parent_class)->unmap (widget);
}
+static void
+gtk_text_im_set_focus_in (GtkText *self)
+{
+ GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
+ if (!priv->editable)
+ return;
+
+ gtk_text_schedule_im_reset (self);
+ gtk_im_context_focus_in (priv->im_context);
+}
+
static void
gtk_text_realize (GtkWidget *widget)
{
@@ -2220,6 +2232,8 @@ gtk_text_realize (GtkWidget *widget)
GTK_WIDGET_CLASS (gtk_text_parent_class)->realize (widget);
gtk_im_context_set_client_widget (priv->im_context, widget);
+ if (gtk_widget_is_focus (GTK_WIDGET (self)))
+ gtk_text_im_set_focus_in (self);
gtk_text_adjust_scroll (self);
gtk_text_update_primary_selection (self);
@@ -3245,12 +3259,7 @@ gtk_text_focus_changed (GtkEventControllerFocus *controller,
g_signal_connect (keyboard, "notify::direction",
G_CALLBACK (direction_changed), self);
- if (priv->editable)
- {
- gtk_text_schedule_im_reset (self);
- gtk_im_context_focus_in (priv->im_context);
- }
-
+ gtk_text_im_set_focus_in (self);
gtk_text_reset_blink_time (self);
}
else /* Focus out */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]