Skip to content

Commit 64540d2

Browse files
committed
keyboardManager.js: Don't wait on ibus' set_global_engine_async()
to return when switching between xkb layouts. This can incur at noticeable delay when switching, so skip it unless it's necessary. ref: #13384, #13428 (though I think in both of these the comments are not always referring to the same issues, since there are multiple keybinding types at work here).
1 parent c433277 commit 64540d2

1 file changed

Lines changed: 16 additions & 4 deletions

File tree

js/ui/keyboardManager.js

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,14 +636,18 @@ var InputSourceManager = class {
636636
if (is === this._currentSource)
637637
return;
638638

639+
// A switch between two xkb layouts doesn't change the ibus engine.
640+
let xkbToXkb = this._currentSource?.type == INPUT_SOURCE_TYPE_XKB &&
641+
is.type == INPUT_SOURCE_TYPE_XKB;
642+
639643
// The focus changes during holdKeyboard/releaseKeyboard may trick
640644
// the client into hiding UI containing the currently focused entry.
641645
// So holdKeyboard/releaseKeyboard are not called when
642646
// 'set-content-type' signal is received.
643647
// E.g. Focusing on a password entry in a popup in Xorg Firefox
644648
// will emit 'set-content-type' signal.
645649
// https://gitlab.gnome.org/GNOME/gnome-shell/issues/391
646-
if (!this._reloading)
650+
if (!this._reloading && !xkbToXkb)
647651
holdKeyboard();
648652
this._keyboardManager.apply(is.xkbId);
649653

@@ -659,10 +663,18 @@ var InputSourceManager = class {
659663
else
660664
engine = 'xkb:us::eng';
661665

662-
if (!this._reloading)
663-
this._ibusManager.setEngine(engine, releaseKeyboard);
664-
else
666+
if (this._reloading) {
667+
this._ibusManager.setEngine(engine);
668+
} else if (xkbToXkb) {
669+
// muffin freezes the keyboard for grp: switches (via
670+
// modifiers-accelerator-activated) and delegates the unfreeze to
671+
// this handler, so release it even though we skipped holdKeyboard -
672+
// synchronously, without waiting on the ibus round-trip.
665673
this._ibusManager.setEngine(engine);
674+
releaseKeyboard();
675+
} else {
676+
this._ibusManager.setEngine(engine, releaseKeyboard);
677+
}
666678

667679
if (is.type == INPUT_SOURCE_TYPE_IBUS && (is.id === this._currentSource?.id)) {
668680
this._ibusManager.refreshCurrentEngineProperties();

0 commit comments

Comments
 (0)