Skip to content

wayland: Fix workspace bounce-back on click for Hyprland - #341

Open
b2l wants to merge 2 commits into
rvaiya:masterfrom
b2l:waybar-workspace-fixes
Open

wayland: Fix workspace bounce-back on click for Hyprland#341
b2l wants to merge 2 commits into
rvaiya:masterfrom
b2l:waybar-workspace-fixes

Conversation

@b2l

@b2l b2l commented Apr 30, 2026

Copy link
Copy Markdown

Summary

  • When clicking on waybar (or other layer surfaces) to switch workspaces via warpd, the workspace would switch then immediately bounce back to the original one
  • Root cause: way_mouse_click() destroyed and recreated the input surface with exclusive keyboard interactivity, causing Hyprland to steal focus back
  • Fix: replace the destroy/recreate cycle with toggling keyboard interactivity (EXCLUSIVENONEEXCLUSIVE) on the existing surface, plus a short delay before re-enabling exclusivity to let the compositor finish processing the click

Test plan

  • Click on waybar workspace buttons via warpd hint mode — workspace should switch without bouncing back
  • Regular clicks (non-workspace-changing) still work correctly
  • Drag operations still work (mouse_down/mouse_up path unchanged)
  • Test on Sway or other wlroots compositors for regressions

🤖 Generated with Claude Code

b2l and others added 2 commits April 30, 2026 09:40
Hyprland requires layer surfaces to declare their actual size via
set_size — the previous hardcoded 10x10 caused surfaces to be
invisible. Use the actual requested dimensions instead.

Set empty input regions on visual surfaces (hints, cursor boxes) so
virtual pointer events pass through to the target window.

Hyprland routes virtual pointer events to the keyboard-exclusive
surface, preventing clicks from reaching the target. Work around this
by temporarily destroying and recreating the input surface around
each click.

Fix discover_pointer_location reliability by committing the virtual
pointer frame and using wl_display_roundtrip to ensure the compositor
processes each motion event.

Fix way_input_ungrab_keyboard hanging on Hyprland — the original code
waited for keyboard focus to return to another warpd surface, but no
such surface exists after the input surface is destroyed.

Note: virtual pointer scroll and drag events have the same
keyboard-exclusive routing issue but are not addressed here.

Note 2: honnestly I don't know much about the topic and heavily used
Claude Code to get the fix I wanted.
I'll be happy to rework the PR if you want :)
When clicking on waybar to switch workspaces, the previous
destroy/recreate cycle for the input surface caused Hyprland to
steal focus back, bouncing to the original workspace.

Replace ungrab/regrab with suspend/resume that toggles keyboard
interactivity on the existing surface, avoiding the surface
lifecycle churn. A short delay before resuming exclusivity gives
the compositor time to process click side-effects.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@abneb

abneb commented Aug 12, 2026

Copy link
Copy Markdown

@b2l hey man, is your branch working fine with hyprland?

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants