From 76261ad24ab0f702e619c380e3f22b4c1ca938ad Mon Sep 17 00:00:00 2001 From: Ferdinand Schober Date: Tue, 20 Sep 2022 08:24:44 +0200 Subject: [PATCH] Send ALL keyboard shortcuts Using keyboard-shortcut-inhibit-unstable-v1.xml we can inhibit shortcuts for the server and send those to the client as well. --- config.toml | 1 + src/bin/server.rs | 50 ++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/config.toml b/config.toml index 9bbdc46..deffd33 100644 --- a/config.toml +++ b/config.toml @@ -1,3 +1,4 @@ +port = 42069 [client.left] host_name = "rubinium" ip = "192.168.2.182" diff --git a/src/bin/server.rs b/src/bin/server.rs index b57e887..38541b4 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -10,6 +10,10 @@ use std::{ use wayland_protocols::wp::{ pointer_constraints::zv1::client::{zwp_locked_pointer_v1, zwp_pointer_constraints_v1}, relative_pointer::zv1::client::{zwp_relative_pointer_manager_v1, zwp_relative_pointer_v1}, + keyboard_shortcuts_inhibit::zv1::client::{ + zwp_keyboard_shortcuts_inhibit_manager_v1, + zwp_keyboard_shortcuts_inhibitor_v1, + }, }; use wayland_protocols_wlr::layer_shell::v1::client::{ @@ -38,7 +42,10 @@ struct App { rel_pointer_manager: Option, pointer_lock: Option, rel_pointer: Option, + shortcut_inhibit_manager: Option, + shortcut_inhibitor: Option, connection: protocol::Connection, + seat: Option, } fn main() { @@ -69,6 +76,9 @@ fn main() { pointer_lock: None, rel_pointer: None, connection, + shortcut_inhibit_manager: None, + shortcut_inhibitor: None, + seat: None, }; // use roundtrip to process this event synchronously @@ -146,7 +156,7 @@ impl Dispatch for App { app.buffer = Some(buffer); } "wl_seat" => { - registry.bind::(name, 8, qh, ()); + app.seat = Some(registry.bind::(name, 8, qh, ())); } "zwp_pointer_constraints_v1" => { app.pointer_constraints = Some( @@ -174,6 +184,11 @@ impl Dispatch for App { 4, &qh, (), )); } + "zwp_keyboard_shortcuts_inhibit_manager_v1" => { + app.shortcut_inhibit_manager = Some(registry.bind::( + name, 1, &qh, (), + )); + } _ => {} } } @@ -307,6 +322,13 @@ impl Dispatch for App { .get_relative_pointer(pointer, qh, ()), ); } + if app.shortcut_inhibitor.is_none() { + app.shortcut_inhibitor = Some(app.shortcut_inhibit_manager.as_ref().unwrap().inhibit_shortcuts( + app.surface.as_ref().unwrap(), + app.seat.as_ref().unwrap(), + qh, (), + )); + } } wl_pointer::Event::Leave {..} => { if let Some(s) = app.layer_surface.as_ref() { @@ -349,6 +371,10 @@ impl Dispatch for App { rel_pointer.destroy(); app.rel_pointer = None; } + if let Some(shortcut_inhibitor) = app.shortcut_inhibitor.as_ref() { + shortcut_inhibitor.destroy(); + app.shortcut_inhibitor = None; + } } else { app.connection.send_event(event); } @@ -465,3 +491,25 @@ impl Dispatch for App { _: &QueueHandle, ) { } } + +impl Dispatch for App { + fn event( + _: &mut Self, + _: &zwp_keyboard_shortcuts_inhibit_manager_v1::ZwpKeyboardShortcutsInhibitManagerV1, + _: ::Event, + _: &(), + _: &Connection, + _: &QueueHandle, + ) { } +} + +impl Dispatch for App { + fn event( + _: &mut Self, + _: &zwp_keyboard_shortcuts_inhibitor_v1::ZwpKeyboardShortcutsInhibitorV1, + _: ::Event, + _: &(), + _: &Connection, + _: &QueueHandle, + ) { } +}