clean up match
This commit is contained in:
parent
e690aa07f1
commit
179c8ac9ee
41
src/main.rs
41
src/main.rs
|
@ -70,31 +70,26 @@ 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");
|
let button_press: &xcb::ButtonPressEvent = unsafe { xcb::cast_event(&ev) };
|
||||||
break;
|
println!(
|
||||||
|
"Mouse press: x={}, y={}",
|
||||||
|
button_press.event_x(),
|
||||||
|
button_press.event_y()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
Some(ev) => {
|
xcb::BUTTON_RELEASE => {
|
||||||
let r = ev.response_type();
|
let button_release: &xcb::ButtonReleaseEvent = unsafe { xcb::cast_event(&ev) };
|
||||||
if r == xcb::BUTTON_PRESS as u8 {
|
println!(
|
||||||
let button_press: &xcb::ButtonPressEvent = unsafe { xcb::cast_event(&ev) };
|
"Mouse release: x={}, y={}",
|
||||||
println!(
|
button_release.event_x(),
|
||||||
"Mouse press: x={}, y={}",
|
button_release.event_y()
|
||||||
button_press.event_x(),
|
);
|
||||||
button_press.event_y()
|
break; // Move on after mouse released
|
||||||
);
|
|
||||||
} else if r == xcb::BUTTON_RELEASE as u8 {
|
|
||||||
let button_release: &xcb::ButtonReleaseEvent = unsafe { xcb::cast_event(&ev) };
|
|
||||||
println!(
|
|
||||||
"Mouse release: x={}, y={}",
|
|
||||||
button_release.event_x(),
|
|
||||||
button_release.event_y()
|
|
||||||
);
|
|
||||||
break; // Move on after mouse released
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
_ => continue
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
// Now we have taken coordinates, we use them
|
// Now we have taken coordinates, we use them
|
||||||
|
|
Loading…
Reference in New Issue