]> source.dussan.org Git - tigervnc.git/commitdiff
Now the min desktop window size limit to the toolbar size.
authorgeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sat, 27 Jan 2007 15:48:25 +0000 (15:48 +0000)
committergeorge82 <george82@3789f03b-4d11-0410-bbf8-ca57d06f2519>
Sat, 27 Jan 2007 15:48:25 +0000 (15:48 +0000)
It makes managing of the vncviewer size more comfort.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2222 3789f03b-4d11-0410-bbf8-ca57d06f2519

win/vncviewer/DesktopWindow.cxx

index 826572337ed5699682930686b3b2529c21e0ad76..5aba7802724bc41f5c4f14e4d3571f53f90e16ea 100644 (file)
@@ -428,12 +428,23 @@ DesktopWindow::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
       if ((wpos->flags & SWP_NOSIZE) || isAutoScaling())
         break;
 
+      // Calculate the minimum size of main window
+      RECT r;
+      Rect min_size;
+      int tbMinWidth = 0, tbMinHeight = 0;
+      if (isToolbarEnabled()) {
+        tbMinWidth = tb.getTotalWidth();
+        tbMinHeight = tb.getHeight();
+        SetRect(&r, 0, 0, tbMinWidth, tbMinHeight);
+        AdjustWindowRect(&r, GetWindowLong(handle, GWL_STYLE), FALSE);
+        min_size = Rect(r.left, r.top, r.right, r.bottom);
+      }
+
       // Work out how big the window should ideally be
       DWORD current_style = GetWindowLong(frameHandle, GWL_STYLE);
       DWORD style = current_style & ~(WS_VSCROLL | WS_HSCROLL);
       DWORD style_ex = GetWindowLong(frameHandle, GWL_EXSTYLE);
 
-      RECT r;
       SetRect(&r, 0, 0, buffer->width(), buffer->height());
       AdjustWindowRectEx(&r, style, FALSE, style_ex);
       Rect reqd_size = Rect(r.left, r.top, r.right, r.bottom);
@@ -451,13 +462,28 @@ DesktopWindow::processMessage(UINT msg, WPARAM wParam, LPARAM lParam) {
       RECT current;
       GetWindowRect(handle, &current);
 
+      if (min_size.width() > reqd_size.width()) {
+        reqd_size.tl.x = min_size.tl.x;
+        reqd_size.br.x = min_size.br.x;
+      }
+      if (min_size.height() > reqd_size.height()) {
+        reqd_size.tl.y = min_size.tl.y;
+        reqd_size.br.y = min_size.br.y;
+      }
+
       if (!(GetWindowLong(handle, GWL_STYLE) & WS_MAXIMIZE) && !fullscreenActive) {
-        // Ensure that the window isn't resized too large
-        if (wpos->cx > reqd_size.width()) {
+        // Ensure that the window isn't resized too large or too small
+        if ((wpos->cx < min_size.width()) && isToolbarEnabled()) {
+          wpos->cx = min_size.width();
+          wpos->x = current.left;
+        } else if ((wpos->cx > reqd_size.width())) {
           wpos->cx = reqd_size.width();
           wpos->x = current.left;
         }
-        if (wpos->cy > reqd_size.height()) {
+        if ((wpos->cy < min_size.height()) && isToolbarEnabled()) {
+          wpos->cy = min_size.height();
+          wpos->y = current.top;
+        } else if (wpos->cy > reqd_size.height()) {
           wpos->cy = reqd_size.height();
           wpos->y = current.top;
         }