]> source.dussan.org Git - tigervnc.git/commitdiff
Workaround options window appearing behind viewer 1349/head
authorSamuel Mannehed <samuel@cendio.se>
Wed, 6 Oct 2021 12:06:22 +0000 (14:06 +0200)
committerSamuel Mannehed <samuel@cendio.se>
Wed, 6 Oct 2021 13:03:22 +0000 (15:03 +0200)
FLTK's fullscreen_x() function will always put the window on a high
level (NSStatusWindowLevel = 25), even if the window doesn't have focus.
This causes the OptionsDialog to end up behind the DesktopWindow when
the fullscreen function is called. Until we can rest assured that most
people building TigerVNC will use a fixed version of FLTK, we will need
this workaround.

vncviewer/DesktopWindow.cxx
vncviewer/cocoa.h
vncviewer/cocoa.mm

index d379a712f92bc0f113662187ebd42c3ede064455..f334c61449eac0dce8e901e25ce30243a6a32c4d 100644 (file)
@@ -918,12 +918,11 @@ void DesktopWindow::fullscreen_on()
 {
   bool allMonitors = !strcasecmp(fullScreenMode, "all");
   bool selectedMonitors = !strcasecmp(fullScreenMode, "selected");
+  int top, bottom, left, right;
 
   if (not selectedMonitors and not allMonitors) {
-    int n = Fl::screen_num(x(), y(), w(), h());
-    fullscreen_screens(n, n, n, n);
+    top = bottom = left = right = Fl::screen_num(x(), y(), w(), h());
   } else {
-    int top, bottom, left, right;
     int top_y, bottom_y, left_x, right_x;
 
     int sx, sy, sw, sh;
@@ -983,8 +982,17 @@ void DesktopWindow::fullscreen_on()
       }
     }
 
-    fullscreen_screens(top, bottom, left, right);
   }
+#ifdef __APPLE__
+  // This is a workaround for a bug in FLTK, see: https://github.com/fltk/fltk/pull/277
+  int savedLevel;
+  savedLevel = cocoa_get_level(this);
+#endif
+  fullscreen_screens(top, bottom, left, right);
+#ifdef __APPLE__
+  // This is a workaround for a bug in FLTK, see: https://github.com/fltk/fltk/pull/277
+  cocoa_set_level(this, savedLevel);
+#endif
 
   if (!fullscreen_active())
     fullscreen();
index 083400383e216111b79871cd2289cef3b044c5e2..ca17ddf9da66658002e1e4f05bcc5f000d9a0a86 100644 (file)
@@ -21,6 +21,9 @@
 
 class Fl_Window;
 
+int cocoa_get_level(Fl_Window *win);
+void cocoa_set_level(Fl_Window *win, int level);
+
 int cocoa_capture_displays(Fl_Window *win);
 void cocoa_release_displays(Fl_Window *win);
 
index dca1afa41f20e9c20374cfc8bb3bd3d1186ad46c..e8764f52a7d7c88e11ce4d1105d54dab56e424e7 100644 (file)
@@ -50,6 +50,20 @@ const int kVK_Menu = 0x6E;
 
 static bool captured = false;
 
+int cocoa_get_level(Fl_Window *win)
+{
+  NSWindow *nsw;
+  nsw = (NSWindow*)fl_xid(win);
+  return [nsw level];
+}
+
+void cocoa_set_level(Fl_Window *win, int level)
+{
+  NSWindow *nsw;
+  nsw = (NSWindow*)fl_xid(win);
+  [nsw setLevel:level];
+}
+
 int cocoa_capture_displays(Fl_Window *win)
 {
   NSWindow *nsw;