From 38faa18449ef38f01a060346869b87e4cd42e3dd Mon Sep 17 00:00:00 2001 From: tcmal Date: Fri, 21 Jun 2024 21:03:52 +0100 Subject: log requests and sequence numbers in debug mode --- src/conn_info/mod.rs | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/conn_info/mod.rs b/src/conn_info/mod.rs index bd6f0cd..fbbbb54 100644 --- a/src/conn_info/mod.rs +++ b/src/conn_info/mod.rs @@ -49,6 +49,17 @@ pub struct Connection<'a> { pub keyboard_state: KeyboardInfo, } +macro_rules! debug_req { + ($req:ident) => { + #[cfg(debug_assertions)] + eprintln!("seq ?: {:?}", $req) + }; + ($req:ident, $cookie:ident) => { + #[cfg(debug_assertions)] + eprintln!("seq {}: {:?}", $cookie.sequence(), $req) + }; +} + impl<'a> Connection<'a> { /// Prepare the window manager to run on the given connection and screen number. /// This will fail if another WM is running. @@ -172,16 +183,19 @@ impl<'a> Connection<'a> { /// Delegate for [`RawConnection::send_request`] pub fn send_request(&self, req: &R) -> R::Cookie where - R: xcb::Request, + R: xcb::Request + Debug, { - self.conn.send_request(req) + let cookie = self.conn.send_request(req); + debug_req!(req, cookie); + cookie } /// Delegate for [`RawConnection::send_and_check_request`] pub fn send_and_check_request(&self, req: &R) -> Result<()> where - R: xcb::RequestWithoutReply, + R: xcb::RequestWithoutReply + Debug, { + debug_req!(req); self.conn.send_and_check_request(req).map_err(Into::into) } @@ -226,7 +240,7 @@ impl<'a> Connection<'a> { impl Drop for Connection<'_> { fn drop(&mut self) { - self.send_request(&DestroyWindow { + self.conn.send_request(&DestroyWindow { window: self.check_window, }); -- cgit v1.2.3