aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--vncviewer/Viewport.cxx42
-rw-r--r--vncviewer/Viewport.h4
2 files changed, 46 insertions, 0 deletions
diff --git a/vncviewer/Viewport.cxx b/vncviewer/Viewport.cxx
index 3dd53e2f..e574903c 100644
--- a/vncviewer/Viewport.cxx
+++ b/vncviewer/Viewport.cxx
@@ -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;
diff --git a/vncviewer/Viewport.h b/vncviewer/Viewport.h
index f3f60be9..293eb93b 100644
--- a/vncviewer/Viewport.h
+++ b/vncviewer/Viewport.h
@@ -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: