Skip to content

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

Open
benny-e wants to merge 4 commits intodavatorium:nextfrom
benny-e:wayland-click-to-close
Open

wayland: implement click-to-exit support using fullscreen capture surface#2272
benny-e wants to merge 4 commits intodavatorium:nextfrom
benny-e:wayland-click-to-close

Conversation

@benny-e
Copy link

@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.

benny-e added 2 commits March 8, 2026 18:38
Add state used by the Wayland backend to support click-to-exit
behavior.

When click-to-exit is enabled, the Wayland backend uses a fullscreen
surface to receive pointer events outside the visible rofi menu. To
support this, track both the fullscreen surface geometry and the
visible menu rectangle so pointer handling and rendering code can
distinguish between the two.
When click-to-exit is enabled on Wayland, use a fullscreen transparent
surface so rofi can receive pointer events outside the visible menu.

The menu itself keeps its normal size and theme-driven placement
inside that surface. Rendering is translated to the menu rectangle so
themes and placement options behave the same as in normal mode.

When click-to-exit is disabled, the Wayland backend keeps the existing
menu-sized surface behavior.
@benny-e benny-e force-pushed the wayland-click-to-close branch from 68a1d4d to 739d1a8 Compare March 9, 2026 23:39
@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
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

@lbonn
Copy link
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
Handle click-to-exit natively in the Wayland pointer path.

When capture mode is enabled, pointer events are compared against the
visible menu rectangle. Pointer presses outside that rectangle cancel
the active view, while inside clicks continue through the normal
widget event path.

This allows click-to-exit to work on Wayland without compositor-side
scripts or hacks.

Fix doxygen and remove stray comment
Seperated outside-click handling into its own function
@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
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

@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
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
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

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