Skip to content

Fix emoji picker inserting into the wrong window on split layouts (#7350) - #7351

Closed
Guts444 wants to merge 1 commit into
omacom:quattrofrom
Guts444:fix/emoji-insert-focus
Closed

Guts444 wants to merge 1 commit into
omacom:quattrofrom
Guts444:fix/emoji-insert-focus

Conversation

@Guts444

@Guts444 Guts444 commented Aug 18, 2026

Copy link
Copy Markdown

Summary

Fixes #7350 — the emoji picker types the picked emoji into the wrong window whenever the picker card visually spans two windows (split layouts, side-by-side monitors).

Root cause: Emojis.qml's applySelected() dismisses the overlay and then runs bin/omarchy-menu-emoji-insert, which pastes with wtype Shift+Insert into whatever window is focused at that moment. Once the overlay closes, the compositor refocuses whichever window sits under the clicked cell — so clicking an emoji on the half of the card over the other window pastes it there (e.g. into a browser's address bar) instead of in the window the user was typing in.

Fix:

  • shell/plugins/emojis/Emojis.qml — when the picker opens, capture the address of the active window (hyprctl -j activewindow, via a one-shot Process), and pass it to the insert helper alongside the emoji.
  • bin/omarchy-menu-emoji-insert — accept an optional second argument (focus address) and dispatch focus back to that window (hl.dsp.focus({ window = "address:…" }), the same form already used in Workspaces.qml) before pasting. With no address given, behavior is unchanged, so the command stays usable standalone.
  • test/shell.d/emojis-test.sh — new coverage: the helper skips the focus restore when called without an address, and issues the correct dispatch when given one.

Related

I did not touch the clipboard lifecycle (the wl-copy --foreground + kill dance). That is deliberate: git history shows the transient clipboard is intentional (Insert emojis without persisting clipboard entries, Keep sensitive clipboard contents out of history), even though it confuses users who expect the emoji to remain pasteable after insert (#7233). Happy to address that separately if the maintainers want to reconsider.

Test plan

  • test/all — all emoji tests pass; the only failures (config-test, snapper-test, unowned-system-paths-test) also fail on a clean quattro checkout on this machine (environment-specific, unrelated).
  • Live verification on the reporter's machine: user plugin clone of the emojis plugin running the exact patched files. Clicking emojis on the half of the card over the other window now inserts into the window that was focused when the picker opened (verified with the reporter on two layouts: tiled side-by-side windows and the same card geometry on a split).

Copilot AI balanced review requested due to automatic review settings August 18, 2026 03:52

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

Note

Copilot was unable to run its full agentic suite in this review.

Updates the emoji picker to refocus the window that was active when the picker opened, ensuring emoji insertion lands in the intended application (especially in split/multi-monitor layouts).

Changes:

  • Capture the active Hyprland window address on picker open and pass it to the insert helper.
  • Refocus the captured window in omarchy-menu-emoji-insert before pasting.
  • Extend shell tests with a hyprctl stub and focus-restore assertions.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 5 comments.

File Description
test/shell.d/emojis-test.sh Adds a hyprctl stub and validates focus-restore behavior in the helper script.
shell/plugins/emojis/Emojis.qml Captures Hyprland active window address on open and passes it to the insert helper.
bin/omarchy-menu-emoji-insert Accepts optional focus address and refocuses via hyprctl before typing.

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

Comment on lines +71 to +74
cat >"$TMPDIR/bin/hyprctl" <<'SH'
#!/bin/bash
printf '%s\n' "$*" >>"$HYPRCTL_OUT"
SH

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in the amended head: the first invocation now sets HYPRCTL_OUT="$TMPDIR/hyprctl", so the guard assertion has teeth (same fix flagged by the human reviewer).

Comment thread test/shell.d/emojis-test.sh Outdated
chmod +x "$TMPDIR/bin/wl-copy" "$TMPDIR/bin/wtype" "$TMPDIR/bin/sleep"
chmod +x "$TMPDIR/bin/wl-copy" "$TMPDIR/bin/wtype" "$TMPDIR/bin/hyprctl" "$TMPDIR/bin/sleep"

WL_COPY_OUT="$TMPDIR/copy" WL_COPY_EMOJI_OUT="$TMPDIR/emoji" WTYPE_OUT="$TMPDIR/wtype" PATH="$TMPDIR/bin:$PATH" \

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in the amended head: the first invocation now sets HYPRCTL_OUT="$TMPDIR/hyprctl", so the guard assertion has teeth (same fix flagged by the human reviewer).


# With a focus address, the helper restores that window's focus before pasting.
# No hyprctl call is expected without one, so the stub stays empty here.
[[ ! -s "$TMPDIR/hyprctl" ]] || fail "emoji insert helper skips focus restore without a focus address"

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Addressed in the amended head: the first invocation now sets HYPRCTL_OUT="$TMPDIR/hyprctl", so the guard assertion has teeth (same fix flagged by the human reviewer).

Comment thread shell/plugins/emojis/Emojis.qml Outdated
}

