diff options
author | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2007-01-27 15:32:27 +0000 |
---|---|---|
committer | george82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519> | 2007-01-27 15:32:27 +0000 |
commit | 858a46483d0cf4a2a69f11a1ca48f920fb063aa4 (patch) | |
tree | f799a71ad807bca0a6d24f238fad8eb1487d0ac2 | |
parent | 06e58b12c50d068fa4ce70fc5e7ebca251410294 (diff) | |
download | tigervnc-858a46483d0cf4a2a69f11a1ca48f920fb063aa4.tar.gz tigervnc-858a46483d0cf4a2a69f11a1ca48f920fb063aa4.zip |
Added DesktopWindow::resizeDesktopWindowToBuffer() method.
Now the Desktop Window resizes against the pixel buffer size
when the scale ratio changed.
This update fixes the bug with zero size of the desktop
window when it restore from minimized position.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2221 3789f03b-4d11-0410-bbf8-ca57d06f2519
-rw-r--r-- | win/vncviewer/DesktopWindow.cxx | 29 | ||||
-rw-r--r-- | win/vncviewer/DesktopWindow.h | 3 |
2 files changed, 28 insertions, 4 deletions
diff --git a/win/vncviewer/DesktopWindow.cxx b/win/vncviewer/DesktopWindow.cxx index ee941fd1..82657233 100644 --- a/win/vncviewer/DesktopWindow.cxx +++ b/win/vncviewer/DesktopWindow.cxx @@ -475,8 +475,7 @@ DesktopWindow::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) { // Resize child windows GetClientRect(handle, &r); if (tb.isVisible()) { - MoveWindow(frameHandle, 0, tb.getHeight(), - r.right, r.bottom - tb.getHeight(), TRUE); + MoveWindow(frameHandle, 0, tb.getHeight(), r.right, r.bottom - tb.getHeight(), TRUE); } else { MoveWindow(frameHandle, 0, 0, r.right, r.bottom, TRUE); } @@ -985,13 +984,13 @@ void DesktopWindow::setAutoScaling(bool as) { void DesktopWindow::setDesktopScaleRatio(double scale_ratio) { buffer->setScaleRatio(scale_ratio); - InvalidateRect(frameHandle, 0, FALSE); - if (!isAutoScaling()) calculateScrollBars(); + if (!isAutoScaling()) resizeDesktopWindowToBuffer(); if (isToolbarEnabled()) refreshToolbarButtons(); char *newTitle = new char[strlen(desktopName)+20]; sprintf(newTitle, "%s @ %i%%", desktopName, getDesktopScale()); SetWindowText(handle, TStr(newTitle)); delete [] newTitle; + InvalidateRect(frameHandle, 0, FALSE); } void DesktopWindow::fitBufferToWindow(bool repaint) { @@ -1139,6 +1138,28 @@ void DesktopWindow::calculateScrollBars() { client_size = Rect(r.left, r.top, r.right, r.bottom); } +void DesktopWindow::resizeDesktopWindowToBuffer() { + RECT r; + DWORD style = GetWindowLong(frameHandle, GWL_STYLE) & ~(WS_VSCROLL | WS_HSCROLL); + DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE); + + // Calculate the required size of the desktop window + SetRect(&r, 0, 0, buffer->width(), buffer->height()); + AdjustWindowRectEx(&r, style, FALSE, style_ex); + if (isToolbarEnabled()) + r.bottom += tb.getHeight(); + AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE); + + // Set the required size, center the main window and clip to the current monitor + SetWindowPos(handle, 0, 0, 0, r.right-r.left, r.bottom-r.top, SWP_NOACTIVATE | SWP_NOOWNERZORDER | SWP_NOZORDER | SWP_NOMOVE); + centerWindow(handle, NULL); + MonitorInfo mi(getMonitor()); + mi.clipTo(handle); + + // Enable/disable scrollbars as appropriate + calculateScrollBars(); +} + void DesktopWindow::setName(const char* name) { diff --git a/win/vncviewer/DesktopWindow.h b/win/vncviewer/DesktopWindow.h index 11b66703..bce7cf72 100644 --- a/win/vncviewer/DesktopWindow.h +++ b/win/vncviewer/DesktopWindow.h @@ -214,6 +214,9 @@ namespace rfb { // window style accordingly void calculateScrollBars(); + // Resizes the main window against the pixel buffer size + void resizeDesktopWindowToBuffer(); + // Win32-specific input handling rfb::win32::CPointer ptr; Point oldpos; |