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