add traces

This commit is contained in:
Michael Zhang 2021-01-13 13:02:13 -06:00
parent 58adb0680f
commit b75eeae98c
Signed by: michael
GPG key ID: BDA47A31A3C8EE6B

View file

@ -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::<xcb::KeyReleaseEvent>(&evt) };
info!("released key {:?}", key_evt.detail());
let evt = unsafe { xcb::cast_event::<xcb::KeyReleaseEvent>(&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::<xcb::ButtonPressEvent>(&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::<xcb::ButtonPressEvent>(&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::<xcb::ButtonReleaseEvent>(&evt) };
info!("released mouse button {:?}", button_evt.detail());
let evt = unsafe { xcb::cast_event::<xcb::ButtonReleaseEvent>(&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::<xcb::MotionNotifyEvent>(&evt) };
state.mx = motion_evt.root_x();
state.my = motion_evt.root_y();
}
v => {
info!("event type: {:?}", v);
trace!("unknown event of type: {:?}", v);
}
}