forked from michael/leanshot
add traces
This commit is contained in:
parent
58adb0680f
commit
b75eeae98c
1 changed files with 16 additions and 14 deletions
30
src/gui.rs
30
src/gui.rs
|
@ -222,10 +222,10 @@ impl Gui {
|
||||||
while let Some(evt) = self.conn.wait_for_event() {
|
while let Some(evt) = self.conn.wait_for_event() {
|
||||||
match evt.response_type() {
|
match evt.response_type() {
|
||||||
xcb::KEY_RELEASE => {
|
xcb::KEY_RELEASE => {
|
||||||
let key_evt = unsafe { xcb::cast_event::<xcb::KeyReleaseEvent>(&evt) };
|
let evt = unsafe { xcb::cast_event::<xcb::KeyReleaseEvent>(&evt) };
|
||||||
info!("released key {:?}", key_evt.detail());
|
trace!("key released: root={} key={} state={}", evt.root(), evt.detail(), evt.state());
|
||||||
|
|
||||||
if key_evt.detail() == 9 {
|
if evt.detail() == 9 {
|
||||||
if state.dragging {
|
if state.dragging {
|
||||||
state.dragging = false;
|
state.dragging = false;
|
||||||
} else {
|
} else {
|
||||||
|
@ -236,24 +236,25 @@ impl Gui {
|
||||||
}
|
}
|
||||||
xcb::KEY_PRESS => {}
|
xcb::KEY_PRESS => {}
|
||||||
xcb::BUTTON_PRESS => {
|
xcb::BUTTON_PRESS => {
|
||||||
let button_evt = unsafe { xcb::cast_event::<xcb::ButtonPressEvent>(&evt) };
|
let evt = unsafe { xcb::cast_event::<xcb::ButtonPressEvent>(&evt) };
|
||||||
info!("pressed mouse button {:?}", button_evt.detail());
|
trace!("button pressed: button={}", evt.detail());
|
||||||
state.mx = button_evt.root_x();
|
|
||||||
state.my = button_evt.root_y();
|
state.mx = evt.root_x();
|
||||||
state.dx = button_evt.root_x();
|
state.my = evt.root_y();
|
||||||
state.dy = button_evt.root_y();
|
state.dx = evt.root_x();
|
||||||
|
state.dy = evt.root_y();
|
||||||
|
|
||||||
// left mouse button
|
// left mouse button
|
||||||
if button_evt.detail() == 1 {
|
if evt.detail() == 1 {
|
||||||
state.dragging = true;
|
state.dragging = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xcb::BUTTON_RELEASE => {
|
xcb::BUTTON_RELEASE => {
|
||||||
let button_evt = unsafe { xcb::cast_event::<xcb::ButtonReleaseEvent>(&evt) };
|
let evt = unsafe { xcb::cast_event::<xcb::ButtonReleaseEvent>(&evt) };
|
||||||
info!("released mouse button {:?}", button_evt.detail());
|
trace!("button released: button={}", evt.detail());
|
||||||
|
|
||||||
// left mouse button
|
// left mouse button
|
||||||
if state.dragging && button_evt.detail() == 1 {
|
if state.dragging && evt.detail() == 1 {
|
||||||
state.dragging = false;
|
state.dragging = false;
|
||||||
if let Some(_) = state.rect() {
|
if let Some(_) = state.rect() {
|
||||||
break;
|
break;
|
||||||
|
@ -261,12 +262,13 @@ impl Gui {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
xcb::MOTION_NOTIFY => {
|
xcb::MOTION_NOTIFY => {
|
||||||
|
trace!("mouse movement event");
|
||||||
let motion_evt = unsafe { xcb::cast_event::<xcb::MotionNotifyEvent>(&evt) };
|
let motion_evt = unsafe { xcb::cast_event::<xcb::MotionNotifyEvent>(&evt) };
|
||||||
state.mx = motion_evt.root_x();
|
state.mx = motion_evt.root_x();
|
||||||
state.my = motion_evt.root_y();
|
state.my = motion_evt.root_y();
|
||||||
}
|
}
|
||||||
v => {
|
v => {
|
||||||
info!("event type: {:?}", v);
|
trace!("unknown event of type: {:?}", v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue