From 2b67891ca2d9e78cda3d03c875ab437882e0e97b Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Sat, 16 Apr 2022 09:06:09 +0200 Subject: [PATCH] Disable tabbing out by grabbing keyboard We grab the keyboard and bind it to the roftl window. This works as long as there is no other window grabbing the keyboard afterwards (and effectively stealing the keyboard from roftl). This is done so tabbing out of roftl (and hence loosing focus) is not possible. --- src/main.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/main.rs b/src/main.rs index 304574b..51ecafd 100644 --- a/src/main.rs +++ b/src/main.rs @@ -76,6 +76,22 @@ fn main() -> Result<(), Box> { xcb_util::ewmh::CLIENT_SOURCE_TYPE_NORMAL, ); + debug! {"Grab keyboard, disable tabbing out"} + let xcb_conn = unsafe { + xcb::Connection::from_raw_conn( + window.xcb_connection().unwrap() as *mut xcb::ffi::xcb_connection_t + ) + }; + + xcb::xproto::grab_keyboard( + &xcb_conn, + true, + xcb_window, + xcb::ffi::base::XCB_CURRENT_TIME, + xcb::xproto::GRAB_MODE_ASYNC as u8, + xcb::xproto::GRAB_MODE_ASYNC as u8, + ); + debug! {"Window id: {:?}", window.id()} debug! {"Draw primary state to window"}