Skip to content

Commit 79ed4dc

Browse files
committed
Report mouse motion before click
This fixes an issue on macOS where a mouse click would be generated, without ever getting a mouse motion to the position before the click. This leads to the application thinking the mouse click occurred at a position other than the actual mouse location. This happens due to mouse motion above the window not automatically giving focus to the window, unless it is actually clicked, making it possible to move the window without motion events. Fixes rust-windowing#942.
1 parent 2b14ec2 commit 79ed4dc

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
- On Web, add the ability to query "Light" or "Dark" system theme send `ThemeChanged` on change.
1010
- Fix `Event::to_static` returning `None` for user events.
1111
- On Wayland, Hide CSD for fullscreen windows.
12+
- On macOS, a mouse motion event is now generated before every mouse click.
1213

1314
# 0.21.0 (2020-02-04)
1415

src/platform_impl/macos/view.rs

+6
Original file line numberDiff line numberDiff line change
@@ -841,26 +841,32 @@ fn mouse_click(this: &Object, event: id, button: MouseButton, button_state: Elem
841841
}
842842

843843
extern "C" fn mouse_down(this: &Object, _sel: Sel, event: id) {
844+
mouse_motion(this, event);
844845
mouse_click(this, event, MouseButton::Left, ElementState::Pressed);
845846
}
846847

847848
extern "C" fn mouse_up(this: &Object, _sel: Sel, event: id) {
849+
mouse_motion(this, event);
848850
mouse_click(this, event, MouseButton::Left, ElementState::Released);
849851
}
850852

851853
extern "C" fn right_mouse_down(this: &Object, _sel: Sel, event: id) {
854+
mouse_motion(this, event);
852855
mouse_click(this, event, MouseButton::Right, ElementState::Pressed);
853856
}
854857

855858
extern "C" fn right_mouse_up(this: &Object, _sel: Sel, event: id) {
859+
mouse_motion(this, event);
856860
mouse_click(this, event, MouseButton::Right, ElementState::Released);
857861
}
858862

859863
extern "C" fn other_mouse_down(this: &Object, _sel: Sel, event: id) {
864+
mouse_motion(this, event);
860865
mouse_click(this, event, MouseButton::Middle, ElementState::Pressed);
861866
}
862867

863868
extern "C" fn other_mouse_up(this: &Object, _sel: Sel, event: id) {
869+
mouse_motion(this, event);
864870
mouse_click(this, event, MouseButton::Middle, ElementState::Released);
865871
}
866872

0 commit comments

Comments
 (0)