From 1f433a8bfba7dd05b190af68bdee50c488325eb0 Mon Sep 17 00:00:00 2001 From: jules Date: Tue, 29 Dec 2015 11:21:03 +0000 Subject: [PATCH] Fix for an obscure win32 situation where a click from another app window could end up causing a click in a juce window if the other window closes with the mouse still down --- .../native/juce_win32_Windowing.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index a2b08ade37..f1e30b0fb5 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -1721,7 +1721,7 @@ private: return (dw & SIGNATURE_MASK) == MI_WP_SIGNATURE; } - void doMouseMove (Point position) + void doMouseMove (Point position, bool isMouseDownEvent) { // this will be handled by WM_TOUCH if (isTouchEvent()) @@ -1730,7 +1730,13 @@ private: if (! isMouseOver) { isMouseOver = true; - ModifierKeys::getCurrentModifiersRealtime(); // (This avoids a rare stuck-button problem when focus is lost unexpectedly) + + // This avoids a rare stuck-button problem when focus is lost unexpectedly, but must + // not be called as part of a move, in case it's actually a mouse-drag from another + // app which ends up here when we get focus before the mouse is released.. + if (isMouseDownEvent) + ModifierKeys::getCurrentModifiersRealtime(); + updateKeyModifiers(); TRACKMOUSEEVENT tme; @@ -1770,7 +1776,7 @@ private: if (GetCapture() != hwnd) SetCapture (hwnd); - doMouseMove (position); + doMouseMove (position, true); if (isValidPeer (this)) { @@ -2447,7 +2453,7 @@ private: return 1; //============================================================================== - case WM_MOUSEMOVE: doMouseMove (getPointFromLParam (lParam)); return 0; + case WM_MOUSEMOVE: doMouseMove (getPointFromLParam (lParam), false); return 0; case WM_MOUSELEAVE: doMouseExit(); return 0; case WM_LBUTTONDOWN: