gtktext: Make sure input method sees focus in
authorGuido Günther <agx@sigxcpu.org>
Wed, 19 Jan 2022 13:40:43 +0000 (14:40 +0100)
committerGuido Günther <agx@sigxcpu.org>
Tue, 25 Jan 2022 10:15:29 +0000 (11:15 +0100)
commita580547f4758762a6962d707522a92823b98c507
tree979a0c7684fe34d375a038f43da79f4aa7eca31e
parent00ee7ffa6aad0a58c0399b46c0c950f127dafcae
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