Skip to content

Commit

Permalink
Properly handle mouse leave event on GTK (#2324)
Browse files Browse the repository at this point in the history
  • Loading branch information
xStrom committed Jan 9, 2023
1 parent 3c91f04 commit 5d765db
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 14 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ You can find its changes [documented below](#070---2021-01-01).
- Do not panic in Application::try_global if Application is not created ([#1996] by [@Maan2003])
- X11: window focus events ([#1938] by [@Maan2003]
- Preserve the aspect ratio of a clipped region in an Image ([#2195] by [@barsae])
- GTK: Hot state now properly resets when the mouse leaves the window via an occluded part. ([#2324] by [@xStrom])

### Visual

Expand Down Expand Up @@ -874,6 +875,7 @@ Last release without a changelog :(
[#2274]: https://github.com/linebender/druid/pull/2274
[#2284]: https://github.com/linebender/druid/pull/2284
[#2320]: https://github.com/linebender/druid/pull/2320
[#2324]: https://github.com/linebender/druid/pull/2324

[Unreleased]: https://github.com/linebender/druid/compare/v0.7.0...master
[0.7.0]: https://github.com/linebender/druid/compare/v0.6.0...v0.7.0
Expand Down
16 changes: 2 additions & 14 deletions druid-shell/src/backend/gtk/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -642,21 +642,9 @@ impl WindowBuilder {
);

win_state.drawing_area.connect_leave_notify_event(
clone!(handle => move |_widget, crossing| {
clone!(handle => move |_widget, _crossing| {
if let Some(state) = handle.state.upgrade() {
let scale = state.scale.get();
let crossing_state = crossing.state();
let mouse_event = MouseEvent {
pos: Point::from(crossing.position()).to_dp(scale),
buttons: get_mouse_buttons_from_modifiers(crossing_state),
mods: get_modifiers(crossing_state),
count: 0,
focus: false,
button: MouseButton::None,
wheel_delta: Vec2::ZERO
};

state.with_handler(|h| h.mouse_move(&mouse_event));
state.with_handler(|h| h.mouse_leave());
}

Inhibit(true)
Expand Down

0 comments on commit 5d765db

Please sign in to comment.