Skip to content

immulticontext: Don't have a global_context_id

Guido Günther requested to merge guidog/gtk:im-multi into gtk-3-24

This is a backport of 16d4ce4d by @otte to GTK3:

Context IDs are dependant on the display - both because displays can use different backends, but also because changing the GtkSetting is a per-display operation.

So just remove the cache. If it turns out we need a per-display cache, we can add one to GtkSettings.

It fixes a crash on phosh's lockscreen when you use the OSK and swipe it away triggered by the fact that we do

   g_object_set (priv->entry_pin, "im-module", "gtk-im-context-none", NULL);

to make the OSK stay hidden when the user uses the keypad. This switch of the im-context leads to an endless loop:

#21387 0x0000ffff81c1c6b8 in gtk_im_multicontext_retrieve_surrounding_cb (slave=<optimized out>, multicontext=<optimized out>)
    at ../../../gtk/gtkimmulticontext.c:538
#21391 0x0000ffff814359a0 in <emit signal '0xffff618d3b00 "retrieve-surrounding"' on instance 0xaaaaed9481a0 [GtkIMContextWayland]>
    (instance=0xaaaaed9481a0, detailed_signal=detailed_signal@entry=0xffff618d3b00 "retrieve-surrounding")
    at ../../../gobject/gsignal.c:3624
    #21388 0x0000ffff81ab62e0 in _gtk_marshal_BOOLEAN__VOIDv
    (closure=<optimized out>, return_value=0xffffd76f6218, instance=<optimized out>, args=..., marshal_data=<optimized out>, n_params=<optimized out>, param_types=<optimized out>) at gtk/gtkmarshalers.c:2147
    #21389 0x0000ffff81418588 in _g_closure_invoke_va
    (closure=0xaaaaef58eda0, return_value=0xffffd76f6218, instance=0xaaaaed9481a0, args=..., n_params=0, param_types=0x0)
    at ../../../gobject/gclosure.c:897
    #21390 0x0000ffff8142f17c in signal_emit_valist_unlocked (instance=0xaaaaed7b28c0, 
    instance@entry=0xaaaaed9481a0, signal_id=signal_id@entry=456, detail=<optimized out>, var_args=...)
    at ../../../gobject/gsignal.c:3424
#21392 0x0000ffff618d29ec in notify_im_change
    (context=context@entry=0xaaaaed9481a0 [GtkIMContextWayland], cause=cause@entry=ZWP_TEXT_INPUT_V3_CHANGE_CAUSE_OTHER)
    at ../../../modules/input/imwayland.c:145
#21393 0x0000ffff618d2b40 in gtk_im_context_wayland_reset (context=0xaaaaed9481a0 [GtkIMContextWayland])
    at ../../../modules/input/imwayland.c:854
#21394 0x0000ffff81c1ca5c in gtk_im_multicontext_set_slave
    (multicontext=multicontext@entry=0xaaaaee393090 [GtkIMMulticontext], slave=slave@entry=0x0, finalizing=finalizing@entry=0)
    at ../../../gtk/gtkimmulticontext.c:182
#21395 0x0000ffff81c1cccc in gtk_im_multicontext_get_slave (multicontext=0xaaaaee393090 [GtkIMMulticontext])
    at ../../../gtk/gtkimmulticontext.c:271
#21396 0x0000ffff81c1cf04 in gtk_im_multicontext_set_surrounding
    (context=<optimized out>, text=0xaaaaf05a8eb0 "", len=0, cursor_index=0) at ../../../gtk/gtkimmulticontext.c:497
#21397 0x0000ffff81b9da0c in gtk_entry_retrieve_surrounding_cb (context=0xaaaaee393090 [GtkIMMulticontext], entry=<optimized out>)
    at ../../../gtk/gtkentry.c:6121
#21401 0x0000ffff814359a0 in <emit signal '0xffff81ea1d28 "retrieve-surrounding"' on instance 0xaaaaee393090 [GtkIMMulticontext]>
    (instance=0xaaaaee393090, detailed_signal=detailed_signal@entry=0xffff81ea1d28 "retrieve-surrounding")
    at ../../../gobject/gsignal.c:3624
    #21398 0x0000ffff81ab62e0 in _gtk_marshal_BOOLEAN__VOIDv
    (closure=<optimized out>, return_value=0xffffd76f67b8, instance=<optimized out>, args=..., marshal_data=<optimized out>, n_params=<optimized out>, param_types=<optimized out>) at gtk/gtkmarshalers.c:2147
    #21399 0x0000ffff81418588 in _g_closure_invoke_va
    (closure=0xaaaaf05de560, return_value=0xffffd76f67b8, instance=0xaaaaee393090, args=..., n_params=0, param_types=0x0)
    at ../../../gobject/gclosure.c:897
    #21400 0x0000ffff8142f17c in signal_emit_valist_unlocked (instance=0xaaaaed7a4650, 
    instance@entry=0xaaaaee393090, signal_id=signal_id@entry=456, detail=<optimized out>, var_args=...)
    at ../../../gobject/gsignal.c:3424
#21402 0x0000ffff81c1c6b8 in gtk_im_multicontext_retrieve_surrounding_cb (slave=<optimized out>, multicontext=<optimized out>)
    at ../../../gtk/gtkimmulticontext.c:538
(gdb) 

Removing the cache fixes this as well as it gets rid of the gtk_im_multicontext_set_slave (multicontext, NULL, FALSE); in gtk_im_multicontext_get_slave.

Merge request reports