Revision: 4460
          http://tigervnc.svn.sourceforge.net/tigervnc/?rev=4460&view=rev
Author:   ossman_
Date:     2011-06-01 09:33:00 +0000 (Wed, 01 Jun 2011)

Log Message:
-----------
Handle framebuffer resize requests.

Modified Paths:
--------------
    trunk/vncviewer/CConn.cxx
    trunk/vncviewer/DesktopWindow.cxx
    trunk/vncviewer/DesktopWindow.h

Modified: trunk/vncviewer/CConn.cxx
===================================================================
--- trunk/vncviewer/CConn.cxx   2011-06-01 09:31:53 UTC (rev 4459)
+++ trunk/vncviewer/CConn.cxx   2011-06-01 09:33:00 UTC (rev 4460)
@@ -398,14 +398,10 @@
 
 void CConn::resizeFramebuffer()
 {
-/*
   if (!desktop)
     return;
-  if ((desktop->width() == cp.width) && (desktop->height() == cp.height))
-    return;
 
-  desktop->resize(cp.width, cp.height);
-*/
+  desktop->resizeFramebuffer(cp.width, cp.height);
 }
 
 // autoSelectFormatAndEncoding() chooses the format and encoding appropriate

Modified: trunk/vncviewer/DesktopWindow.cxx
===================================================================
--- trunk/vncviewer/DesktopWindow.cxx   2011-06-01 09:31:53 UTC (rev 4459)
+++ trunk/vncviewer/DesktopWindow.cxx   2011-06-01 09:33:00 UTC (rev 4460)
@@ -144,35 +144,53 @@
 }
 
 
-void DesktopWindow::resize(int x, int y, int w, int h)
+void DesktopWindow::resizeFramebuffer(int new_w, int new_h)
 {
-  // Deal with some scrolling corner cases:
-  //
-  // a) If the window is larger then the viewport, center the viewport.
-  // b) If the window is smaller than the viewport, make sure there is
-  //    no wasted space on the sides.
-  //
-  // FIXME: Doesn't compensate for scroll widget size properly.
-  if (w > viewport->w())
-    viewport->position((w - viewport->w()) / 2, viewport->y());
-  else {
-    if (viewport->x() > 0)
-      viewport->position(0, viewport->y());
-    else if (w > (viewport->x() + viewport->w()))
-      viewport->position(w - viewport->w(), viewport->y());
-  }
+  if ((new_w == viewport->w()) && (new_h == viewport->h()))
+    return;
 
-  // Same thing for y axis
-  if (h > viewport->h())
-    viewport->position(viewport->x(), (h - viewport->h()) / 2);
+  // Turn off size limitations for a bit while we juggle things around
+  size_range(100, 100, 0, 0);
+
+  // If we're letting the viewport match the window perfectly, then
+  // keep things that way for the new size, otherwise just keep things
+  // like they are.
+  if ((w() == viewport->w()) && (h() == viewport->h()))
+    size(new_w, new_h);
   else {
-    if (viewport->y() > 0)
-      viewport->position(viewport->x(), 0);
-    else if (h > (viewport->y() + viewport->h()))
-      viewport->position(viewport->x(), h - viewport->h());
+#ifdef HAVE_FLTK_FULLSCREEN
+    if (!fullscreen_active()) {
+#endif
+      // Make sure the window isn't too big
+      if ((w() > new_w) || (h() > new_h))
+        size(__rfbmin(w(), new_w), __rfbmin(h(), new_h));
+#ifdef HAVE_FLTK_FULLSCREEN
+    }
+#endif
   }
 
+  viewport->size(new_w, new_h);
+
+  // We might not resize the main window, so we need to manually call this
+  // to make sure the viewport is centered.
+  repositionViewport();
+
+  // Update allowed resize range
+  size_range(100, 100, new_w, new_h);
+
+  // repositionViewport() makes sure the scroll widget notices any changes
+  // in position, but it might be just the size that changes so we also
+  // need a poke here as well.
+  redraw();
+}
+
+
+void DesktopWindow::resize(int x, int y, int w, int h)
+{
   Fl_Window::resize(x, y, w, h);
+
+  // Deal with some scrolling corner cases
+  repositionViewport();
 }
 
 
@@ -291,6 +309,49 @@
 }
 
 
+void DesktopWindow::repositionViewport()
+{
+  int new_x, new_y;
+
+  // Deal with some scrolling corner cases:
+  //
+  // a) If the window is larger then the viewport, center the viewport.
+  // b) If the window is smaller than the viewport, make sure there is
+  //    no wasted space on the sides.
+  //
+  // FIXME: Doesn't compensate for scroll widget size properly.
+
+  new_x = viewport->x();
+  new_y = viewport->y();
+
+  if (w() > viewport->w())
+    new_x = (w() - viewport->w()) / 2;
+  else {
+    if (viewport->x() > 0)
+      new_x = 0;
+    else if (w() > (viewport->x() + viewport->w()))
+      new_x = w() - viewport->w();
+  }
+
+  // Same thing for y axis
+  if (h() > viewport->h())
+    new_y = (h() - viewport->h()) / 2;
+  else {
+    if (viewport->y() > 0)
+      new_y = 0;
+    else if (h() > (viewport->y() + viewport->h()))
+      new_y = h() - viewport->h();
+  }
+
+  if ((new_x != viewport->x()) || (new_y != viewport->y())) {
+    viewport->position(new_x, new_y);
+
+    // The scroll widget does not notice when you move around child widgets,
+    // so redraw everything to make sure things update.
+    redraw();
+  }
+}
+
 void DesktopWindow::handleClose(Fl_Widget *wnd, void *data)
 {
   exit_vncviewer();

Modified: trunk/vncviewer/DesktopWindow.h
===================================================================
--- trunk/vncviewer/DesktopWindow.h     2011-06-01 09:31:53 UTC (rev 4459)
+++ trunk/vncviewer/DesktopWindow.h     2011-06-01 09:33:00 UTC (rev 4460)
@@ -65,6 +65,8 @@
     viewport->copyRect(r, srcX, srcY);
   }
 
+  void resizeFramebuffer(int new_w, int new_h);
+
   // Fl_Window callback methods
   void resize(int x, int y, int w, int h);
 
@@ -76,6 +78,8 @@
 
   static void handleGrab(void *data);
 
+  void repositionViewport();
+
   static void handleClose(Fl_Widget *wnd, void *data);
 
   static void handleOptions(void *data);


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Simplify data backup and recovery for your virtual environment with vRanger. 
Installation's a snap, and flexible recovery options mean your data is safe,
secure and there when you need it. Data protection magic?
Nope - It's vRanger. Get your free trial download today. 
http://p.sf.net/sfu/quest-sfdev2dev
_______________________________________________
Tigervnc-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tigervnc-commits

Reply via email to