From b75eeae98c8f00c566d21049e0d27e77bfe071b7 Mon Sep 17 00:00:00 2001 From: Michael Zhang Date: Wed, 13 Jan 2021 13:02:13 -0600 Subject: [PATCH] add traces --- src/gui.rs | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/src/gui.rs b/src/gui.rs index ccd76e5..e4d4a20 100644 --- a/src/gui.rs +++ b/src/gui.rs @@ -222,10 +222,10 @@ impl Gui { while let Some(evt) = self.conn.wait_for_event() { match evt.response_type() { xcb::KEY_RELEASE => { - let key_evt = unsafe { xcb::cast_event::(&evt) }; - info!("released key {:?}", key_evt.detail()); + let evt = unsafe { xcb::cast_event::(&evt) }; + trace!("key released: root={} key={} state={}", evt.root(), evt.detail(), evt.state()); - if key_evt.detail() == 9 { + if evt.detail() == 9 { if state.dragging { state.dragging = false; } else { @@ -236,24 +236,25 @@ impl Gui { } xcb::KEY_PRESS => {} xcb::BUTTON_PRESS => { - let button_evt = unsafe { xcb::cast_event::(&evt) }; - info!("pressed mouse button {:?}", button_evt.detail()); - state.mx = button_evt.root_x(); - state.my = button_evt.root_y(); - state.dx = button_evt.root_x(); - state.dy = button_evt.root_y(); + let evt = unsafe { xcb::cast_event::(&evt) }; + trace!("button pressed: button={}", evt.detail()); + + state.mx = evt.root_x(); + state.my = evt.root_y(); + state.dx = evt.root_x(); + state.dy = evt.root_y(); // left mouse button - if button_evt.detail() == 1 { + if evt.detail() == 1 { state.dragging = true; } } xcb::BUTTON_RELEASE => { - let button_evt = unsafe { xcb::cast_event::(&evt) }; - info!("released mouse button {:?}", button_evt.detail()); + let evt = unsafe { xcb::cast_event::(&evt) }; + trace!("button released: button={}", evt.detail()); // left mouse button - if state.dragging && button_evt.detail() == 1 { + if state.dragging && evt.detail() == 1 { state.dragging = false; if let Some(_) = state.rect() { break; @@ -261,12 +262,13 @@ impl Gui { } } xcb::MOTION_NOTIFY => { + trace!("mouse movement event"); let motion_evt = unsafe { xcb::cast_event::(&evt) }; state.mx = motion_evt.root_x(); state.my = motion_evt.root_y(); } v => { - info!("event type: {:?}", v); + trace!("unknown event of type: {:?}", v); } }