From 87e90ee8a4e45d0ccb5d17e536f13441d9fdfa64 Mon Sep 17 00:00:00 2001 From: Jon Topper Date: Mon, 27 Jul 2020 19:07:35 +0100 Subject: [PATCH] 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. --- UI/platform-osx.mm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/UI/platform-osx.mm b/UI/platform-osx.mm index b54b76448..18de5e7e9 100644 --- a/UI/platform-osx.mm +++ b/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( + window->winId()); + NSWindow *nsw = nsv.window; + [nsw setLevel:1024]; + flags |= Qt::WindowStaysOnTopHint; - else + } else { flags &= ~Qt::WindowStaysOnTopHint; + } window->setWindowFlags(flags); window->show();