Browse Source

UI: Make macOS 'always on top' more aggressive

Applications like Keynote, in full screen mode, cover up OBS.

This change forces windows that have been set as 'always on top' (eg.
projector windows) to sit above Keynote's full screen view by
manipulating the NSWindow's level attribute.
Jon Topper 5 years ago
parent
commit
87e90ee8a4
1 changed files with 10 additions and 2 deletions
  1. 10 2
      UI/platform-osx.mm

+ 10 - 2
UI/platform-osx.mm

@@ -148,10 +148,18 @@ void SetAlwaysOnTop(QWidget *window, bool enable)
 {
 	Qt::WindowFlags flags = window->windowFlags();
 
-	if (enable)
+	if (enable) {
+		/* Force the level of the window high so it sits on top of
+		 * full-screen applications like Keynote */
+		NSView *nsv = (__bridge NSView *)reinterpret_cast<void *>(
+			window->winId());
+		NSWindow *nsw = nsv.window;
+		[nsw setLevel:1024];
+
 		flags |= Qt::WindowStaysOnTopHint;
-	else
+	} else {
 		flags &= ~Qt::WindowStaysOnTopHint;
+	}
 
 	window->setWindowFlags(flags);
 	window->show();