aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2025-02-05 12:52:27 +0100
committerPierre Ossman <ossman@cendio.se>2025-02-05 14:03:51 +0100
commitf3749354c9834a9bb67e300b1c6fec3f35dad8bf (patch)
treefc15de5a852b5c267a34b31f75d097f85f8d9bd1 /vncviewer
parent655da47027a8f91ec39c1d107406f346900dd694 (diff)
downloadtigervnc-f3749354c9834a9bb67e300b1c6fec3f35dad8bf.tar.gz
tigervnc-f3749354c9834a9bb67e300b1c6fec3f35dad8bf.zip
Move all remote resize details to remoteResize()
This complex logic is difficult to understand when it is spread out. Change DesktopWindow::remoteResize() to be a request to resize instead, and let it decide fully if and when it will honour that request. Note that this slightly changes the behaviour of -DesktopSize. It will no longer override the -RemoteResize setting.
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/DesktopWindow.cxx81
-rw-r--r--vncviewer/DesktopWindow.h5
2 files changed, 33 insertions, 53 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index e5933c53..48b975b2 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -83,7 +83,7 @@ DesktopWindow::DesktopWindow(int w, int h, const char *name,
CConn* cc_)
: Fl_Window(w, h), cc(cc_), offscreen(nullptr), overlay(nullptr),
firstUpdate(true),
- delayedFullscreen(false), delayedDesktopSize(false),
+ delayedFullscreen(false), sentDesktopSize(false),
keyboardGrabbed(false), mouseGrabbed(false),
statsLastUpdates(0), statsLastPixels(0), statsLastPosition(0),
statsGraph(nullptr)
@@ -339,15 +339,8 @@ void DesktopWindow::setName(const char *name)
void DesktopWindow::updateWindow()
{
if (firstUpdate) {
- if (cc->server.supportsSetDesktopSize) {
- // Hack: Wait until we're in the proper mode and position until
- // resizing things, otherwise we might send the wrong thing.
- if (delayedFullscreen)
- delayedDesktopSize = true;
- else
- handleDesktopSize();
- }
firstUpdate = false;
+ remoteResize();
}
viewport->updateWindow();
@@ -697,21 +690,10 @@ void DesktopWindow::resize(int x, int y, int w, int h)
Fl_Window::resize(x, y, w, h);
if (resizing) {
- // Try to get the remote size to match our window size, provided
- // the following conditions are true:
- //
- // a) The user has this feature turned on
- // b) The server supports it
- // c) We're not still waiting for a chance to handle DesktopSize
- // d) We're not still waiting for startup fullscreen to kick in
- //
- if (not firstUpdate and not delayedFullscreen and
- ::remoteResize and cc->server.supportsSetDesktopSize) {
- // We delay updating the remote desktop as we tend to get a flood
- // of resize events as the user is dragging the window.
- Fl::remove_timeout(handleResizeTimeout, this);
- Fl::add_timeout(0.5, handleResizeTimeout, this);
- }
+ // We delay updating the remote desktop as we tend to get a flood
+ // of resize events as the user is dragging the window.
+ Fl::remove_timeout(handleResizeTimeout, this);
+ Fl::add_timeout(0.5, handleResizeTimeout, this);
repositionWidgets();
}
@@ -1290,32 +1272,13 @@ void DesktopWindow::maximizeWindow()
}
-void DesktopWindow::handleDesktopSize()
-{
- if (strcmp(desktopSize, "") != 0) {
- int width, height;
-
- // An explicit size has been requested
-
- if (sscanf(desktopSize, "%dx%d", &width, &height) != 2)
- return;
-
- remoteResize(width, height);
- } else if (::remoteResize) {
- // No explicit size, but remote resizing is on so make sure it
- // matches whatever size the window ended up being
- remoteResize(w(), h());
- }
-}
-
-
void DesktopWindow::handleResizeTimeout(void *data)
{
DesktopWindow *self = (DesktopWindow *)data;
assert(self);
- self->remoteResize(self->w(), self->h());
+ self->remoteResize();
}
@@ -1330,11 +1293,33 @@ void DesktopWindow::reconfigureFullscreen(void* /*data*/)
}
-void DesktopWindow::remoteResize(int width, int height)
+void DesktopWindow::remoteResize()
{
+ int width, height;
ScreenSet layout;
ScreenSet::const_iterator iter;
+ if (!::remoteResize)
+ return;
+ if (!cc->server.supportsSetDesktopSize)
+ return;
+
+ // Don't pester the server with a resize until we have our final size
+ if (delayedFullscreen)
+ return;
+
+ width = w();
+ height = h();
+
+ if (!sentDesktopSize && (strcmp(desktopSize, "") != 0)) {
+ // An explicit size has been requested
+
+ if (sscanf(desktopSize, "%dx%d", &width, &height) != 2)
+ return;
+
+ sentDesktopSize = true;
+ }
+
if (!fullscreen_active() || (width > w()) || (height > h())) {
// In windowed mode (or the framebuffer is so large that we need
// to scroll) we just report a single virtual screen that covers
@@ -1573,11 +1558,7 @@ void DesktopWindow::handleFullscreenTimeout(void *data)
assert(self);
self->delayedFullscreen = false;
-
- if (self->delayedDesktopSize) {
- self->handleDesktopSize();
- self->delayedDesktopSize = false;
- }
+ self->remoteResize();
}
void DesktopWindow::scrollTo(int x, int y)
diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h
index ce7960ce..8ac19c45 100644
--- a/vncviewer/DesktopWindow.h
+++ b/vncviewer/DesktopWindow.h
@@ -101,10 +101,9 @@ private:
void maximizeWindow();
- void handleDesktopSize();
static void handleResizeTimeout(void *data);
static void reconfigureFullscreen(void *data);
- void remoteResize(int width, int height);
+ void remoteResize();
void repositionWidgets();
@@ -131,7 +130,7 @@ private:
bool firstUpdate;
bool delayedFullscreen;
- bool delayedDesktopSize;
+ bool sentDesktopSize;
bool keyboardGrabbed;
bool mouseGrabbed;