-
Notifications
You must be signed in to change notification settings - Fork 567
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add Event::MouseLeave for windows #821
Conversation
Maybe there's a better name than
|
Good point, didn't think of the confusion with left mouse button.. I started with |
I think we generally follow web terminology (in this case, mouseleave) unless there is compelling reason to do otherwise. Though now I see the inconsistency with "mousemoved" as opposed to "mousemove". Hmm. |
Following web terms would be fine, except we don't with e.g. |
Indeed. Now I regret that. |
Well it's not too late to change it to |
Alright! |
Yes I agree with that naming plan @teddemunnik, split it into two PRs. |
6a84c74
to
dadd264
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here are some initial thoughts. I got some deeper thoughts around this whole situation, but I'll have to describe that later as I'm out of time right now.
if !s.has_mouse_focus && is_point_in_client_rect(hwnd, x, y) { | ||
s.has_mouse_focus = true; | ||
let mut desc = TRACKMOUSEEVENT { | ||
cbSize: std::mem::size_of::<TRACKMOUSEEVENT>() as DWORD, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use just mem::size_of
instead of std::mem::size_of
.
if TrackMouseEvent(&mut desc) == FALSE { | ||
warn!( | ||
"failed to TrackMouseEvent: {}", | ||
Error::Hr(HRESULT_FROM_WIN32(GetLastError())) | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is an interesting failure possibility. I think it might be better to set s.has_mouse_focus
to false
so that we'll try again on the next move event. Otherwise we'll forever be without this tracking.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm curious in what circumstances this call would fail, besides being passed wrong arguments. But good call with not setting has_mouse_focus
.
druid/src/event.rs
Outdated
/// Called when the mouse has left the application area. | ||
/// | ||
/// The `MouseLeave` event is propagated to the active widget, if | ||
/// there is one, otherwise to hot widgets (see `HotChanged`). | ||
MouseLeave, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the application area the window
Also the event will be propagated to both active and hot widgets. Multiple can be active, and hot widgets will receive this regardless of whether there are active.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's true, I copied the comment and behavior from MouseMove
, but I think they don't match there either?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably remnants of an era where druid was single window or something.
The event notifies the app that the cursor is no longer hovering the application window.
When the MouseLeft is propagated, druid automatically clears is_hot.
95026b6
to
a92e988
Compare
As per the discussion in zulip let's make |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adds a new new event
MouseLeft
, and implemented it for windows.The purpose for this event is to give a possibility of the OS to notifiy the druid app that it is no longer going to receive mouse events for some time. Either because the mouse has left the window rect, or because another app is blocking the mouse cursor.