-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathqcocoaintegration-presentationoptions.patch
39 lines (35 loc) · 2.04 KB
/
qcocoaintegration-presentationoptions.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From b808c0099ac5880ef06f419c1017146ce40953d1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?=
Date: Wed, 13 Apr 2016 17:09:06 +0200
Subject: OS X: Fix available geometry at startup when menu bar is hidden
Later versions of OS X allow you to auto-hide the menu bar, which should
free up 22 pixels vertically at the top of the screen in the available
geometry. Due to how the NSScreens are invalidated (asynchronously), we
pick up this geometry change too late, resulting in QWindows maximizing
as if the menu bar was still there.
To work around this we explicitly tell the system to apply the default
presentation options before initializing the QScreen properties, which
results in the NSScreen being invalidated synchronously and having the
right available geometry.
Change-Id: I40d6ef2211165d53e0825173e3b6c6c17a5a954e
Reviewed-by: Jake Petroules <[email protected]>
---
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -197,6 +197,16 @@
[cocoaApplication setMenu:[qtMenuLoader menu]];
}
+ // The presentation options such as whether or not the dock and/or menu bar is
+ // hidden (automatically by the system) affects the main screen's available
+ // geometry. Since we're initializing the screens synchronously at application
+ // startup we need to ensure that the presentation options have been propagated
+ // to the screen before we read out its properties. Normally OS X does this in
+ // an asynchronous callback, but that's too late for us. We force the propagation
+ // by explicitly setting the presentation option to the magic 'default value',
+ // which will resolve to an actual value and result in screen invalidation.
+ cocoaApplication.presentationOptions = NSApplicationPresentationDefault;
+
m_screensObserver = QMacNotificationObserver([NSApplication sharedApplication],
NSApplicationDidChangeScreenParametersNotification, [&]() { updateScreens(); });
updateScreens();