function captureFocus() {
focusProbe.command = ["/usr/bin/hyprctl", "-j", "activewindow"]

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Fixed in 03a0d2d: the probe now invokes hyprctl via PATH, consistent with the rest of the shell (e.g. Workspaces.qml runs hyprctl dispatch … the same way).

Comment on lines 160 to 164
function applySelected(emoji) {
if (!emoji) return
root.dismiss()
Quickshell.execDetached([root.omarchyPath + "/bin/omarchy-menu-emoji-insert", emoji])
Quickshell.execDetached([root.omarchyPath + "/bin/omarchy-menu-emoji-insert", emoji, root.focusAddress])
}

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Rationale for keeping this as-is: captureFocus() now starts the probe before the overlay maps (it runs first thing in open()), so by the time the grid is visible and a user can physically click a cell (hundreds of ms later), the probe has long finished — the race is not humanly reachable. And if the probe ever yields nothing (hyprctl unavailable), the insert helper's own focus dispatch would fail identically, so the empty-address path degrades to exactly the pre-fix behavior. Queuing the emoji would add state for a case that cannot occur in practice.

Copilot AI review requested due to automatic review settings August 18, 2026 04:07
@Guts444
Guts444 force-pushed the fix/emoji-insert-focus branch from 80417e3 to 83d5b06 Compare August 18, 2026 04:07

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

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

Suppressed comments (1)

shell/plugins/emojis/Emojis.qml:65

  • Hard-coding /usr/bin/hyprctl reduces portability (systems where hyprctl is elsewhere, e.g., /run/current-system/sw/bin, or sandboxed environments). Prefer invoking hyprctl via PATH (e.g., \"hyprctl\") or making the binary path configurable so focus capture works across supported deployments.
    focusProbe.command = ["/usr/bin/hyprctl", "-j", "activewindow"]

The picker overlay closes before the insert helper runs, and the
compositor then refocuses whichever window sits under the clicked
cell. When the card spans two windows (split layout, multi-monitor),
the paste lands in that window instead of the one the user was in.

Capture the active window address when the picker opens and have the
insert helper restore focus to it before pasting. The helper keeps its
existing behavior when called without a focus address.
Copilot AI review requested due to automatic review settings August 18, 2026 04:14
@Guts444
Guts444 force-pushed the fix/emoji-insert-focus branch from 83d5b06 to 03a0d2d Compare August 18, 2026 04:14

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

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

Suppressed comments (1)

test/shell.d/emojis-test.sh:106

  • This assertion is brittle because the helper explicitly has a fallback path (... || hyprctl dispatch focuswindow ...). If the primary focus-restore command fails in real environments (which is plausible), the helper will execute an additional hyprctl call and the stub file will contain multiple lines, causing this test to fail even though behavior is correct. Consider either (a) asserting that the log contains at least one acceptable focus-restore command, or (b) splitting into two tests: one where the stub simulates success for the primary call and one where it simulates failure and verifies the fallback invocation.
[[ $(<"$TMPDIR/hyprctl") == 'dispatch hl.dsp.focus({ window = "address:0x1234abcd" })' ]] \
  || fail "emoji insert helper restores the focus captured at picker open"

@omarchybot

Copy link
Copy Markdown
Collaborator

Thanks for the detailed report and fix. I ran this on a worker VM built from the Omarchy ISO. Current quattro no longer has this bug, so this change is no longer needed.

What I ran. I opened two foot terminals tiled side by side, focused the left one and opened the emoji picker. Then I clicked emojis on the half of the card over the right terminal with a real (uinput) pointer. Each terminal wrote what it received to a file, so the check was which file the emoji landed in.

Why it went away. Your diagnosis was right for the code you wrote against. When the overlay unmapped, Hyprland's follow_mouse refocused the window under the pointer. Since 48de782, shell/Ui/OverlayWindow.qml keeps the overlay surface mapped. On close it drops the surface's keyboard focus to None instead of unmapping it. Hyprland then hands focus back to the window that had it before, so omarchy-menu-emoji-insert pastes where the user was typing.

Second opinion. Codex Medium reviewed the diff read-only. It agreed this is the proportionate fix for #7350, compared with #8573, which fixes the same issue but also changes how emojis are inserted. Its independence is not guaranteed. It flagged one defect in this PR: focusAddress is filled in by an asynchronous hyprctl probe and is never cleared on open, so a selection made before the probe returns passes the previous opening's address. It also raised, before I tested anything, that the overlay change on quattro might have changed the close behaviour. The worker runs above settled that. I didn't push a fix for the race, because the change it would harden is no longer needed.

test/shell.d/emojis-test.sh didn't run on the worker because the worker image has no node, so the test was skipped rather than passed.

This is now waiting on the maintainer. My recommendation is to close it, and #7350 with it, as fixed by 48de782. It would only be worth keeping as a guard if overlays go back to unmapping on close.

@omarchybot

Copy link
Copy Markdown
Collaborator

Thank you for this, @Guts444, and for the diagnosis, which was right. 48de782 (#13419) keeps the overlay mapped and hands focus back where it was, and a worker run confirmed the emoji now lands in the window you were typing in on current quattro, so this is no longer needed.

Closed at the maintainer's request. The review above has the details; it was done by Claude Opus 5.5 with Codex Medium as a second opinion, whose agreement is not independent.

@omarchybot omarchybot closed this Sep 28, 2026
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.

Emoji picker inserts into the wrong window when the card spans two windows

3 participants