swaywm / sway

i3-compatible Wayland compositor
https://swaywm.org
MIT License
14.72k stars 1.11k forks source link

zwlr_layer_surface_v1::keyboard_interactivity v4 #7499

Open WhyNotHugo opened 1 year ago

WhyNotHugo commented 1 year ago

This is a feature request for zwlr_layer_surface_v1::keyboard_interactivity v4::on_demand:

This requests the compositor to allow this surface to be focused and unfocused by the user in an implementation-defined manner. The user should be able to unfocus this surface even regardless of the layer it is on.

Typically, the compositor will want to use its normal mechanism to manage keyboard focus between layer shell surfaces with this setting and regular toplevels on the desktop layer (e.g. click to focus). Nevertheless, it is possible for a compositor to require a special interaction to focus or unfocus layer shell surfaces (e.g. requiring a click even if focus follows the mouse normally, or providing a keybinding to switch focus between layers).

This setting is mainly intended for desktop shell components (e.g. panels) that allow keyboard interaction. Using this option can allow implementing a desktop shell that can be fully usable without the mouse.

I think a suitable implementation for sway is to handle focus like a a floating window (e.g.: same mouse rules and same mapping to toggle focus).

If the previous state was exclusive, it initially has focus, if its previous state was none, it does not.

WhyNotHugo commented 1 year ago

In particular, I want to use this for shotman, which uses this protocol.

WhyNotHugo commented 1 year ago

I think wlroots supports it: https://gitlab.freedesktop.org/wlroots/wlroots/-/commit/45c0877e3433f2b057f9125a8bc735057e088e6c

trinitronx commented 1 year ago

Adding a +1 to this, given that the following PRs have made it into wl-protocols, wlroots, & gtk-layer-shell:

Note: FWIW, there is also one for wayfire: WayfireWM/wayfire#962

Testing the quick gtk-layer-shell demo program (examples/gtk-layer-demo) on Sway 1.8.1 seems to still have non-ideal behavior when setting the "On Demand" keyboard mode (--keyboard o) and either "Top" or "Overlay" layers (--layer t or --layer o).

When on these layers, it's impossible to get keyboard focus off of the demo program window without first setting keyboard setting back to "None". Not ideal from a UI/UX perspective, nor from an app developer perspective given the protocol's promise of an "On Demand" keyboard mode versus "Exclusive".

trinitronx commented 1 year ago

Notes:

EDIT: I just tested building from source each package. I can confirm that the gtk-layer-shell demo behaves properly on latest sway + wlroots git branches:

00:00:00.000 [INFO] [sway/main.c:338] Sway version 1.9-dev-dc634c4a (Jul 23 2023, branch 'master')
00:00:00.000 [INFO] [sway/main.c:339] wlroots version 0.17.0-dev

Unless this gets backported to the 1.8 branch, users expecting the "On Demand" keyboard focus behavior will have to wait until newer packages of sway are released.