sway/protocols/meson.build
Michael Weiser d4482400f1 swaybar: Implement pointer gesture swipe support
After previous commits, swaybar bindsym statements would already accept
the new pseudo button names for swipe gestures. Also, sway itself would
not handle swipes when executed while the pointer was above a bar.

Add the necessary handling for three- and four-finger swipe pointer
gestures in swaybar. Cancel ongoing swipes when the pointer leaves the
bar as to not confuse successive swipes with focus changes inbetween
them.  Add the pointer gestures protocol in client and server variants
to the meson build file to make the necessary definitions available.
Bind to the global interface on startup, instantiate a swipe gesture and
add a listener on seat setup as well as destroy it on seat shutdown.

Extend the sway-bar manual page as necessary.

Test-plan:
- add workspace switching to config like so:

bar bar-0 {
        swaybar_command swaybar

        bindsym release SWIPE_3_LEFT workspace prev_on_output
        bindsym release SWIPE_4_RIGHT workspace next_on_output
        bindsym --release SWIPE_3_LEFT exec yad --text foo
        bindsym --release SWIPE_4_UP exec yad --text bar
}

- start sway and open two workspaces
- position pointer above a bar surface
- switch back and forth using horizontal three- and four-finger swipes,
  observing that different finger counts are necessary per direction
- observe that the --release binding for left swipes is ignored because
  there is an on-press binding already
- observe that the --release binding for upward swipes is honoured
  because there is no on-press binding
- move pointer away from bar surface
- observe that switching by swipe no longer works

Signed-off-by: Michael Weiser <michael.weiser@gmx.de>
2021-08-05 20:10:07 +02:00

82 lines
2.4 KiB
Meson

wl_protocol_dir = wayland_protos.get_variable(pkgconfig: 'pkgdatadir')
wayland_scanner_dep = dependency('wayland-scanner', required: false, native: true)
if wayland_scanner_dep.found()
wayland_scanner = find_program(
wayland_scanner_dep.get_variable(pkgconfig: 'wayland_scanner'),
native: true,
)
else
wayland_scanner = find_program('wayland-scanner', native: true)
endif
protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/pointer-constraints/pointer-constraints-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/tablet/tablet-unstable-v2.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['idle.xml'],
['wlr-input-inhibitor-unstable-v1.xml'],
['wlr-output-power-management-unstable-v1.xml'],
]
client_protocols = [
[wl_protocol_dir, 'stable/xdg-shell/xdg-shell.xml'],
[wl_protocol_dir, 'unstable/xdg-output/xdg-output-unstable-v1.xml'],
[wl_protocol_dir, 'unstable/pointer-gestures/pointer-gestures-unstable-v1.xml'],
['wlr-layer-shell-unstable-v1.xml'],
['wlr-input-inhibitor-unstable-v1.xml'],
]
wl_protos_src = []
wl_protos_headers = []
foreach p : protocols
xml = join_paths(p)
wl_protos_src += custom_target(
xml.underscorify() + '_server_c',
input: xml,
output: '@BASENAME@-protocol.c',
command: [wayland_scanner, 'private-code', '@INPUT@', '@OUTPUT@'],
)
wl_protos_headers += custom_target(
xml.underscorify() + '_server_h',
input: xml,
output: '@BASENAME@-protocol.h',
command: [wayland_scanner, 'server-header', '@INPUT@', '@OUTPUT@'],
)
endforeach
foreach p : client_protocols
xml = join_paths(p)
wl_protos_headers += custom_target(
xml.underscorify() + '_client_h',
input: xml,
output: '@BASENAME@-client-protocol.h',
command: [wayland_scanner, 'client-header', '@INPUT@', '@OUTPUT@'],
)
endforeach
lib_client_protos = static_library(
'client_protos',
wl_protos_src + wl_protos_headers,
dependencies: wayland_client.partial_dependency(compile_args: true),
)
client_protos = declare_dependency(
link_with: lib_client_protos,
sources: wl_protos_headers,
)
lib_server_protos = static_library(
'server_protos',
wl_protos_src + wl_protos_headers,
dependencies: wayland_server.partial_dependency(compile_args: true),
)
server_protos = declare_dependency(
link_with: lib_server_protos,
sources: wl_protos_headers,
)