mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Windows: Avoid sending mousewheel events to obscured windows
This commit is contained in:
parent
cff48fdc63
commit
77bf765fcf
1 changed files with 22 additions and 7 deletions
|
|
@ -2863,8 +2863,6 @@ private:
|
||||||
{
|
{
|
||||||
auto currentMousePos = getPOINTFromLParam ((LPARAM) GetMessagePos());
|
auto currentMousePos = getPOINTFromLParam ((LPARAM) GetMessagePos());
|
||||||
|
|
||||||
// Because Windows stupidly sends all wheel events to the window with the keyboard
|
|
||||||
// focus, we have to redirect them here according to the mouse pos..
|
|
||||||
auto* peer = getOwnerOfWindow (WindowFromPoint (currentMousePos));
|
auto* peer = getOwnerOfWindow (WindowFromPoint (currentMousePos));
|
||||||
|
|
||||||
if (peer == nullptr)
|
if (peer == nullptr)
|
||||||
|
|
@ -2892,7 +2890,7 @@ private:
|
||||||
return MouseInputSource::InputSourceType::mouse;
|
return MouseInputSource::InputSourceType::mouse;
|
||||||
}
|
}
|
||||||
|
|
||||||
void doMouseWheel (const WPARAM wParam, const bool isVertical)
|
bool doMouseWheel (const WPARAM wParam, const bool isVertical)
|
||||||
{
|
{
|
||||||
updateKeyModifiers();
|
updateKeyModifiers();
|
||||||
const float amount = jlimit (-1000.0f, 1000.0f, 0.5f * (short) HIWORD (wParam));
|
const float amount = jlimit (-1000.0f, 1000.0f, 0.5f * (short) HIWORD (wParam));
|
||||||
|
|
@ -2904,8 +2902,19 @@ private:
|
||||||
wheel.isSmooth = false;
|
wheel.isSmooth = false;
|
||||||
wheel.isInertial = false;
|
wheel.isInertial = false;
|
||||||
|
|
||||||
if (const auto [peer, localPos] = findPeerUnderMouse(); peer != nullptr)
|
// From Windows 10 onwards, mouse events are sent first to the window under the mouse, not
|
||||||
peer->handleMouseWheel (getPointerType (wParam), localPos, getMouseEventTime(), wheel);
|
// the window with focus, despite what the MSDN docs might say.
|
||||||
|
// This is the behaviour we want; if we're receiving a scroll event, we can assume it
|
||||||
|
// should be processed by the current peer.
|
||||||
|
const auto currentMousePos = getPOINTFromLParam ((LPARAM) GetMessagePos());
|
||||||
|
auto* peer = getOwnerOfWindow (WindowFromPoint (currentMousePos));
|
||||||
|
|
||||||
|
if (peer == nullptr)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
const auto localPos = peer->globalToLocal (convertPhysicalScreenPointToLogical (D2DUtilities::toPoint (currentMousePos), hwnd).toFloat());
|
||||||
|
peer->handleMouseWheel (getPointerType (wParam), localPos, getMouseEventTime(), wheel);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool doGestureEvent (LPARAM lParam)
|
bool doGestureEvent (LPARAM lParam)
|
||||||
|
|
@ -3952,10 +3961,16 @@ private:
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
case WM_POINTERWHEEL:
|
case WM_POINTERWHEEL:
|
||||||
case 0x020A: /* WM_MOUSEWHEEL */ doMouseWheel (wParam, true); return 0;
|
case WM_MOUSEWHEEL:
|
||||||
|
if (doMouseWheel (wParam, true))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_POINTERHWHEEL:
|
case WM_POINTERHWHEEL:
|
||||||
case 0x020E: /* WM_MOUSEHWHEEL */ doMouseWheel (wParam, false); return 0;
|
case WM_MOUSEHWHEEL:
|
||||||
|
if (doMouseWheel (wParam, false))
|
||||||
|
return 0;
|
||||||
|
break;
|
||||||
|
|
||||||
case WM_CAPTURECHANGED:
|
case WM_CAPTURECHANGED:
|
||||||
doCaptureChanged();
|
doCaptureChanged();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue