Skip to content

wayland: implement click-to-exit support using fullscreen capture surface#2272

Merged
lbonn merged 1 commit intodavatorium:nextfrom
benny-e:wayland-click-to-close
Mar 20, 2026
Merged

wayland: implement click-to-exit support using fullscreen capture surface#2272
lbonn merged 1 commit intodavatorium:nextfrom
benny-e:wayland-click-to-close

Conversation

@benny-e
Copy link
Copy Markdown
Contributor

@benny-e benny-e commented Mar 8, 2026

This PR implements native click-to-exit support for rofi's Wayland backend.

On Wayland, rofi cannot receive pointer events outside its surface, so
click-to-exit does not work when the surface only matches the visible
menu size. This patch addresses that by using a fullscreen transparent
surface when click-to-exit is enabled.

The visible menu keeps its normal size and theme-driven placement
inside that fullscreen surface. Pointer events are compared against the
visible menu rectangle so inside clicks continue through the normal
widget path, while outside clicks cancel the active view.

When click-to-exit is disabled, existing Wayland behavior remains
unchanged.

Fixes #2158

Tested with:

  • rofi -dmenu -no-config -no-click-to-exit
  • rofi -dmenu -no-config -click-to-exit
  • rofi -show drun -no-click-to-exit
  • rofi -show drun -click-to-exit

Also tested with non-centered placement to verify that theme-driven
positioning is preserved in capture mode.

Tested on Hyprland and Sway with single and multi-monitor setups. Outside clicks close as expected, including clicking on another monitor.

Comment thread source/wayland/view.c Outdated
@benny-e benny-e force-pushed the wayland-click-to-close branch from 68a1d4d to 739d1a8 Compare March 9, 2026 23:39
Comment thread source/wayland/view.c Outdated
@benny-e benny-e force-pushed the wayland-click-to-close branch from 739d1a8 to 6f6aea8 Compare March 10, 2026 23:40
@lbonn
Copy link
Copy Markdown
Collaborator

lbonn commented Mar 11, 2026

@benny-e thanks a lot for working on this. I haven't been able to test it yet but will try to do so this week

Comment thread source/wayland/view.c Outdated
Comment thread source/wayland/view.c Outdated
Comment thread source/wayland/view.c Outdated
Comment thread source/wayland/view.c
@lbonn
Copy link
Copy Markdown
Collaborator

lbonn commented Mar 11, 2026

Apart from the outside-monitor parts being clipped, it is working as advertised :)

@benny-e benny-e force-pushed the wayland-click-to-close branch 2 times, most recently from 00a2ccd to 026f3a3 Compare March 12, 2026 00:56
Comment thread source/wayland/display.c Outdated
Comment thread source/wayland/display.c Outdated
Comment thread include/view.h Outdated
Comment thread include/view.h Outdated
@benny-e benny-e force-pushed the wayland-click-to-close branch from 026f3a3 to cf8d37a Compare March 13, 2026 01:22
@benny-e
Copy link
Copy Markdown
Contributor Author

benny-e commented Mar 13, 2026

removed the stray stdio.h include
removed the Wayland-specific declarations from view.h
moved get_menu_rect behind _view_proxy

Comment thread include/view.h
Comment thread include/view-internal.h Outdated
@DaveDavenport DaveDavenport marked this pull request as draft March 13, 2026 13:17
@benny-e benny-e marked this pull request as ready for review March 14, 2026 15:56
@lbonn
Copy link
Copy Markdown
Collaborator

lbonn commented Mar 17, 2026

@benny-e thanks, I think it's close to a mergeable state.

Do you mind if I squash all these changes in one commit with a meaningful message?
You can also do it yourself if you prefer.

@benny-e
Copy link
Copy Markdown
Contributor Author

benny-e commented Mar 17, 2026

@benny-e thanks, I think it's close to a mergeable state.

Do you mind if I squash all these changes in one commit with a meaningful message?

You can also do it yourself if you prefer.

Great! I don't mind, feel free to squash

@lbonn lbonn force-pushed the wayland-click-to-close branch from 0ee59af to 544ecc4 Compare March 19, 2026 18:30
Click to exit is implemented using a fullscreen transparent surface
to capture pointer events outside the visible menu.

It has limitations with regard to multi-monitor setup but works well
enough in the common case.
@lbonn lbonn force-pushed the wayland-click-to-close branch from 544ecc4 to e58d1cf Compare March 19, 2026 18:49
@lbonn lbonn merged commit 6d2a528 into davatorium:next Mar 20, 2026
7 checks passed
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.

[REQUEST] Ability to close rofi on outside click.

2 participants