summaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2011-06-01 09:33:00 +0000
committerPierre Ossman <ossman@cendio.se>2011-06-01 09:33:00 +0000
commit6455d851c778cd660c72bb495e3fa7e37829ae46 (patch)
tree21af261b4a655aaf897fdbf236cb1820fadec2ec /vncviewer
parente00f0aa62b8631456dce54a82211cd779f99ae68 (diff)
downloadtigervnc-6455d851c778cd660c72bb495e3fa7e37829ae46.tar.gz
tigervnc-6455d851c778cd660c72bb495e3fa7e37829ae46.zip
Handle framebuffer resize requests.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@4460 3789f03b-4d11-0410-bbf8-ca57d06f2519
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/CConn.cxx6
-rw-r--r--vncviewer/DesktopWindow.cxx107
-rw-r--r--vncviewer/DesktopWindow.h4
3 files changed, 89 insertions, 28 deletions
diff --git a/vncviewer/CConn.cxx b/vncviewer/CConn.cxx
index bc7b9489..3a6c038d 100644
--- a/vncviewer/CConn.cxx
+++ b/vncviewer/CConn.cxx
@@ -398,14 +398,10 @@ void CConn::setCursor(int width, int height, const Point& hotspot,
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
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index 0e438e7f..8350a42f 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -144,35 +144,53 @@ void DesktopWindow::updateWindow()
}
-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::handleGrab(void *data)
}
+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();
diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h
index 9378d7bf..ec7b05b7 100644
--- a/vncviewer/DesktopWindow.h
+++ b/vncviewer/DesktopWindow.h
@@ -65,6 +65,8 @@ public:
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 @@ private:
static void handleGrab(void *data);
+ void repositionViewport();
+
static void handleClose(Fl_Widget *wnd, void *data);
static void handleOptions(void *data);