Cross-Platform build scripts for audio plugins
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

752 lines
34KB

  1. diff --git a/mkspecs/common/clang-mac.conf b/mkspecs/common/clang-mac.conf
  2. index cbae2e6..ed6132c 100644
  3. --- a/mkspecs/common/clang-mac.conf
  4. +++ b/mkspecs/common/clang-mac.conf
  5. @@ -10,4 +10,4 @@ QMAKE_CXXFLAGS += -stdlib=libc++
  6. QMAKE_LFLAGS += -stdlib=libc++
  7. QMAKE_AR_LTCG = libtool -static -o
  8. -QMAKE_CFLAGS_APPLICATION_EXTENSION = -fapplication-extension
  9. +QMAKE_CFLAGS_APPLICATION_EXTENSION =
  10. diff --git a/src/corelib/global/qoperatingsystemversion_darwin.mm b/src/corelib/global/qoperatingsystemversion_darwin.mm
  11. index d8b927f..9a690ad 100644
  12. --- a/src/corelib/global/qoperatingsystemversion_darwin.mm
  13. +++ b/src/corelib/global/qoperatingsystemversion_darwin.mm
  14. @@ -40,16 +40,37 @@
  15. #include "qoperatingsystemversion_p.h"
  16. #import <Foundation/Foundation.h>
  17. +typedef qint16 (*GestaltFunction)(quint32 selector, qint32 *response);
  18. +
  19. QT_BEGIN_NAMESPACE
  20. QOperatingSystemVersion QOperatingSystemVersion::current()
  21. {
  22. - NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
  23. QOperatingSystemVersion v;
  24. v.m_os = currentType();
  25. - v.m_major = osv.majorVersion;
  26. - v.m_minor = osv.minorVersion;
  27. - v.m_micro = osv.patchVersion;
  28. + v.m_major = -1;
  29. + v.m_minor = -1;
  30. + v.m_micro = -1;
  31. + static GestaltFunction pGestalt = 0;
  32. + if (!pGestalt) {
  33. + CFBundleRef b = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreServices"));
  34. + pGestalt = reinterpret_cast<GestaltFunction>(CFBundleGetFunctionPointerForName(b,
  35. + CFSTR("Gestalt")));
  36. + }
  37. + // Use temporary variables so we can return 0.0.0 (unknown version)
  38. + // in case of an error partway through determining the OS version
  39. + qint32 major = 0, minor = 0, patch = 0;
  40. + if (!pGestalt)
  41. + return v;
  42. + if (pGestalt('sys1', &major) != 0)
  43. + return v;
  44. + if (pGestalt('sys2', &minor) != 0)
  45. + return v;
  46. + if (pGestalt('sys3', &patch) != 0)
  47. + return v;
  48. + v.m_major = major;
  49. + v.m_minor = minor;
  50. + v.m_micro = patch;
  51. return v;
  52. }
  53. diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
  54. index 7fed54f..bbf5e6d 100644
  55. --- a/src/corelib/io/qfilesystemengine_unix.cpp
  56. +++ b/src/corelib/io/qfilesystemengine_unix.cpp
  57. @@ -126,8 +126,11 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
  58. #ifdef Q_OS_MACOS
  59. // Find if an application other than Finder claims to know how to handle the package
  60. - QCFType<CFURLRef> application = LSCopyDefaultApplicationURLForURL(url,
  61. - kLSRolesEditor | kLSRolesViewer, nullptr);
  62. + QCFType<CFURLRef> application;
  63. + LSGetApplicationForURL(url,
  64. + kLSRolesEditor|kLSRolesViewer,
  65. + NULL,
  66. + &application);
  67. if (application) {
  68. QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application);
  69. diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm
  70. index 56eabc4..c48a797 100644
  71. --- a/src/corelib/kernel/qcore_foundation.mm
  72. +++ b/src/corelib/kernel/qcore_foundation.mm
  73. @@ -46,7 +46,7 @@
  74. #include <QtCore/qbytearray.h>
  75. #include <QtCore/qrect.h>
  76. -#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE)
  77. +#if 0
  78. #include <QtCore/qtimezone.h>
  79. #include <QtCore/private/qtimezoneprivate_p.h>
  80. #include <QtCore/private/qcore_mac_p.h>
  81. @@ -433,7 +433,7 @@ NSDate *QDateTime::toNSDate() const
  82. // ----------------------------------------------------------------------------
  83. -#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE)
  84. +#if 0
  85. /*!
  86. \since 5.9
  87. diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h
  88. index bd87139..d154cbf 100644
  89. --- a/src/corelib/tools/qtimezone.h
  90. +++ b/src/corelib/tools/qtimezone.h
  91. @@ -47,7 +47,7 @@
  92. QT_REQUIRE_CONFIG(timezone);
  93. -#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE)
  94. +#if 0
  95. Q_FORWARD_DECLARE_CF_TYPE(CFTimeZone);
  96. Q_FORWARD_DECLARE_OBJC_CLASS(NSTimeZone);
  97. #endif
  98. @@ -147,7 +147,7 @@ public:
  99. static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId,
  100. QLocale::Country country);
  101. -#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE)
  102. +#if 0
  103. static QTimeZone fromCFTimeZone(CFTimeZoneRef timeZone);
  104. CFTimeZoneRef toCFTimeZone() const Q_DECL_CF_RETURNS_RETAINED;
  105. static QTimeZone fromNSTimeZone(const NSTimeZone *timeZone);
  106. diff --git a/src/gui/painting/qcoregraphics.mm b/src/gui/painting/qcoregraphics.mm
  107. index c4fb8af..91875cd 100644
  108. --- a/src/gui/painting/qcoregraphics.mm
  109. +++ b/src/gui/painting/qcoregraphics.mm
  110. @@ -47,6 +47,21 @@
  111. #include <QtCore/qcoreapplication.h>
  112. #include <QtCore/qoperatingsystemversion.h>
  113. +@interface NSGraphicsContext (QtAdditions)
  114. +
  115. ++ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState;
  116. +
  117. +@end
  118. +
  119. +@implementation NSGraphicsContext (QtAdditions)
  120. +
  121. ++ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState
  122. +{
  123. + return [self graphicsContextWithGraphicsPort:graphicsPort flipped:initialFlippedState];
  124. +}
  125. +
  126. +@end
  127. +
  128. QT_BEGIN_NAMESPACE
  129. // ---------------------- Images ----------------------
  130. @@ -147,7 +162,7 @@ QPixmap qt_mac_toQPixmap(const NSImage *image, const QSizeF &size)
  131. QMacCGContext ctx(&pixmap);
  132. if (!ctx)
  133. return QPixmap();
  134. - NSGraphicsContext *gc = [NSGraphicsContext graphicsContextWithCGContext:ctx flipped:YES];
  135. + NSGraphicsContext *gc = [NSGraphicsContext qt_graphicsContextWithCGContext:ctx flipped:YES];
  136. if (!gc)
  137. return QPixmap();
  138. [NSGraphicsContext saveGraphicsState];
  139. diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
  140. index f8fe160..3c350b3 100644
  141. --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
  142. +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
  143. @@ -456,7 +456,6 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QFontEngineFT>::fontEngine(const
  144. return QFontEngineFT::create(*fontData, fontDef.pixelSize,
  145. static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
  146. } else if (NSURL *url = descriptorAttribute<NSURL>(descriptor, kCTFontURLAttribute)) {
  147. - Q_ASSERT(url.fileURL);
  148. QFontEngine::FaceId faceId;
  149. faceId.filename = QString::fromNSString(url.path).toUtf8();
  150. return QFontEngineFT::create(fontDef, faceId);
  151. diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
  152. index aa61245..2423378 100644
  153. --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
  154. +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
  155. @@ -78,7 +78,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
  156. mHelper = 0;
  157. mStolenContentView = 0;
  158. mPanelButtons = nil;
  159. - mResultCode = NSModalResponseCancel;
  160. + mResultCode = NSCancelButton;
  161. mDialogIsExecuting = false;
  162. mResultSet = false;
  163. mClosingDueToKnownButton = false;
  164. @@ -166,7 +166,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
  165. mClosingDueToKnownButton = true;
  166. [mColorPanel close];
  167. [self updateQtColor];
  168. - [self finishOffWithCode:NSModalResponseOK];
  169. + [self finishOffWithCode:NSOKButton];
  170. }
  171. - (void)onCancelClicked
  172. @@ -175,7 +175,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
  173. mClosingDueToKnownButton = true;
  174. [mColorPanel close];
  175. mQtColor = QColor();
  176. - [self finishOffWithCode:NSModalResponseCancel];
  177. + [self finishOffWithCode:NSCancelButton];
  178. }
  179. }
  180. @@ -236,12 +236,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
  181. [NSApp runModalForWindow:mColorPanel];
  182. mDialogIsExecuting = false;
  183. - return (mResultCode == NSModalResponseOK);
  184. + return (mResultCode == NSOKButton);
  185. }
  186. - (QPlatformDialogHelper::DialogCode)dialogResultCode
  187. {
  188. - return (mResultCode == NSModalResponseOK) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
  189. + return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
  190. }
  191. - (BOOL)windowShouldClose:(id)window
  192. @@ -250,7 +250,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
  193. if (!mPanelButtons)
  194. [self updateQtColor];
  195. if (mDialogIsExecuting) {
  196. - [self finishOffWithCode:NSModalResponseCancel];
  197. + [self finishOffWithCode:NSCancelButton];
  198. } else {
  199. mResultSet = true;
  200. if (mHelper)
  201. @@ -276,7 +276,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
  202. // This check will prevent any such recursion.
  203. if (!mResultSet) {
  204. mResultSet = true;
  205. - if (mResultCode == NSModalResponseCancel) {
  206. + if (mResultCode == NSCancelButton) {
  207. emit mHelper->reject();
  208. } else {
  209. emit mHelper->accept();
  210. diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
  211. index b22f1b1..d2dd645 100644
  212. --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
  213. +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm
  214. @@ -401,7 +401,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
  215. // [NSApp run], which is the normal code path for cocoa applications.
  216. if (NSModalSession session = d->currentModalSession()) {
  217. QBoolBlocker execGuard(d->currentExecIsNSAppRun, false);
  218. - while ([NSApp runModalSession:session] == NSModalResponseContinue && !d->interrupt) {
  219. + while ([NSApp runModalSession:session] == NSRunContinuesResponse && !d->interrupt) {
  220. qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
  221. if (session != d->currentModalSessionCached) {
  222. // It's possible to release the current modal session
  223. @@ -445,7 +445,7 @@ bool QCocoaEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags)
  224. if (flags & QEventLoop::WaitForMoreEvents)
  225. qt_mac_waitForMoreEvents(NSModalPanelRunLoopMode);
  226. NSInteger status = [NSApp runModalSession:session];
  227. - if (status != NSModalResponseContinue && session == d->currentModalSessionCached) {
  228. + if (status != NSRunContinuesResponse && session == d->currentModalSessionCached) {
  229. // INVARIANT: Someone called [NSApp stopModal:] from outside the event
  230. // dispatcher (e.g to stop a native dialog). But that call wrongly stopped
  231. // 'session' as well. As a result, we need to restart all internal sessions:
  232. diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
  233. index 9a96895..b227794 100644
  234. --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
  235. +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm
  236. @@ -104,7 +104,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
  237. mHelper = 0;
  238. mStolenContentView = 0;
  239. mPanelButtons = 0;
  240. - mResultCode = NSModalResponseCancel;
  241. + mResultCode = NSCancelButton;
  242. mDialogIsExecuting = false;
  243. mResultSet = false;
  244. @@ -169,7 +169,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
  245. - (void)onOkClicked
  246. {
  247. [mFontPanel close];
  248. - [self finishOffWithCode:NSModalResponseOK];
  249. + [self finishOffWithCode:NSOKButton];
  250. }
  251. - (void)onCancelClicked
  252. @@ -177,7 +177,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
  253. if (mPanelButtons) {
  254. [mFontPanel close];
  255. mQtFont = QFont();
  256. - [self finishOffWithCode:NSModalResponseCancel];
  257. + [self finishOffWithCode:NSCancelButton];
  258. }
  259. }
  260. @@ -222,12 +222,12 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
  261. [NSApp runModalForWindow:mFontPanel];
  262. mDialogIsExecuting = false;
  263. - return (mResultCode == NSModalResponseOK);
  264. + return (mResultCode == NSOKButton);
  265. }
  266. - (QPlatformDialogHelper::DialogCode)dialogResultCode
  267. {
  268. - return (mResultCode == NSModalResponseOK) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
  269. + return (mResultCode == NSOKButton) ? QPlatformDialogHelper::Accepted : QPlatformDialogHelper::Rejected;
  270. }
  271. - (BOOL)windowShouldClose:(id)window
  272. @@ -236,7 +236,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
  273. if (!mPanelButtons)
  274. [self updateQtFont];
  275. if (mDialogIsExecuting) {
  276. - [self finishOffWithCode:NSModalResponseCancel];
  277. + [self finishOffWithCode:NSCancelButton];
  278. } else {
  279. mResultSet = true;
  280. if (mHelper)
  281. @@ -262,7 +262,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
  282. // This check will prevent any such recursion.
  283. if (!mResultSet) {
  284. mResultSet = true;
  285. - if (mResultCode == NSModalResponseCancel) {
  286. + if (mResultCode == NSCancelButton) {
  287. emit mHelper->reject();
  288. } else {
  289. emit mHelper->accept();
  290. diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
  291. index bac49cf..83b51cd 100644
  292. --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
  293. +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
  294. @@ -144,7 +144,7 @@ void QCocoaScreen::updateGeometry()
  295. // The reference screen for the geometry is always the primary screen, but since
  296. // we may be in the process of creating and registering the primary screen, we
  297. // must special-case that and assign it direcly.
  298. - QCocoaScreen *primaryScreen = (nsScreen == [[NSScreen screens] firstObject]) ?
  299. + QCocoaScreen *primaryScreen = (nsScreen == [[NSScreen screens] objectAtIndex:0]) ?
  300. this : static_cast<QCocoaScreen*>(QGuiApplication::primaryScreen()->handle());
  301. m_geometry = primaryScreen->mapFromNative(m_geometry).toRect();
  302. diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
  303. index e41c70b..815028b 100644
  304. --- a/src/plugins/platforms/cocoa/qcocoamenu.mm
  305. +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
  306. @@ -329,13 +329,6 @@ void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *
  307. }
  308. insertNative(cocoaItem, beforeItem);
  309. -
  310. - // Empty menus on a menubar are hidden by default. If the menu gets
  311. - // added to the menubar before it contains any item, we need to sync.
  312. - if (isVisible() && attachedItem().hidden) {
  313. - if (auto *mb = qobject_cast<QCocoaMenuBar *>(menuParent()))
  314. - mb->syncMenu(this);
  315. - }
  316. }
  317. void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
  318. diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
  319. index a4cd465..06d63f7 100644
  320. --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
  321. +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
  322. @@ -369,7 +369,7 @@ void QCocoaMenuBar::updateMenuBarImmediately()
  323. QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
  324. [loader ensureAppMenuInMenu:mb->nsMenu()];
  325. - NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:mb->merged().count()] retain];
  326. + NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:0] retain];
  327. foreach (QCocoaMenuItem *m, mb->merged()) {
  328. [mergedItems addObject:m->nsItem()];
  329. m->syncMerged();
  330. diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
  331. index 5504c24..fa0b7f7 100644
  332. --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
  333. +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
  334. @@ -172,12 +172,11 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
  335. QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
  336. {
  337. + QCFType<CFURLRef> url;
  338. const int ExpectedImageWidth = 242;
  339. const int ExpectedImageHeight = 414;
  340. - QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier(
  341. - CFSTR("com.apple.KeyboardSetupAssistant"), nullptr);
  342. - if (urls && CFArrayGetCount(urls) > 0) {
  343. - CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0);
  344. + if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"),
  345. + 0, 0, &url) == noErr) {
  346. QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
  347. if (bundle) {
  348. url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0);
  349. diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
  350. index aa8fffd..e6abf49 100644
  351. --- a/src/plugins/platforms/cocoa/qcocoawindow.h
  352. +++ b/src/plugins/platforms/cocoa/qcocoawindow.h
  353. @@ -217,7 +217,9 @@ public:
  354. Q_NOTIFICATION_HANDLER(NSWindowDidExitFullScreenNotification) void windowDidExitFullScreen();
  355. Q_NOTIFICATION_HANDLER(NSWindowDidOrderOffScreenNotification) void windowDidOrderOffScreen();
  356. Q_NOTIFICATION_HANDLER(NSWindowDidOrderOnScreenAndFinishAnimatingNotification) void windowDidOrderOnScreen();
  357. +#if 0
  358. Q_NOTIFICATION_HANDLER(NSWindowDidChangeOcclusionStateNotification) void windowDidChangeOcclusionState();
  359. +#endif
  360. Q_NOTIFICATION_HANDLER(NSWindowDidChangeScreenNotification) void windowDidChangeScreen();
  361. Q_NOTIFICATION_HANDLER(NSWindowWillCloseNotification) void windowWillClose();
  362. @@ -316,6 +318,8 @@ public: // for QNSView
  363. bool m_viewIsEmbedded; // true if the m_view is actually embedded in a "foreign" NSView hiearchy
  364. bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy
  365. + QCocoaWindow *m_parentCocoaWindow;
  366. +
  367. Qt::WindowFlags m_windowFlags;
  368. Qt::WindowState m_lastReportedWindowState;
  369. Qt::WindowModality m_windowModality;
  370. diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
  371. index 86fd7b8..5d63dea 100644
  372. --- a/src/plugins/platforms/cocoa/qcocoawindow.mm
  373. +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
  374. @@ -325,7 +325,7 @@ static void qt_closePopups()
  375. + (void)applicationActivationChanged:(NSNotification*)notification
  376. {
  377. const id sender = self;
  378. - NSEnumerator<NSWindow*> *windowEnumerator = nullptr;
  379. + NSEnumerator* windowEnumerator = nullptr;
  380. NSApplication *application = [NSApplication sharedApplication];
  381. #if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)
  382. @@ -526,6 +526,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw, WId nativeHandle)
  383. , m_nsWindow(0)
  384. , m_viewIsEmbedded(false)
  385. , m_viewIsToBeEmbedded(false)
  386. + , m_parentCocoaWindow(0)
  387. , m_lastReportedWindowState(Qt::WindowNoState)
  388. , m_windowModality(Qt::NonModal)
  389. , m_windowUnderMouse(false)
  390. @@ -594,10 +595,12 @@ QCocoaWindow::~QCocoaWindow()
  391. [m_nsWindow makeFirstResponder:nil];
  392. [m_nsWindow setContentView:nil];
  393. [m_nsWindow.helper detachFromPlatformWindow];
  394. - if (m_view.window.parentWindow)
  395. - [m_view.window.parentWindow removeChildWindow:m_view.window];
  396. - else if ([m_view superview])
  397. + if (m_view.window.parentWindow) {
  398. + if (m_parentCocoaWindow)
  399. + m_parentCocoaWindow->removeChildWindow(this);
  400. + } else if ([m_view superview]) {
  401. [m_view removeFromSuperview];
  402. + }
  403. removeMonitor();
  404. @@ -614,6 +617,7 @@ QCocoaWindow::~QCocoaWindow()
  405. foreachChildNSWindow(^(QCocoaWindow *childWindow) {
  406. [m_nsWindow removeChildWindow:childWindow->m_nsWindow];
  407. + childWindow->m_parentCocoaWindow = 0;
  408. });
  409. [m_view release];
  410. @@ -690,7 +694,7 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
  411. if (isChildNSWindow()) {
  412. QPlatformWindow::setGeometry(rect);
  413. - NSWindow *parentNSWindow = m_view.window.parentWindow;
  414. + NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
  415. NSRect parentWindowFrame = [parentNSWindow contentRectForFrameRect:parentNSWindow.frame];
  416. clipWindow(parentWindowFrame);
  417. @@ -744,7 +748,7 @@ void QCocoaWindow::clipWindow(const NSRect &clipRect)
  418. m_hiddenByClipping = false;
  419. if (!m_hiddenByAncestor) {
  420. [m_nsWindow orderFront:nil];
  421. - static_cast<QCocoaWindow *>(QPlatformWindow::parent())->reinsertChildWindow(this);
  422. + m_parentCocoaWindow->reinsertChildWindow(this);
  423. }
  424. }
  425. }
  426. @@ -781,7 +785,7 @@ void QCocoaWindow::show(bool becauseOfAncestor)
  427. if ([m_nsWindow isVisible])
  428. return;
  429. - if (m_view.window.parentWindow && !m_view.window.parentWindow.visible) {
  430. + if (m_parentCocoaWindow && ![m_parentCocoaWindow->m_nsWindow isVisible]) {
  431. m_hiddenByAncestor = true; // Parent still hidden, don't show now
  432. } else if ((becauseOfAncestor == m_hiddenByAncestor) // Was NEITHER explicitly hidden
  433. && !m_hiddenByClipping) { // ... NOR clipped
  434. @@ -792,7 +796,7 @@ void QCocoaWindow::show(bool becauseOfAncestor)
  435. if (!m_hiddenByClipping) { // setCocoaGeometry() can change the clipping status
  436. [m_nsWindow orderFront:nil];
  437. if (isChildNSWindow())
  438. - static_cast<QCocoaWindow *>(QPlatformWindow::parent())->reinsertChildWindow(this);
  439. + m_parentCocoaWindow->reinsertChildWindow(this);
  440. foreachChildNSWindow(^(QCocoaWindow *childWindow) {
  441. childWindow->show(true);
  442. });
  443. @@ -854,12 +858,7 @@ void QCocoaWindow::setVisible(bool visible)
  444. applyWindowState(window()->windowState());
  445. if (window()->windowState() != Qt::WindowMinimized) {
  446. - if ((window()->modality() == Qt::WindowModal
  447. - || window()->type() == Qt::Sheet)
  448. - && parentCocoaWindow) {
  449. - // show the window as a sheet
  450. - [parentCocoaWindow->m_nsWindow beginSheet:m_nsWindow completionHandler:nil];
  451. - } else if (window()->modality() != Qt::NonModal) {
  452. + if (window()->modality() != Qt::NonModal) {
  453. // show the window as application modal
  454. QCocoaEventDispatcher *cocoaEventDispatcher = qobject_cast<QCocoaEventDispatcher *>(QGuiApplication::instance()->eventDispatcher());
  455. Q_ASSERT(cocoaEventDispatcher != 0);
  456. @@ -919,11 +918,6 @@ void QCocoaWindow::setVisible(bool visible)
  457. if (cocoaEventDispatcherPrivate)
  458. cocoaEventDispatcherPrivate->endModalSession(window());
  459. m_hasModalSession = false;
  460. - } else {
  461. - if ([m_nsWindow isSheet]) {
  462. - Q_ASSERT_X(parentCocoaWindow, "QCocoaWindow", "Window modal dialog has no transient parent.");
  463. - [parentCocoaWindow->m_nsWindow endSheet:m_nsWindow];
  464. - }
  465. }
  466. hide();
  467. @@ -1190,7 +1184,7 @@ void QCocoaWindow::raise()
  468. // -[NSWindow orderFront:] doesn't work with attached windows.
  469. // The only solution is to remove and add the child window.
  470. // This will place it on top of all the other NSWindows.
  471. - NSWindow *parentNSWindow = m_view.window.parentWindow;
  472. + NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
  473. [parentNSWindow removeChildWindow:m_nsWindow];
  474. [parentNSWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
  475. } else {
  476. @@ -1226,7 +1220,7 @@ void QCocoaWindow::lower()
  477. // The only solution is to remove and add all the child windows except this one.
  478. // This will keep the current window at the bottom while adding the others on top of it,
  479. // hopefully in the same order (this is not documented anywhere in the Cocoa documentation).
  480. - NSWindow *parentNSWindow = m_view.window.parentWindow;
  481. + NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
  482. NSArray *children = [parentNSWindow.childWindows copy];
  483. for (NSWindow *child in children)
  484. if (m_nsWindow != child) {
  485. @@ -1528,6 +1522,7 @@ void QCocoaWindow::windowDidOrderOnScreen()
  486. exposeWindow();
  487. }
  488. +#if 0
  489. void QCocoaWindow::windowDidChangeOcclusionState()
  490. {
  491. // Several unit tests expect paint and/or expose events for windows that are
  492. @@ -1543,6 +1538,7 @@ void QCocoaWindow::windowDidChangeOcclusionState()
  493. }
  494. }
  495. }
  496. +#endif
  497. void QCocoaWindow::windowDidChangeScreen()
  498. {
  499. @@ -1698,14 +1694,15 @@ void QCocoaWindow::recreateWindowIfNeeded()
  500. qCDebug(lcQpaCocoaWindow) << "Reconfiguring NSWindow due to" << recreateReason;
  501. - QCocoaWindow *parentCocoaWindow = static_cast<QCocoaWindow *>(parentWindow);
  502. + // FIXME: Replace member with direct parentWindow usage (possibly cast)
  503. + m_parentCocoaWindow = static_cast<QCocoaWindow *>(parentWindow);
  504. if (shouldBeChildNSWindow) {
  505. QWindow *parentQWindow = parentWindow->window();
  506. // Ensure that all parents in the hierarchy are also child NSWindows
  507. if (!parentQWindow->property("_q_platform_MacUseNSWindow").toBool()) {
  508. parentQWindow->setProperty("_q_platform_MacUseNSWindow", QVariant(true));
  509. - parentCocoaWindow->recreateWindowIfNeeded();
  510. + m_parentCocoaWindow->recreateWindowIfNeeded();
  511. }
  512. }
  513. @@ -1713,8 +1710,8 @@ void QCocoaWindow::recreateWindowIfNeeded()
  514. if ((isContentView() && !shouldBeContentView) || (recreateReason & PanelChanged)) {
  515. qCDebug(lcQpaCocoaWindow) << "Getting rid of existing window" << m_nsWindow;
  516. [m_nsWindow closeAndRelease];
  517. - if (isChildNSWindow())
  518. - [m_view.window.parentWindow removeChildWindow:m_view.window];
  519. + if (isChildNSWindow() && oldParentCocoaWindow)
  520. + oldParentCocoaWindow->removeChildWindow(this);
  521. if (isContentView()) {
  522. // We explicitly disassociate m_view from the window's contentView,
  523. // as AppKit does not automatically do this in response to removing
  524. @@ -1730,9 +1727,9 @@ void QCocoaWindow::recreateWindowIfNeeded()
  525. if (noPreviousWindow)
  526. m_nsWindow = createNSWindow(shouldBeChildNSWindow, shouldBePanel);
  527. - if (m_view.window.parentWindow) {
  528. - if (!shouldBeChildNSWindow || (recreateReason & ParentChanged))
  529. - [m_view.window.parentWindow removeChildWindow:m_view.window];
  530. + if (oldParentCocoaWindow) {
  531. + if (!shouldBeChildNSWindow || oldParentCocoaWindow != m_parentCocoaWindow)
  532. + oldParentCocoaWindow->removeChildWindow(this);
  533. m_forwardWindow = oldParentCocoaWindow;
  534. }
  535. @@ -1759,8 +1756,8 @@ void QCocoaWindow::recreateWindowIfNeeded()
  536. setWindowState(window()->windowState());
  537. } else if (shouldBeChildNSWindow) {
  538. if (!m_hiddenByClipping) {
  539. - [parentCocoaWindow->m_nsWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
  540. - parentCocoaWindow->reinsertChildWindow(this);
  541. + [m_parentCocoaWindow->m_nsWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
  542. + m_parentCocoaWindow->reinsertChildWindow(this);
  543. }
  544. // Set properties after the window has been made a child NSWindow
  545. @@ -1771,7 +1768,7 @@ void QCocoaWindow::recreateWindowIfNeeded()
  546. if ([m_view superview])
  547. [m_view removeFromSuperview];
  548. - [parentCocoaWindow->m_view addSubview:m_view];
  549. + [m_parentCocoaWindow->m_view addSubview:m_view];
  550. QRect rect = windowGeometry();
  551. // Prevent setting a (0,0) window size; causes opengl context
  552. // "Invalid Drawable" warnings.
  553. @@ -1915,6 +1912,11 @@ bool QCocoaWindow::alwaysShowToolWindow() const
  554. return qt_mac_resolveOption(false, window(), "_q_macAlwaysShowToolWindow", "");
  555. }
  556. +void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
  557. +{
  558. + [m_nsWindow removeChildWindow:child->m_nsWindow];
  559. +}
  560. +
  561. void QCocoaWindow::removeMonitor()
  562. {
  563. if (!monitor)
  564. @@ -2046,12 +2048,14 @@ Qt::WindowState QCocoaWindow::windowState() const
  565. // FIXME: Support compound states (Qt::WindowStates)
  566. NSWindow *window = m_view.window;
  567. + /*
  568. if (window.miniaturized)
  569. return Qt::WindowMinimized;
  570. + */
  571. if (window.qt_fullScreen)
  572. return Qt::WindowFullScreen;
  573. - if ((window.zoomed && !isTransitioningToFullScreen())
  574. - || (m_lastReportedWindowState == Qt::WindowMaximized && isTransitioningToFullScreen()))
  575. + if (/*(window.zoomed && !isTransitioningToFullScreen())
  576. + ||*/ (m_lastReportedWindowState == Qt::WindowMaximized && isTransitioningToFullScreen()))
  577. return Qt::WindowMaximized;
  578. // Note: We do not report Qt::WindowActive, even if isActive()
  579. @@ -2181,7 +2185,6 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window)
  580. if (!m_drawContentBorderGradient) {
  581. [window setStyleMask:[window styleMask] & ~NSTexturedBackgroundWindowMask];
  582. [[[window contentView] superview] setNeedsDisplay:YES];
  583. - window.titlebarAppearsTransparent = NO;
  584. return;
  585. }
  586. @@ -2206,7 +2209,6 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window)
  587. int effectiveBottomContentBorderThickness = m_bottomContentBorderThickness;
  588. [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask];
  589. - window.titlebarAppearsTransparent = YES;
  590. [window setContentBorderThickness:effectiveTopContentBorderThickness forEdge:NSMaxYEdge];
  591. [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];
  592. diff --git a/src/printsupport/dialogs/qpagesetupdialog_mac.mm b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
  593. index 1e39845..9305566 100644
  594. --- a/src/printsupport/dialogs/qpagesetupdialog_mac.mm
  595. +++ b/src/printsupport/dialogs/qpagesetupdialog_mac.mm
  596. @@ -77,7 +77,7 @@ QT_USE_NAMESPACE
  597. QPageSetupDialog *dialog = static_cast<QPageSetupDialog *>(contextInfo);
  598. QPrinter *printer = dialog->printer();
  599. - if (returnCode == NSModalResponseOK) {
  600. + if (returnCode == NSOKButton) {
  601. PMPageFormat format = static_cast<PMPageFormat>([printInfo PMPageFormat]);
  602. PMRect paperRect;
  603. PMGetUnadjustedPaperRect(format, &paperRect);
  604. @@ -88,7 +88,7 @@ QT_USE_NAMESPACE
  605. printer->printEngine()->setProperty(QPrintEngine::PPK_Orientation, orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
  606. }
  607. - dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
  608. + dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
  609. }
  610. @end
  611. diff --git a/src/printsupport/dialogs/qprintdialog_mac.mm b/src/printsupport/dialogs/qprintdialog_mac.mm
  612. index 8547799..f7bbb59 100644
  613. --- a/src/printsupport/dialogs/qprintdialog_mac.mm
  614. +++ b/src/printsupport/dialogs/qprintdialog_mac.mm
  615. @@ -101,7 +101,7 @@ QT_USE_NAMESPACE
  616. QPrintDialog *dialog = static_cast<QPrintDialog *>(contextInfo);
  617. QPrinter *printer = dialog->printer();
  618. - if (returnCode == NSModalResponseOK) {
  619. + if (returnCode == NSOKButton) {
  620. PMPrintSession session = static_cast<PMPrintSession>([printInfo PMPrintSession]);
  621. PMPrintSettings settings = static_cast<PMPrintSettings>([printInfo PMPrintSettings]);
  622. @@ -190,7 +190,7 @@ QT_USE_NAMESPACE
  623. printer->setPageSize(pageSize);
  624. printer->setOrientation(orientation == kPMLandscape ? QPrinter::Landscape : QPrinter::Portrait);
  625. - dialog->done((returnCode == NSModalResponseOK) ? QDialog::Accepted : QDialog::Rejected);
  626. + dialog->done((returnCode == NSOKButton) ? QDialog::Accepted : QDialog::Rejected);
  627. }
  628. @end
  629. diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp
  630. index 4c5c9e1..5b4a95e 100644
  631. --- a/src/testlib/qtestcase.cpp
  632. +++ b/src/testlib/qtestcase.cpp
  633. @@ -147,6 +147,7 @@ static bool debuggerPresent()
  634. return CFStringCompare(str1, str2, kCFCompareCaseInsensitive) == kCFCompareEqualTo;
  635. };
  636. +#if 0
  637. // Check if there is an exception handler for the process:
  638. mach_msg_type_number_t portCount = 0;
  639. exception_mask_t masks[EXC_TYPES_COUNT];
  640. @@ -163,6 +164,7 @@ static bool debuggerPresent()
  641. }
  642. }
  643. }
  644. +#endif
  645. // Ok, no debugger attached. So, let's see if CrashReporter will throw up a dialog. If so, we
  646. // leave it to the OS to do the stack trace.
  647. diff --git a/src/widgets/styles/qmacstyle_mac.mm b/src/widgets/styles/qmacstyle_mac.mm
  648. index e6436f8..db1878a 100644
  649. --- a/src/widgets/styles/qmacstyle_mac.mm
  650. +++ b/src/widgets/styles/qmacstyle_mac.mm
  651. @@ -137,6 +137,21 @@
  652. #include <qpa/qplatformtheme.h>
  653. #include <QtGui/private/qcoregraphics_p.h>
  654. +@interface NSGraphicsContext (QtAdditions)
  655. +
  656. ++ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState;
  657. +
  658. +@end
  659. +
  660. +@implementation NSGraphicsContext (QtAdditions)
  661. +
  662. ++ (NSGraphicsContext *)qt_graphicsContextWithCGContext:(CGContextRef)graphicsPort flipped:(BOOL)initialFlippedState
  663. +{
  664. + return [self graphicsContextWithGraphicsPort:graphicsPort flipped:initialFlippedState];
  665. +}
  666. +
  667. +@end
  668. +
  669. QT_USE_NAMESPACE
  670. static QWindow *qt_getWindow(const QWidget *widget)
  671. @@ -1036,8 +1051,8 @@ void QMacStylePrivate::drawFocusRing(QPainter *p, const QRect &targetRect, int h
  672. CGContextSetAlpha(ctx, 0.5); // As applied to the stroke color below
  673. [NSGraphicsContext saveGraphicsState];
  674. - [NSGraphicsContext setCurrentContext:[NSGraphicsContext graphicsContextWithCGContext:ctx
  675. - flipped:NO]];
  676. + [NSGraphicsContext setCurrentContext:[NSGraphicsContext qt_graphicsContextWithCGContext:ctx
  677. + flipped:NO]];
  678. CGRect focusRingRect = CGRectMake(hMargin, vMargin, size, size);
  679. NSBezierPath *focusRingPath;
  680. if (radius > 0) {