Skip to content

Commit 211f124

Browse files
committed
Fix projection window not overlaying menu bar on Mac OS
1 parent c81cc89 commit 211f124

File tree

4 files changed

+44
-3
lines changed

4 files changed

+44
-3
lines changed

src/macwindowhelper.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// macwindowhelper.h
2+
#pragma once
3+
4+
#include <QWidget>
5+
6+
#if defined(Q_OS_MAC)
7+
void makeWindowCoverMenuBar(QWidget *widget);
8+
#else
9+
inline void makeWindowCoverMenuBar(QWidget *) {}
10+
#endif

src/macwindowhelper.mm

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// macwindowhelper.mm
2+
#import "macwindowhelper.h"
3+
4+
#if defined(Q_OS_MAC)
5+
#import <AppKit/AppKit.h>
6+
7+
void makeWindowCoverMenuBar(QWidget *widget) {
8+
if (!widget) return;
9+
10+
NSView *nativeView = (__bridge NSView *)widget->winId();
11+
if (!nativeView) return;
12+
13+
NSWindow *nsWindow = [nativeView window];
14+
if (!nsWindow) return;
15+
16+
[nsWindow setLevel:NSMainMenuWindowLevel + 1];
17+
[nsWindow setStyleMask:NSWindowStyleMaskBorderless];
18+
}
19+
#endif

src/projectionwindow.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* You should have received a copy of the GNU General Public License
1515
* along with Subtivals. If not, see <http://www.gnu.org/licenses/>
1616
**/
17+
1718
#include <QtCore/QSettings>
1819
#include <QtCore/qmath.h>
1920
#include <QtGui/QCursor>
@@ -22,19 +23,23 @@
2223

2324
#include "subtitlestyle.h"
2425
#include "projectionwindow.h"
26+
#include "macwindowhelper.h"
2527

2628
ProjectionWindow::ProjectionWindow(QWidget *parent)
2729
: SubtitlesForm(parent), m_hideDesktop(false), m_monitor(-1),
2830
m_resizable(false) {
29-
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint |
30-
Qt::X11BypassWindowManagerHint;
31+
Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint;
3132
#ifdef WIN32
3233
flags |= Qt::SubWindow;
34+
#endif
35+
#ifdef Q_OS_LINUX
36+
flags |= Qt::X11BypassWindowManagerHint;
3337
#endif
3438
setStyleSheet("background:transparent;");
3539
setAttribute(Qt::WA_TranslucentBackground);
3640
setWindowFlags(flags);
3741
setCursor(QCursor(Qt::BlankCursor));
42+
makeWindowCoverMenuBar(this);
3843
}
3944

4045
ProjectionWindow::~ProjectionWindow() {}

src/subtivals.pro

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,14 @@ HEADERS += mainwindow.h \
4343
styleadvanced.h \
4444
shortcuteditor.h \
4545
wizard.h \
46-
weblive.h
46+
weblive.h \
47+
macwindowhelper.h
48+
49+
OBJECTIVE_SOURCES += macwindowhelper.mm
50+
51+
macx {
52+
QMAKE_MACOSX_DEPLOYMENT_TARGET = 10.15
53+
}
4754

4855
FORMS += mainwindow.ui \
4956
subtitlesform.ui \

0 commit comments

Comments
 (0)