diff options
author | Jon TURNEY <jon.turney@dronecode.org.uk> | 2009-07-05 16:06:32 +0100 |
---|---|---|
committer | Jon TURNEY <jon.turney@dronecode.org.uk> | 2009-07-07 15:03:43 +0100 |
commit | 48a9d65b88f56d1f8ab3bf824a4fe48c2f68725f (patch) | |
tree | f17afcab897bafb6ce90ccab3b374c3cf8a9a1f2 | |
parent | 5aec72745232dd61e60cfbf3acc4628d4fcd0315 (diff) |
Cygwin/X: Window positioning improvements for multiwindow mode
A few tweaks to winUpdateWindowPosition():
* Don't allow window decoration to disappear off to top or left edge of the
display as a result of adjustments to add decoration for the window style
* Honour the position requested by window geometry for the client area (so
windows which save their position don't get moved by the decoration width
every time they are created) (unless we need to bump it away from top or left edges)
* Fix an issue with initial window placement being offscreen on multimonitor
systems when some monitors have negative coordinates (are to the left of or
above the primary monitor)
Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r-- | hw/xwin/winmultiwindowwm.c | 34 |
1 files changed, 24 insertions, 10 deletions
diff --git a/hw/xwin/winmultiwindowwm.c b/hw/xwin/winmultiwindowwm.c index 8560c6cc0..18d9aedc2 100644 --- a/hw/xwin/winmultiwindowwm.c +++ b/hw/xwin/winmultiwindowwm.c @@ -1605,6 +1605,7 @@ winApplyHints (Display *pDisplay, Window iWindow, HWND hWnd, HWND *zstyle) void winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle) { + int iX, iY, iWidth, iHeight; int iDx, iDy; RECT rcNew; WindowPtr pWin = GetProp (hWnd, WIN_WINDOW_PROP); @@ -1614,8 +1615,16 @@ winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle) pDraw = &pWin->drawable; if (!pDraw) return; + /* Get the X and Y location of the X window */ + iX = pWin->drawable.x + GetSystemMetrics (SM_XVIRTUALSCREEN); + iY = pWin->drawable.y + GetSystemMetrics (SM_YVIRTUALSCREEN); + + /* Get the height and width of the X window */ + iWidth = pWin->drawable.width; + iHeight = pWin->drawable.height; + /* Setup a rectangle with the X window position and size */ - SetRect (&rcNew, pDraw->x, pDraw->y, pDraw->x + pDraw->width, pDraw->y + pDraw->height); + SetRect (&rcNew, iX, iY, iX + iWidth, iY + iHeight); #if 0 ErrorF ("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n", @@ -1625,15 +1634,20 @@ winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle) AdjustWindowRectEx (&rcNew, GetWindowLongPtr (hWnd, GWL_STYLE), FALSE, WS_EX_APPWINDOW); - /* Calculate position deltas */ - iDx = pDraw->x - rcNew.left; - iDy = pDraw->y - rcNew.top; + /* Don't allow window decoration to disappear off to top-left as a result of this adjustment */ + if (rcNew.left < GetSystemMetrics(SM_XVIRTUALSCREEN)) + { + iDx = GetSystemMetrics(SM_XVIRTUALSCREEN) - rcNew.left; + rcNew.left += iDx; + rcNew.right += iDx; + } - /* Calculate new rectangle */ - rcNew.left += iDx; - rcNew.right += iDx; - rcNew.top += iDy; - rcNew.bottom += iDy; + if (rcNew.top < GetSystemMetrics(SM_YVIRTUALSCREEN)) + { + iDy = GetSystemMetrics(SM_YVIRTUALSCREEN) - rcNew.top; + rcNew.top += iDy; + rcNew.bottom += iDy; + } #if 0 ErrorF ("winUpdateWindowPosition - (%d, %d)-(%d, %d)\n", @@ -1644,7 +1658,7 @@ winUpdateWindowPosition (HWND hWnd, Bool reshape, HWND *zstyle) /* Position the Windows window */ SetWindowPos (hWnd, *zstyle, rcNew.left, rcNew.top, rcNew.right - rcNew.left, rcNew.bottom - rcNew.top, - SWP_NOMOVE | ((reshape) ? 0 : SWP_NOREDRAW)); + 0); if (reshape) { |