clean up match

This commit is contained in:
expectocode 2018-11-25 01:45:07 +00:00
parent e690aa07f1
commit 179c8ac9ee
1 changed files with 18 additions and 23 deletions

View File

@ -70,22 +70,17 @@ fn main() {
conn.flush(); conn.flush();
loop { loop {
let ev = conn.wait_for_event(); let ev = conn.wait_for_event().unwrap();
match ev { match ev.response_type() {
None => { xcb::BUTTON_PRESS => {
println!("Error reading events");
break;
}
Some(ev) => {
let r = ev.response_type();
if r == xcb::BUTTON_PRESS as u8 {
let button_press: &xcb::ButtonPressEvent = unsafe { xcb::cast_event(&ev) }; let button_press: &xcb::ButtonPressEvent = unsafe { xcb::cast_event(&ev) };
println!( println!(
"Mouse press: x={}, y={}", "Mouse press: x={}, y={}",
button_press.event_x(), button_press.event_x(),
button_press.event_y() button_press.event_y()
); );
} else if r == xcb::BUTTON_RELEASE as u8 { }
xcb::BUTTON_RELEASE => {
let button_release: &xcb::ButtonReleaseEvent = unsafe { xcb::cast_event(&ev) }; let button_release: &xcb::ButtonReleaseEvent = unsafe { xcb::cast_event(&ev) };
println!( println!(
"Mouse release: x={}, y={}", "Mouse release: x={}, y={}",
@ -94,7 +89,7 @@ fn main() {
); );
break; // Move on after mouse released break; // Move on after mouse released
} }
} _ => continue
}; };
} }
// Now we have taken coordinates, we use them // Now we have taken coordinates, we use them