Wayland: type through wtype and release the overlay's keyboard grab - #63
Open
SMZ70 wants to merge 4 commits into
Open
Wayland: type through wtype and release the overlay's keyboard grab#63SMZ70 wants to merge 4 commits into
SMZ70 wants to merge 4 commits into
Conversation
SMZ70
marked this pull request as ready for review
August 25, 2026 01:57
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Makes the whip actually land on Wayland compositors. Tested on sway 1.9 / Ubuntu 24.04 with ghostty.
There are already two open Linux PRs (#34, #37), so to be clear about what is different here: this one needs no root daemon, no group membership and no re-login, and it fixes a second bug that neither addresses.
1.
xdotoolcannot reach Wayland clientssendMacroLinuxcurrently shells out toxdotool, which drives XTEST. A wlroots compositor does not route XTEST events to Wayland clients, so under sway the macro reaches XWayland windows and nothing else — whipping a Wayland-native terminal silently does nothing at all.This routes to
wtype(1)whenWAYLAND_DISPLAYis set, which speaks the virtual-keyboard Wayland protocol. The existingxdotoolpath is untouched and still used on X11.wtypeneeds no daemon and no elevated privileges — it is a plainapt install wtype/pacman -S wtype. That is the main practical difference from #34, which usesydotooland therefore requiressystemctl enable --now ydotool,usermod -aG input, and a logout before it works.2. The overlay swallows the keystrokes
This one took a while to find, and it bites regardless of which input tool you use.
The overlay is created with
setAlwaysOnTop(true, 'screen-saver'), which Electron maps to a layer-shell surface that holds keyboard interactivity. While the whip is on screen, the compositor routes the virtual keyboard to that surface — not to the window it still reports as focused. Every keystroke vanishes into the whip.The symptom is confusing, because everything looks correct: the right window is focused, and every
wtype/ydotoolcall exits 0. Nothing arrives. Dropping the surface for the ~200 ms the macro takes is what actually releases the keyboard; it is restored immediately afterwards so the whip survives the crack.I would expect #34 and #37 to hit this too on any wlroots compositor.
3. Focus drifts mid-crack under
focus_follows_mousesway defaults to
focus_follows_mouse=yes, and cracking a whip means flinging the pointer across the screen — so focus lands on whichever window the cursor passed over, and the macro types there.The focused container is now recorded on tray click, before the overlay appears or the pointer starts moving, and refocused via
swaymsgimmediately before typing.refocusPreviousApp's Alt+Tab is skipped under Wayland, where it is meaningless: a tiling compositor has no most-recently-used stack to walk, and neither the layer-shell tray nor thefocusable: falseoverlay ever takes keyboard focus in the first place.This part is sway-specific and degrades gracefully — if
swaymsgis not present (Hyprland, GNOME, ...) it falls through to whatever currently has focus, which is the previous behaviour.Notes
wtypeis invoked throughexecFilewith an argv array, and the phrase is passed after--so a text starting with-is never parsed as an option.