aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorPierre Ossman <ossman@cendio.se>2021-12-30 13:04:59 +0100
committerPierre Ossman <ossman@cendio.se>2021-12-30 13:04:59 +0100
commit805252edc0015e8c505a8f203b896f86ad5ebc01 (patch)
treedd2d59087221542339972d1917c680e38780c466 /vncviewer
parentda49141204a3d16c3e670d3a5ecd3d16560efd82 (diff)
downloadtigervnc-805252edc0015e8c505a8f203b896f86ad5ebc01.tar.gz
tigervnc-805252edc0015e8c505a8f203b896f86ad5ebc01.zip
Avoid creating windows larger than current monitor
Many window managers don't have proper logic to restrict the window size to something sane, so we have to take care of that ourselves.
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/DesktopWindow.cxx23
1 files changed, 23 insertions, 0 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index 256d8ff8..10e26fee 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -145,6 +145,29 @@ DesktopWindow::DesktopWindow(int w, int h, const char *name,
}
}
+ // Many window managers don't properly resize overly large windows,
+ // so we'll have to do some sanity checks ourselves here
+ int sx, sy, sw, sh;
+ if (force_position()) {
+ Fl::screen_work_area(sx, sy, sw, sh, geom_x, geom_y);
+ } else {
+ int mx, my;
+
+ // If we don't explicitly request a position then we don't know which
+ // monitor the window manager might place us on. Assume the popular
+ // behaviour of following the cursor.
+
+ Fl::get_mouse(mx, my);
+ Fl::screen_work_area(sx, sy, sw, sh, mx, my);
+ }
+ if ((w > sw) || (h > sh)) {
+ vlog.info(_("Reducing window size to fit on current monitor"));
+ if (w > sw)
+ w = sw;
+ if (h > sh)
+ h = sh;
+ }
+
#ifdef __APPLE__
// On OS X we can do the maximize thing properly before the
// window is showned. Other platforms handled further down...