diff options
author | Pierre Ossman <ossman@cendio.se> | 2021-09-02 16:51:03 +0200 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2021-09-02 16:51:03 +0200 |
commit | 238a309aa1a94cb19fd1c364a58f40dec38d49b6 (patch) | |
tree | 2f59b7a319d3f596e2e977443795538ad5c7758b | |
parent | 4d4e3b28973f6e5d3ab42833c922e79ed6148f0f (diff) | |
parent | abb393139dcde536e7aafc8fcfbb8eb0b713ddc2 (diff) | |
download | tigervnc-238a309aa1a94cb19fd1c364a58f40dec38d49b6.tar.gz tigervnc-238a309aa1a94cb19fd1c364a58f40dec38d49b6.zip |
Merge branch 'fullscreens-added-removed' of https://github.com/x11clone/x11clone
-rw-r--r-- | vncviewer/DesktopWindow.cxx | 39 | ||||
-rw-r--r-- | vncviewer/DesktopWindow.h | 1 |
2 files changed, 40 insertions, 0 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx index 7936deb7..ef023a5b 100644 --- a/vncviewer/DesktopWindow.cxx +++ b/vncviewer/DesktopWindow.cxx @@ -71,6 +71,10 @@ using namespace rfb; static rfb::LogWriter vlog("DesktopWindow"); +// Global due to http://www.fltk.org/str.php?L2177 and the similar +// issue for Fl::event_dispatch. +static DesktopWindow *staticSelf = NULL; + DesktopWindow::DesktopWindow(int w, int h, const char *name, const rfb::PixelFormat& serverPF, CConn* cc_) @@ -105,6 +109,8 @@ DesktopWindow::DesktopWindow(int w, int h, const char *name, OptionsDialog::addCallback(handleOptions, this); + staticSelf = this; + // Hack. See below... Fl::event_dispatch(&fltkHandle); @@ -227,6 +233,8 @@ DesktopWindow::~DesktopWindow() delete statsGraph; + staticSelf = NULL; + // FLTK automatically deletes all child widgets, so we shouldn't touch // them ourselves here } @@ -828,6 +836,15 @@ int DesktopWindow::handle(int event) } +void DesktopWindow::reconfigureFullscreen(void *data) +{ + DesktopWindow *self = (DesktopWindow *)data; + + assert(self); + self->fullscreen_on(); +} + + int DesktopWindow::fltkHandle(int event, Fl_Window *win) { int ret; @@ -840,6 +857,28 @@ int DesktopWindow::fltkHandle(int event, Fl_Window *win) ret = Fl::handle_(event, win); + switch (event) { + case FL_SCREEN_CONFIGURATION_CHANGED: + // Screens removed or added. Recreate fullscreen window if + // necessary. On Windows, adding a second screen only works + // reliable if we are using a timer. Otherwise, the window will + // not be resized to cover the new screen. A timer makes sense + // also on other systems, to make sure that whatever desktop + // environment has a chance to deal with things before we do. + // Please note that when using FullscreenSystemKeys on macOS, the + // display configuration cannot be changed: macOS will not detect + // added or removed screens and there will be no + // FL_SCREEN_CONFIGURATION_CHANGED event. This is by design: + // "When you capture a display, you have exclusive use of the + // display. Other applications and system services are not allowed + // to use the display or change its configuration. In addition, + // they are not notified of display changes" + if (staticSelf->fullscreen_active()) { + Fl::remove_timeout(reconfigureFullscreen, staticSelf); + Fl::add_timeout(0.5, reconfigureFullscreen, staticSelf); + } + } + // This is hackish and the result of the dodgy focus handling in FLTK. // The basic problem is that FLTK's view of focus and the system's tend // to differ, and as a result we do not see all the FL_FOCUS events we diff --git a/vncviewer/DesktopWindow.h b/vncviewer/DesktopWindow.h index 67be6c6a..2f23d781 100644 --- a/vncviewer/DesktopWindow.h +++ b/vncviewer/DesktopWindow.h @@ -105,6 +105,7 @@ private: void handleDesktopSize(); static void handleResizeTimeout(void *data); + static void reconfigureFullscreen(void *data); void remoteResize(int width, int height); void repositionWidgets(); |