reapack

Package manager for REAPER
Log | Files | Refs | Submodules | README | LICENSE

commit 89ee236fc724739b16dca7fdeb115353d59fb9a5
parent a8bf69168a8bb293c6081c7f423e18f7411dfd89
Author: cfillion <cfillion@users.noreply.github.com>
Date:   Wed, 29 Jun 2016 16:42:14 -0700

dialog: improve window placement in multi-monitor setups

completes the fix for bug #6

Diffstat:
Msrc/dialog.cpp | 19+++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/src/dialog.cpp b/src/dialog.cpp @@ -245,8 +245,23 @@ void Dialog::boundedMove(int x, int y) const int width = rect.right - rect.left, height = rect.bottom - rect.top; - x = min(max(0, x), GetSystemMetrics(SM_CXSCREEN) - width); - y = min(max(0, y), GetSystemMetrics(SM_CYSCREEN) - height); +#ifdef SM_XVIRTUALSCREEN + const int screenX = GetSystemMetrics(SM_XVIRTUALSCREEN); + const int screenWidth = GetSystemMetrics(SM_CXVIRTUALSCREEN) - abs(screenX); + const int screenY = GetSystemMetrics(SM_YVIRTUALSCREEN); + const int screenHeight = GetSystemMetrics(SM_CYVIRTUALSCREEN) - abs(screenY); +#else // for SWELL + RECT viewport; + SWELL_GetViewPort(&viewport, &rect, false); + + const int screenX = viewport.left; + const int screenWidth = viewport.right - abs(screenX); + const int screenY = viewport.top; + const int screenHeight = viewport.bottom - abs(screenY); +#endif + + x = min(max(screenX, x), screenWidth - width); + y = min(max(screenY, y), screenHeight - height); SetWindowPos(m_handle, nullptr, x, y, 0, 0, SWP_NOZORDER | SWP_NOSIZE | SWP_NOACTIVATE);