summaryrefslogtreecommitdiff
path: root/src/conn_info/mod.rs
diff options
context:
space:
mode:
authortcmal <me@aria.rip>2024-06-21 21:03:52 +0100
committertcmal <me@aria.rip>2024-06-21 21:03:52 +0100
commit38faa18449ef38f01a060346869b87e4cd42e3dd (patch)
tree79508d0bc4a7880f7a63d57f39d5a910830ee748 /src/conn_info/mod.rs
parent4579ebac1d049ec451d4e7c2619dc55ea911a9df (diff)
log requests and sequence numbers in debug mode
Diffstat (limited to 'src/conn_info/mod.rs')
-rw-r--r--src/conn_info/mod.rs22
1 files 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<R>(&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<R>(&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,
});