Skip to content

Commit

Permalink
Only set has_mouse_focus when TrackMouseEvent succeeds.
Browse files Browse the repository at this point in the history
  • Loading branch information
teddemunnik committed Apr 10, 2020
1 parent 20b8604 commit a92e988
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions druid-shell/src/platform/windows/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -611,15 +611,16 @@ impl WndProc for MyWndProc {
// window under the cursor changes without moving the mouse, for example when
// our window is first opened under the mouse cursor.
if !s.has_mouse_focus && is_point_in_client_rect(hwnd, x, y) {
s.has_mouse_focus = true;
let mut desc = TRACKMOUSEEVENT {
cbSize: mem::size_of::<TRACKMOUSEEVENT>() as DWORD,
dwFlags: TME_LEAVE,
hwndTrack: hwnd,
dwHoverTime: HOVER_DEFAULT,
};
unsafe {
if TrackMouseEvent(&mut desc) == FALSE {
if TrackMouseEvent(&mut desc) != FALSE {
s.has_mouse_focus = true;
} else {
warn!(
"failed to TrackMouseEvent: {}",
Error::Hr(HRESULT_FROM_WIN32(GetLastError()))
Expand Down

0 comments on commit a92e988

Please sign in to comment.