aboutsummaryrefslogtreecommitdiffstats
path: root/vncviewer
diff options
context:
space:
mode:
authorHugo Lundin <hugo@lundin.dev>2021-07-16 13:26:08 +0200
committerHugo Lundin <hugo@lundin.dev>2021-07-16 15:43:14 +0200
commitf4423b410c4f83b5679b959096f15bd631c2318a (patch)
treef44dc01591563e9c3e21343148a6a2ed36c1c60a /vncviewer
parent2289342de7222e4ff2483eae95bb9898830e6097 (diff)
downloadtigervnc-f4423b410c4f83b5679b959096f15bd631c2318a.tar.gz
tigervnc-f4423b410c4f83b5679b959096f15bd631c2318a.zip
Release displays not enclosed by the window
cocoa_capture_displays it captures all displays enclosed by the window_rect. If a set of displays were captured, but the configuration of what monitors to use changed, a second call would only add to the set of captured displays. Therefore, if the user enabled FullScreenAllMonitors (all displays captured) and then disabled it (only one display captured) they would get into a state were monitors not used for the VNC session still were captured (which on macOS for example, results in displays being unusable for other things). This has now been fixed, resulting in monitors outside the window_rect not being unnecessarily captured.
Diffstat (limited to 'vncviewer')
-rw-r--r--vncviewer/DesktopWindow.cxx5
-rw-r--r--vncviewer/cocoa.mm42
2 files changed, 28 insertions, 19 deletions
diff --git a/vncviewer/DesktopWindow.cxx b/vncviewer/DesktopWindow.cxx
index 1278e16c..e7f91f02 100644
--- a/vncviewer/DesktopWindow.cxx
+++ b/vncviewer/DesktopWindow.cxx
@@ -608,6 +608,11 @@ void DesktopWindow::resize(int x, int y, int w, int h)
repositionWidgets();
}
+
+ // Some systems require a grab after the window size has been changed.
+ // Otherwise they might hold on to displays, resulting in them being unusable.
+ if (fullscreen_active() && fullscreenSystemKeys)
+ grabKeyboard();
}
diff --git a/vncviewer/cocoa.mm b/vncviewer/cocoa.mm
index d6596d34..dca1afa4 100644
--- a/vncviewer/cocoa.mm
+++ b/vncviewer/cocoa.mm
@@ -56,34 +56,38 @@ int cocoa_capture_displays(Fl_Window *win)
nsw = (NSWindow*)fl_xid(win);
- if (!captured) {
- CGDisplayCount count;
- CGDirectDisplayID displays[16];
+ CGDisplayCount count;
+ CGDirectDisplayID displays[16];
- int sx, sy, sw, sh;
- rfb::Rect windows_rect, screen_rect;
+ int sx, sy, sw, sh;
+ rfb::Rect windows_rect, screen_rect;
- windows_rect.setXYWH(win->x(), win->y(), win->w(), win->h());
+ windows_rect.setXYWH(win->x(), win->y(), win->w(), win->h());
- if (CGGetActiveDisplayList(16, displays, &count) != kCGErrorSuccess)
- return 1;
+ if (CGGetActiveDisplayList(16, displays, &count) != kCGErrorSuccess)
+ return 1;
- if (count != (unsigned)Fl::screen_count())
- return 1;
+ if (count != (unsigned)Fl::screen_count())
+ return 1;
- for (int i = 0; i < Fl::screen_count(); i++) {
- Fl::screen_xywh(sx, sy, sw, sh, i);
+ for (int i = 0; i < Fl::screen_count(); i++) {
+ Fl::screen_xywh(sx, sy, sw, sh, i);
- screen_rect.setXYWH(sx, sy, sw, sh);
- if (screen_rect.enclosed_by(windows_rect)) {
- if (CGDisplayCapture(displays[i]) != kCGErrorSuccess)
- return 1;
- }
- }
+ screen_rect.setXYWH(sx, sy, sw, sh);
+ if (screen_rect.enclosed_by(windows_rect)) {
+ if (CGDisplayCapture(displays[i]) != kCGErrorSuccess)
+ return 1;
- captured = true;
+ } else {
+ // A display might have been captured with the previous
+ // monitor selection. In that case we don't want to keep
+ // it when its no longer inside the window_rect.
+ CGDisplayRelease(displays[i]);
+ }
}
+ captured = true;
+
if ([nsw level] == CGShieldingWindowLevel())
return 0;