Files
voculinux/tests
4e3637dfb5 Fix: IBus engine restore uses wrong fallback on GNOME/Wayland (#497) (#500)
* Fix: IBus engine restore uses wrong fallback on GNOME/Wayland (#497)

On GNOME/Wayland, when IBus has no global engine (common when Mutter
manages input sources), 'ibus engine' can return a misleading
'xkb:us::eng' default that doesn't match the user's actual keyboard
layout. When Vocalinux restores this wrong value after text injection,
Electron apps switch to US layout.

Root cause: get_current_engine() trusted the output of 'ibus engine'
without checking whether IBus actually had a global engine set, and
had no fallback to discover the real keyboard layout.

Fix:
- Add get_current_engine_gnome_fallback() that reads the actual
  keyboard layout from org.gnome.desktop.input-sources via gsettings
- Modify get_current_engine() to detect 'No global engine' in stderr
  and to detect the suspicious 'xkb:us::eng' default on GNOME/Wayland,
  falling back to gsettings in both cases
- Modify stop() to log a message when skipping engine restoration
  because no valid engine was captured (None means don't restore)
- Modify inject_text() to log when skipping restoration after
  injection for the same reason
- Backward compatible: if gsettings is unavailable, falls back to
  current behavior (returning None or the IBus-reported value)

Tests: 12 new tests covering GNOME fallback, 'No global engine'
detection, suspicious default detection, gsettings parsing, and
edge cases.

* ponytail: simplify gsettings uint32 parsing

gsettings prints 'uint32 N' or just 'N' — split()[-1] handles both,
no need for separate branches

---------

Co-authored-by: Jatin K Malik <jatinkrmalik@users.noreply.github.com>
2026-07-11 05:42:00 +05:30
..