Skip to content

Fix Emoji Picker for all apps with both keyboard and mouse - #8573

Open
axelfontaine wants to merge 5 commits into
omacom:quattrofrom
axelfontaine:fix-emoji-paste-firefox
Open

axelfontaine wants to merge 5 commits into
omacom:quattrofrom
axelfontaine:fix-emoji-paste-firefox

Conversation

@axelfontaine

@axelfontaine axelfontaine commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Now works reliably on

  • GTK
  • Qt6
  • Terminals
  • Chromium
  • Firefox (previously broken)
  • VS Code
  • IntelliJ

With

  • keyboard
  • mouse (previously broken)

Fixes

Supersedes

What changed

omarchy-menu-emoji-insert used to copy the emoji to a transient clipboard and simulate Shift+Insert for every app. It now types the emoji with wtype in terminals and pastes it (transient --sensitive clipboard + synthetic Ctrl+V) everywhere else. The picker also records which window was focused when it opened and re-focuses it before inserting.

Why — insertion method

The old copy-and-paste approach relied on the focused app treating Shift+Insert as "paste clipboard". That breaks:

  • Firefox silently ignores a synthetic Shift+Insert. A manual one pastes fine, and a synthetic Ctrl+V / Ctrl+Shift+V both work — but the wtype-generated Shift+Insert does nothing, so the emoji never lands.
  • No single paste shortcut covers everything. Ctrl+Shift+V (cf. Fix emoji paste in Firefox #6892) fixes Firefox and terminals but is unbound in Qt text widgets, so it misses omawrite and other Qt apps. Ctrl+V misses terminals. Sending two shortcuts double-pastes in apps that accept both.
  • Typing the emoji doesn't work in Chromium / Electron apps (Chrome, VS Code, Slack, Discord…). They ignore the transient keymap wtype uses for Unicode, so a typed emoji never arrives — those need a real clipboard paste.

So no single method works everywhere. The helper splits on the same terminal window tag omarchy's universal-paste keybind already uses (default/hypr/bindings/clipboard.lua): terminals get the emoji typed (clipboard and primary selection stay untouched); everything else gets a transient --sensitive clipboard offer + synthetic Ctrl+V, withdrawn straight after.

Why — origin window

The picker is a fullscreen layer holding exclusive keyboard focus. When it closes, follow_mouse hands focus to whichever window is under the (centred) cursor — so an emoji chosen by mouse click was inserted into the wrong window (with the picker straddling two windows, left-side emoji → left window, right-side → right window). Emojis.qml now captures Hyprland.activeToplevel.address in open() and passes it to the helper, which re-focuses that window with hl.dsp.focus({ window = "address:…" }) (the classic dispatch focuswindow form is routed through the Lua dispatcher and errors on current Hyprland) and polls activewindow until it sticks before inserting. No address (keyboard-only, nothing focused) → unchanged behaviour.

Testing

  • bash test/shell.d/emojis-test.sh — covers the terminal/GUI split, clipboard handling, address normalisation, the refocus loop, and the no-argument path.
  • Manually verified an emoji, a ZWJ sequence (👨‍👩‍👧) and a flag (🇺🇸) insert correctly — via both keyboard and mouse selection, including the picker straddling two windows — in foot, Firefox, Chromium, omawrite (Qt6), Nautilus (GTK) and IntelliJ.

Fixes #7350

Fixes #7379

Copilot AI balanced review requested due to automatic review settings August 27, 2026 11:53

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Replaces clipboard-based emoji pasting with direct wtype input.

Changes:

  • Types selected emojis directly.
  • Updates tests for typing and empty input.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 1 out of 2 changed files in this pull request and generated no comments.

File Description
bin/omarchy-menu-emoji-insert Replaces clipboard staging with direct typing.
test/shell.d/emojis-test.sh Updates helper behavior tests.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@axelfontaine
axelfontaine force-pushed the fix-emoji-paste-firefox branch 2 times, most recently from 2a661fb to 4315389 Compare August 27, 2026 12:25
@axelfontaine axelfontaine changed the title Type inserted emojis instead of pasting them Type inserted emojis into the picker's origin window Aug 27, 2026
@axelfontaine axelfontaine changed the title Type inserted emojis into the picker's origin window Fix Emoji Picker for all apps with both keyboard and mouse Aug 27, 2026
@axelfontaine
axelfontaine force-pushed the fix-emoji-paste-firefox branch from 4315389 to cc260c9 Compare August 27, 2026 16:25
@axelfontaine axelfontaine changed the title Fix Emoji Picker for all apps with both keyboard and mouse Insert emojis by typing or pasting, into the picker's origin window Aug 27, 2026
@axelfontaine axelfontaine changed the title Insert emojis by typing or pasting, into the picker's origin window Fix Emoji Picker for all apps with both keyboard and mouse Aug 27, 2026

@johnpippett johnpippett left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I tested the insert helper at commit cc260c9a740d8c504dd75df52c6b9090e2b0da58 with command stubs.

In bin/omarchy-menu-emoji-insert, lines 32–36, the loop ends after 15 focus requests even if the original window is not active. The helper then sends the emoji to the active window. This can cause the wrong-window insertion reported in #7350.

In my isolated test, the target was 0xdeadbeef, and hyprctl activewindow always returned 0x0. The helper sent 15 focus requests and then called wtype once. The first test in this PR also keeps the active address different from the target, but it expects insertion.

Please check the active address after the retry loop. If it does not match the target, stop without typing or pasting. Please add a test that requires no insertion when focus cannot return to the original window.

This test covers the helper's failure path. I did not run the picker in a graphical session.

@tnperron

Copy link
Copy Markdown

Independent check of the paste half, on Omarchy 4.0.4-1 / Firefox 155.0.1, native Wayland.

This comment is posted by an AI coding agent (Grok), through GitHub account @tnperron, at the account owner's request. I am not opening another pull request.

On a Firefox contenteditable, stock wtype Shift+Insert never fired a paste. The page only saw keydown for Insert with shift held, and the text did not change, even while the clipboard offer was still up. wtype Ctrl+V fired insertFromPaste and inserted ™️. Killing the sensitive wl-copy --foreground process 0.2s after that Ctrl+V still left the character in the field.

In foot (window tag terminal), Shift+Insert still pasted, so a blanket Ctrl+V would be the wrong chord there. The terminal-versus-everything-else split in this PR matches that result.

I have not run this branch, so this does not cover the origin-window refocus path.

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed at cc260c9 by reading the diff against current quattro. Nothing was run on a worker, for the reason below.

It competes with #6892 on the paste half. #6892 (opened 2026-08-14) fixes the same Firefox failure the same way — Ctrl+V outside terminal-tagged windows, the same split default/hypr/bindings/clipboard.lua uses — and has already been verified and marked ready. The older fix wins when the two are similar, so this one is not being verified or marked ready alongside it; two ready fixes to one file would only conflict. #12377 is a third take on the same chord.

The refocus half is separate work that #6892 does not do (#7350, #7379: a mouse-picked emoji landing in the window under the cursor). Two things about it:

Switching terminals from a paste to typing the emoji with wtype is not needed for either bug, and it widens what this change touches.

No second opinion: the configured reviewer, Codex Medium, refused to run because its daily review budget was spent. This is one model's reading.

Waiting on the maintainer to choose between this and #6892. If the refocus fix still reproduces on current quattro, it would land most easily as its own pull request on top of whichever paste fix is merged.

axelfontaine added a commit to axelfontaine/omarchy that referenced this pull request Oct 5, 2026
The retry loop that waits for the picker's origin window to regain
focus gave up silently after 15 attempts and fell through to typing
or pasting into whatever was focused instead -- exactly the
wrong-window bug (omacom#7350) this change set out to fix. Confirmed by
@johnpippett's review on PR omacom#8573.

Stop without inserting when the origin window never comes back, and
cover the failure path with a test (the previous first test
inadvertently relied on the bug: it never set the active window to
the target address, so it was only passing because of the fallthrough
insert).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@greptile-apps

greptile-apps Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable issue remains.

Summary

The picker saves the original window and restores its focus before inserting an emoji.

  • Emoji selections return to the window where the picker opened.
  • Emoji insertion types in terminals and pastes in other apps.

Reviews (4) · Last reviewed commit: "Wait for the clipboard before the emoji ..." · Reviewed by Greptile

Comment thread shell/plugins/emojis/Emojis.qml Resolved
Comment thread test/shell.d/emojis-test.sh Resolved
axelfontaine added a commit to axelfontaine/omarchy that referenced this pull request Oct 5, 2026
The retry loop that waits for the picker's origin window to regain
focus gave up silently after 15 attempts and fell through to typing
or pasting into whatever was focused instead -- exactly the
wrong-window bug (omacom#7350) this change set out to fix. Confirmed by
@johnpippett's review on PR omacom#8573.

Stop without inserting when the origin window never comes back, and
cover the failure path with a test (the previous first test
inadvertently relied on the bug: it never set the active window to
the target address, so it was only passing because of the fallthrough
insert).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@axelfontaine
axelfontaine force-pushed the fix-emoji-paste-firefox branch from 86381b2 to 22279d1 Compare October 5, 2026 14:18
@axelfontaine

Copy link
Copy Markdown
Contributor Author

Rebased onto current quattro (so this now runs on the OverlayWindow picker from #13419) and addressed the open review points.

Greptile P1, stale window receives emoji: fixed in 052453e. Checking it live showed two sources, not one. The picker's own last-seen-address fallback, and Quickshell itself: after Hyprland reports no focused window (activewindowv2>> on an empty workspace), Hyprland.activeToplevel keeps the previous window, still activated=true. The fallback is gone, and the active window is only taken as the origin when it sits on Hyprland.focusedWorkspace. Otherwise no origin is passed. Verified on a dev-linked session: picking an emoji on an empty workspace no longer pulls focus back to a window on another workspace or inserts into it.

Greptile P2, clipboard flags untested: fixed in 22279d1. The wl-copy mock records its arguments and the test asserts --type text/plain --sensitive --foreground, plus the exact -M ctrl -P v -p v -m ctrl chord. Removing --sensitive now fails the suite.

@omarchybot, does #7350 still reproduce on the overlay picker? On current quattro, with this branch dev-linked, I watched Hyprland's event socket across picks in foot, Firefox, Chromium and a scratchpad window, by both keyboard and mouse. In every case closing the picker handed focus straight back to the window that was focused before (activewindowv2>> then the origin address within ~2 ms), even with the pointer over a different window. Since the surface now stays mapped, its close no longer leaves focus to follow_mouse. So #7350 does not appear to reproduce on quattro any more, and the refocus loop rarely has work to do. I've kept it as a guard. Focus can still move if the mouse moves in the ~0.15–0.35 s before the insert, and if the origin window is gone the helper now stops instead of inserting elsewhere (bcdaf02, live-checked with a nonexistent address). A window on a special workspace isn't on focusedWorkspace, so a scratchpad pick goes through the no-origin path. Focus is back on the scratchpad window by then, and the emoji landed there in testing.

Overlap with #6892: the non-terminal half (synthetic Ctrl+V on a transient --sensitive clipboard offer, split on the terminal tag) is the same fix. If #6892 lands first, I'm happy to rebase this onto it. What would remain is the origin-window guard and typing into terminals. Typing with wtype in terminals isn't strictly needed for the Firefox bug, but it keeps the clipboard and primary selection untouched in the one place where the paste chord differs. I can drop it if a smaller change is preferred.

@johnpippett johnpippett left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@axelfontaine, thank you for the update. My earlier concern is fixed. I recommend no further change to the helper.

Result

The helper now checks the active window after the retry loop. If the original window is not active, the helper stops. It does not call wtype or wl-copy.

Tested commit

22279d11fbe8658f77eb4bf402b3a8fdf4cc4b8f, on top of quattro at 81145eb1fd41532fcae4310b26f860608e2eaf82. Claude Code did these checks.

Checks and environment

Claude Code ran bin/omarchy-menu-emoji-insert with command stubs for hyprctl, wtype, wl-copy, and sleep. The checks did not use a graphical session.

  • The target was 0xdeadbeef. hyprctl activewindow -j always returned 0x0. The helper sent 15 focus requests. It made no wtype call and no wl-copy call. The exit status was 0.
  • The result was the same when another window was active (0x1234).
  • Focus returned after 5 requests. The helper stopped the retry loop and typed once in a terminal. In a non-terminal window, it called wl-copy --type text/plain --sensitive --foreground and then wtype -M ctrl -P v -p v -m ctrl.
  • Focus returned after 14 requests. The helper typed once. Focus returned after 16 requests. The helper made no insertion.
  • With no window address, the helper sent no focus request. It typed in a terminal and pasted in other windows.
  • env -i HOME=$HOME PATH=/usr/bin:/bin:<node dir> bash test/shell.d/emojis-test.sh passed all 24 checks. No check was skipped. The node directory is only in PATH because node is installed under mise.
  • Claude Code deleted the post-loop [[ $(active_address) == "$target" ]] || exit 0 line on a scratch copy. The test emoji insert helper does not type into the wrong window when the origin never returns then failed. The new test therefore guards the fix. The file was then restored.

Remaining concerns

These concerns are minor. None of them blocks the merge.

  • When the helper stops, it exits with status 0 and shows no message. A user sees no emoji and no reason.
  • The helper checks the active address, and later is_terminal queries it again. A focus change between the two queries is possible but unlikely.
  • If Hyprland.activeToplevel.workspace is not set, Emojis.qml passes no origin. The helper then uses the old behavior and inserts into the active window. This case seems rare.
  • The failure test uses 0xothertarget as the active address. The 0x0 case above behaves the same way.
  • I see that #6892 also changes the emoji paste. The maintainers can decide how the two pull requests relate. This is not part of my review.

Untested behavior

  • Claude Code read the Emojis.qml change in open(). It uses Hyprland.activeToplevel as the origin only when it is on Hyprland.focusedWorkspace. The logic looks correct. It was not run.
  • I did not run the graphical picker.
  • I did not test real Hyprland focus changes, follow_mouse, or multiple monitors.
  • I did not test whether #7350 reproduces on the new OverlayWindow picker.

I prepared this comment with help from AI tools.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for the rebase and the live checks. Reviewed again at 22279d1 by reading it against current quattro. Nothing was run on a worker, for the reason below. Both points from the last review are addressed: the helper now stops when the origin window never becomes active again (line 41), and that path is tested.

The paste half is still the same fix as #6892, which is older and already verified and marked ready: a transient --sensitive clipboard offer and synthetic Ctrl+V outside windows tagged terminal. When two fixes are this close, the older one wins, so this one is not being verified or marked ready alongside it. #12377 is a third take on the same chord.

What this adds beyond #6892 is two things, and neither is needed for the Firefox paste failure (#8206):

  • Typing into terminals instead of pasting. This leaves the clipboard and primary selection untouched. That is a behaviour change worth considering on its own, but it is not part of the bug fix.
  • Refocusing the window the picker opened from. Your finding holds against the source. On quattro, shell/Ui/OverlayWindow.qml keeps the picker mapped and sets its keyboard focus to None when hidden, so Hyprland hands focus back to the previously focused window rather than to the one under the cursor. That leaves the guard one narrow case: the origin window closes while the picker is open, and the helper then stops instead of pasting into whatever took focus. If it lands, the comment at bin/omarchy-menu-emoji-insert lines 25–30 should be updated, because it still says follow_mouse hands focus to the window under the cursor, which is no longer what happens.

Codex Medium was the second opinion and read all three pull requests. It agreed that this one is not clearly better than #6892 on the paste half. From the source, it also agreed that closing the picker on quattro returns focus to the original window. Its agreement is not guaranteed to be independent. It found no regression that this diff introduces.

Waiting on the maintainer, who chooses between the paste fixes. If they want the terminal typing or the origin guard, those would land most easily as their own small pull request on top of whichever paste fix merges, as you offered.

axelfontaine and others added 5 commits October 28, 2026 07:10
The picker copied the emoji to a transient clipboard and simulated
Shift+Insert. Firefox silently ignores a synthetic Shift+Insert (a manual
one works, and synthetic Ctrl+V works), so the emoji never landed there.

There is no one insertion method that works everywhere. Typing the emoji
with wtype works in terminals, Firefox, GTK and Qt, but Chromium- and
Electron-based apps ignore the transient keymap wtype uses for Unicode, so
nothing arrives. A clipboard paste works in all of those GUI apps, but no
single paste shortcut covers terminals too: Ctrl+V is not paste in a
terminal, Ctrl+Shift+V is unbound in Qt.

Split on the same "terminal" window tag omarchy's universal paste keybind
uses (default/hypr/bindings/clipboard.lua). Terminals get the emoji typed,
which also keeps the clipboard and primary selection untouched. Everything
else gets a transient, --sensitive clipboard offer and a synthetic Ctrl+V,
the offer withdrawn straight after. Verified across foot, Firefox,
Chromium, omawrite (Qt), Nautilus (GTK) and IntelliJ, including ZWJ and
flag sequences, with both keyboard and mouse selection.

The picker is a fullscreen layer holding exclusive keyboard focus. When it
closes, follow_mouse hands focus to whichever window is under the centred
cursor, so a mouse-picked emoji went to the wrong window (or none).
Emojis.qml now records the focused window when the picker opens and passes
its address to the helper, which re-focuses that window - via
hl.dsp.focus({ window = "address:..." }), the form that works on current
Hyprland - and confirms it stuck before inserting.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Q3j2dwT3VnQ7wr9XJUexoK
The retry loop that waits for the picker's origin window to regain
focus gave up silently after 15 attempts and fell through to typing
or pasting into whatever was focused instead -- exactly the
wrong-window bug (omacom#7350) this change set out to fix. Confirmed by
@johnpippett's review on PR omacom#8573.

Stop without inserting when the origin window never comes back, and
cover the failure path with a test (the previous first test
inadvertently relied on the bug: it never set the active window to
the target address, so it was only passing because of the fallthrough
insert).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Opening the picker on an empty workspace targeted a window the picker had
seen earlier, so picking an emoji pulled focus back to that window's
workspace and inserted it there. Two things kept the stale window: the
picker's own last-seen-address fallback, and Quickshell itself, which keeps
Hyprland.activeToplevel (still "activated") after Hyprland reports no
focused window. Drop the fallback and only take the active window as the
origin when it sits on the focused workspace; otherwise pass no origin.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@axelfontaine
axelfontaine force-pushed the fix-emoji-paste-firefox branch from 22279d1 to 94704bb Compare October 28, 2026 06:13
Comment thread shell/plugins/emojis/Emojis.qml Resolved
@axelfontaine

Copy link
Copy Markdown
Contributor Author

@greptile-apps Update your confidence score

@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed again at 94704bb, read against current quattro. The rebase leaves the helper and Emojis.qml as they were at 22279d1. The new commit only makes the test's wtype stub wait for the clipboard stub, and nothing on quattro since then touches these files. Nothing was run on a worker this time, for the reason below.

A correction to the last review here. It said closing the picker on quattro hands focus back to the original window, and that the comment at bin/omarchy-menu-emoji-insert lines 25–30 was out of date. Both were wrong. Since #14458 the overlay unmaps again when it closes, and follow_mouse then focuses the window under the pointer. #7350 and #7379 both reproduced on quattro on a worker, and this branch fixed both in the same runs (details on #7350). The comment in the helper describes what happens.

The paste half still loses to #6892. Both send Ctrl+V from a transient --sensitive clipboard offer outside windows tagged terminal, and #6892 is older. The description's point about Qt doesn't apply to #6892 as it stands: it sends Ctrl+Shift+V only to terminals and Ctrl+V to everything else, Qt included. #12377 doesn't touch the emoji helper.

The refocus half fixes a separate bug that #6892 does not. Three things about it, from reading the source:

  • After the last check that the origin window is active, the non-terminal path still waits 0.15 s before Ctrl+V. If focus moves in that gap, the emoji goes to the wrong window. The race is narrow, and it is the same one noted on Emoji picker inserts into the wrong window when the card spans two windows #7350.
  • A window on a special workspace (the scratchpad) is never recorded as the origin. Quickshell's Hyprland.focusedWorkspace is the focused monitor's regular active workspace (connection.cpp binds it to activeWorkspace, and nothing there handles activespecial), so the === check in open() fails. A mouse pick from the scratchpad therefore behaves as it does on quattro today. That leaves a gap but breaks nothing. It does differ from the inline reply about special workspaces.
  • Typing the emoji into terminals is a third change, needed for neither bug. It also gives up bracketed paste. An editor in normal mode, Vim for example, receives keystrokes rather than literal pasted text.

#16537 rewrites the same paste line to send keys through Hyprland for XWayland apps, so whichever of these lands first, the others will need a rebase.

Codex Medium and muse-wonder (pi, high effort) were the second opinion and were given all three pull requests. Both chose #6892 for the paste fix. Both called the refocus a distinct bug fix worth landing on its own, and both raised the race and the terminal typing. Codex raised the special-workspace gap, which I checked against Quickshell's source. Their agreement with each other is not guaranteed to be independent.

Waiting on the maintainer, who chooses between the paste fixes. @axelfontaine, you offered to cut this down. A version with only the origin-window refocus, on top of #6892 or without the paste change, would no longer compete with it and could be verified on its own.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

When using mouse on the Emoji Picker, emoji isn't shown anywhere Emoji picker inserts into the wrong window when the card spans two windows

5 participants