]> source.dussan.org Git - tigervnc.git/commitdiff
Allow resize of the viewport widget.
authorPierre Ossman <ossman@cendio.se>
Wed, 1 Jun 2011 09:31:53 +0000 (09:31 +0000)
committerPierre Ossman <ossman@cendio.se>
Wed, 1 Jun 2011 09:31:53 +0000 (09:31 +0000)
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4459 3789f03b-4d11-0410-bbf8-ca57d06f2519

vncviewer/Viewport.cxx
vncviewer/Viewport.h

index 3dd53e2fc12008c7e68f64b5b6345117503bc6bc..e574903c098cfbf00ae1ed1b6ca0769e0452f43d 100644 (file)
@@ -196,6 +196,48 @@ void Viewport::draw()
 }
 
 
+void Viewport::resize(int x, int y, int w, int h)
+{
+  rfb::ManagedPixelBuffer* newBuffer;
+  rfb::Rect rect;
+
+  // FIXME: Resize should probably be a feature of ManagedPixelBuffer
+
+  if ((w == frameBuffer->width()) && (h == frameBuffer->height()))
+    goto end;
+
+  newBuffer = new ManagedPixelBuffer(frameBuffer->getPF(), w, h);
+  assert(newBuffer);
+
+  rect.setXYWH(0, 0,
+               __rfbmin(newBuffer->width(), frameBuffer->width()),
+               __rfbmin(newBuffer->height(), frameBuffer->height()));
+  newBuffer->imageRect(rect, frameBuffer->data, frameBuffer->getStride());
+
+  // Black out any new areas
+
+  if (newBuffer->width() > frameBuffer->width()) {
+    rect.setXYWH(frameBuffer->width(), 0,
+                 newBuffer->width() - frameBuffer->width(),
+                 newBuffer->height());
+    newBuffer->fillRect(rect, 0);
+  }
+
+  if (newBuffer->height() > frameBuffer->height()) {
+    rect.setXYWH(0, frameBuffer->height(),
+                 newBuffer->width(),
+                 newBuffer->height() - frameBuffer->height());
+    newBuffer->fillRect(rect, 0);
+  }
+
+  delete frameBuffer;
+  frameBuffer = newBuffer;
+
+end:
+  Fl_Widget::resize(x, y, w, h);
+}
+
+
 int Viewport::handle(int event)
 {
   char *buffer;
index f3f60be93fb0d9f922e41c9ced24d5dfe5913b09..293eb93b26c9d892ff7169146ead9290a61aef9b 100644 (file)
@@ -79,7 +79,11 @@ public:
   }
 
   // Fl_Widget callback methods
+
   void draw();
+
+  void resize(int x, int y, int w, int h);
+
   int handle(int event);
 
 private: