|
|
@ -165,11 +165,19 @@ impl MouseManager {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
fn handle_pointer_transition(&mut self, down: bool) {
|
|
|
|
fn handle_pointer_transition(&mut self, mouse_button: &MouseButton, down: bool) {
|
|
|
|
// For some reason pointer down is handled differently from pointer up and drag.
|
|
|
|
// For some reason pointer down is handled differently from pointer up and drag.
|
|
|
|
// Floating windows: relative coordinates are great.
|
|
|
|
// Floating windows: relative coordinates are great.
|
|
|
|
// Non floating windows: rather than global coordinates, relative are needed
|
|
|
|
// Non floating windows: rather than global coordinates, relative are needed
|
|
|
|
if self.enabled {
|
|
|
|
if self.enabled {
|
|
|
|
|
|
|
|
let button_text = match mouse_button {
|
|
|
|
|
|
|
|
MouseButton::Left => Some("left"),
|
|
|
|
|
|
|
|
MouseButton::Right => Some("right"),
|
|
|
|
|
|
|
|
MouseButton::Middle => Some("middle"),
|
|
|
|
|
|
|
|
_ => None,
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if let Some(button_text) = button_text {
|
|
|
|
if let Some(details) = &self.window_details_under_mouse {
|
|
|
|
if let Some(details) = &self.window_details_under_mouse {
|
|
|
|
let action = if down {
|
|
|
|
let action = if down {
|
|
|
|
"press".to_owned()
|
|
|
|
"press".to_owned()
|
|
|
@ -185,6 +193,7 @@ impl MouseManager {
|
|
|
|
|
|
|
|
|
|
|
|
self.command_sender
|
|
|
|
self.command_sender
|
|
|
|
.send(UiCommand::MouseButton {
|
|
|
|
.send(UiCommand::MouseButton {
|
|
|
|
|
|
|
|
button: button_text.to_string(),
|
|
|
|
action,
|
|
|
|
action,
|
|
|
|
grid_id: details.id,
|
|
|
|
grid_id: details.id,
|
|
|
|
position: position.into(),
|
|
|
|
position: position.into(),
|
|
|
@ -192,6 +201,7 @@ impl MouseManager {
|
|
|
|
.ok();
|
|
|
|
.ok();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
self.dragging = down;
|
|
|
|
self.dragging = down;
|
|
|
|
|
|
|
|
|
|
|
@ -302,12 +312,12 @@ impl MouseManager {
|
|
|
|
Event::WindowEvent {
|
|
|
|
Event::WindowEvent {
|
|
|
|
event:
|
|
|
|
event:
|
|
|
|
WindowEvent::MouseInput {
|
|
|
|
WindowEvent::MouseInput {
|
|
|
|
button: MouseButton::Left,
|
|
|
|
button,
|
|
|
|
state,
|
|
|
|
state,
|
|
|
|
..
|
|
|
|
..
|
|
|
|
},
|
|
|
|
},
|
|
|
|
..
|
|
|
|
..
|
|
|
|
} => self.handle_pointer_transition(state == &ElementState::Pressed),
|
|
|
|
} => self.handle_pointer_transition(button, state == &ElementState::Pressed),
|
|
|
|
_ => {}
|
|
|
|
_ => {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|