From: Pierre Ossman Date: Thu, 30 Dec 2021 12:04:59 +0000 (+0100) Subject: Avoid creating windows larger than current monitor X-Git-Tag: v1.12.90~68 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=805252edc0015e8c505a8f203b896f86ad5ebc01;p=tigervnc.git 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. --- 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...