Audio plugin host https://kx.studio/carla
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.

402 lines
18KB

  1. diff --git a/mkspecs/common/clang-mac.conf b/mkspecs/common/clang-mac.conf
  2. index cbae2e62..dc4694fa 100644
  3. --- a/mkspecs/common/clang-mac.conf
  4. +++ b/mkspecs/common/clang-mac.conf
  5. @@ -10,4 +10,5 @@ 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. +# -fapplication-extension
  11. diff --git a/src/corelib/global/qoperatingsystemversion_darwin.mm b/src/corelib/global/qoperatingsystemversion_darwin.mm
  12. index d8b927ff..9a690adc 100644
  13. --- a/src/corelib/global/qoperatingsystemversion_darwin.mm
  14. +++ b/src/corelib/global/qoperatingsystemversion_darwin.mm
  15. @@ -40,16 +40,37 @@
  16. #include "qoperatingsystemversion_p.h"
  17. #import <Foundation/Foundation.h>
  18. +typedef qint16 (*GestaltFunction)(quint32 selector, qint32 *response);
  19. +
  20. QT_BEGIN_NAMESPACE
  21. QOperatingSystemVersion QOperatingSystemVersion::current()
  22. {
  23. - NSOperatingSystemVersion osv = NSProcessInfo.processInfo.operatingSystemVersion;
  24. QOperatingSystemVersion v;
  25. v.m_os = currentType();
  26. - v.m_major = osv.majorVersion;
  27. - v.m_minor = osv.minorVersion;
  28. - v.m_micro = osv.patchVersion;
  29. + v.m_major = -1;
  30. + v.m_minor = -1;
  31. + v.m_micro = -1;
  32. + static GestaltFunction pGestalt = 0;
  33. + if (!pGestalt) {
  34. + CFBundleRef b = CFBundleGetBundleWithIdentifier(CFSTR("com.apple.CoreServices"));
  35. + pGestalt = reinterpret_cast<GestaltFunction>(CFBundleGetFunctionPointerForName(b,
  36. + CFSTR("Gestalt")));
  37. + }
  38. + // Use temporary variables so we can return 0.0.0 (unknown version)
  39. + // in case of an error partway through determining the OS version
  40. + qint32 major = 0, minor = 0, patch = 0;
  41. + if (!pGestalt)
  42. + return v;
  43. + if (pGestalt('sys1', &major) != 0)
  44. + return v;
  45. + if (pGestalt('sys2', &minor) != 0)
  46. + return v;
  47. + if (pGestalt('sys3', &patch) != 0)
  48. + return v;
  49. + v.m_major = major;
  50. + v.m_minor = minor;
  51. + v.m_micro = patch;
  52. return v;
  53. }
  54. diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp
  55. index 7fed54f7..bbf5e6d6 100644
  56. --- a/src/corelib/io/qfilesystemengine_unix.cpp
  57. +++ b/src/corelib/io/qfilesystemengine_unix.cpp
  58. @@ -126,8 +126,11 @@ static bool isPackage(const QFileSystemMetaData &data, const QFileSystemEntry &e
  59. #ifdef Q_OS_MACOS
  60. // Find if an application other than Finder claims to know how to handle the package
  61. - QCFType<CFURLRef> application = LSCopyDefaultApplicationURLForURL(url,
  62. - kLSRolesEditor | kLSRolesViewer, nullptr);
  63. + QCFType<CFURLRef> application;
  64. + LSGetApplicationForURL(url,
  65. + kLSRolesEditor|kLSRolesViewer,
  66. + NULL,
  67. + &application);
  68. if (application) {
  69. QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, application);
  70. diff --git a/src/corelib/kernel/qcore_foundation.mm b/src/corelib/kernel/qcore_foundation.mm
  71. index 56eabc4b..c48a7979 100644
  72. --- a/src/corelib/kernel/qcore_foundation.mm
  73. +++ b/src/corelib/kernel/qcore_foundation.mm
  74. @@ -46,7 +46,7 @@
  75. #include <QtCore/qbytearray.h>
  76. #include <QtCore/qrect.h>
  77. -#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE)
  78. +#if 0
  79. #include <QtCore/qtimezone.h>
  80. #include <QtCore/private/qtimezoneprivate_p.h>
  81. #include <QtCore/private/qcore_mac_p.h>
  82. @@ -433,7 +433,7 @@ NSDate *QDateTime::toNSDate() const
  83. // ----------------------------------------------------------------------------
  84. -#if QT_CONFIG(timezone) && !defined(QT_NO_SYSTEMLOCALE)
  85. +#if 0
  86. /*!
  87. \since 5.9
  88. diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h
  89. index bd87139f..d154cbf9 100644
  90. --- a/src/corelib/tools/qtimezone.h
  91. +++ b/src/corelib/tools/qtimezone.h
  92. @@ -47,7 +47,7 @@
  93. QT_REQUIRE_CONFIG(timezone);
  94. -#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE)
  95. +#if 0
  96. Q_FORWARD_DECLARE_CF_TYPE(CFTimeZone);
  97. Q_FORWARD_DECLARE_OBJC_CLASS(NSTimeZone);
  98. #endif
  99. @@ -147,7 +147,7 @@ public:
  100. static QList<QByteArray> windowsIdToIanaIds(const QByteArray &windowsId,
  101. QLocale::Country country);
  102. -#if (defined(Q_OS_DARWIN) || defined(Q_QDOC)) && !defined(QT_NO_SYSTEMLOCALE)
  103. +#if 0
  104. static QTimeZone fromCFTimeZone(CFTimeZoneRef timeZone);
  105. CFTimeZoneRef toCFTimeZone() const Q_DECL_CF_RETURNS_RETAINED;
  106. static QTimeZone fromNSTimeZone(const NSTimeZone *timeZone);
  107. diff --git a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
  108. index f8fe160e..3c350b3c 100644
  109. --- a/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
  110. +++ b/src/platformsupport/fontdatabases/mac/qcoretextfontdatabase.mm
  111. @@ -456,7 +456,6 @@ QFontEngine *QCoreTextFontDatabaseEngineFactory<QFontEngineFT>::fontEngine(const
  112. return QFontEngineFT::create(*fontData, fontDef.pixelSize,
  113. static_cast<QFont::HintingPreference>(fontDef.hintingPreference));
  114. } else if (NSURL *url = descriptorAttribute<NSURL>(descriptor, kCTFontURLAttribute)) {
  115. - Q_ASSERT(url.fileURL);
  116. QFontEngine::FaceId faceId;
  117. faceId.filename = QString::fromNSString(url.path).toUtf8();
  118. return QFontEngineFT::create(fontDef, faceId);
  119. diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm
  120. index e41c70b8..815028b7 100644
  121. --- a/src/plugins/platforms/cocoa/qcocoamenu.mm
  122. +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm
  123. @@ -329,13 +329,6 @@ void QCocoaMenu::insertMenuItem(QPlatformMenuItem *menuItem, QPlatformMenuItem *
  124. }
  125. insertNative(cocoaItem, beforeItem);
  126. -
  127. - // Empty menus on a menubar are hidden by default. If the menu gets
  128. - // added to the menubar before it contains any item, we need to sync.
  129. - if (isVisible() && attachedItem().hidden) {
  130. - if (auto *mb = qobject_cast<QCocoaMenuBar *>(menuParent()))
  131. - mb->syncMenu(this);
  132. - }
  133. }
  134. void QCocoaMenu::insertNative(QCocoaMenuItem *item, QCocoaMenuItem *beforeItem)
  135. diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm
  136. index a4cd465d..06d63f7d 100644
  137. --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm
  138. +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm
  139. @@ -369,7 +369,7 @@ void QCocoaMenuBar::updateMenuBarImmediately()
  140. QCocoaMenuLoader *loader = [QCocoaMenuLoader sharedMenuLoader];
  141. [loader ensureAppMenuInMenu:mb->nsMenu()];
  142. - NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:mb->merged().count()] retain];
  143. + NSMutableSet *mergedItems = [[NSMutableSet setWithCapacity:0] retain];
  144. foreach (QCocoaMenuItem *m, mb->merged()) {
  145. [mergedItems addObject:m->nsItem()];
  146. m->syncMerged();
  147. diff --git a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
  148. index 5504c242..fa0b7f71 100644
  149. --- a/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
  150. +++ b/src/plugins/platforms/cocoa/qcocoanativeinterface.mm
  151. @@ -172,12 +172,11 @@ void *QCocoaNativeInterface::NSPrintInfoForPrintEngine(QPrintEngine *printEngine
  152. QPixmap QCocoaNativeInterface::defaultBackgroundPixmapForQWizard()
  153. {
  154. + QCFType<CFURLRef> url;
  155. const int ExpectedImageWidth = 242;
  156. const int ExpectedImageHeight = 414;
  157. - QCFType<CFArrayRef> urls = LSCopyApplicationURLsForBundleIdentifier(
  158. - CFSTR("com.apple.KeyboardSetupAssistant"), nullptr);
  159. - if (urls && CFArrayGetCount(urls) > 0) {
  160. - CFURLRef url = (CFURLRef)CFArrayGetValueAtIndex(urls, 0);
  161. + if (LSFindApplicationForInfo(kLSUnknownCreator, CFSTR("com.apple.KeyboardSetupAssistant"),
  162. + 0, 0, &url) == noErr) {
  163. QCFType<CFBundleRef> bundle = CFBundleCreate(kCFAllocatorDefault, url);
  164. if (bundle) {
  165. url = CFBundleCopyResourceURL(bundle, CFSTR("Background"), CFSTR("png"), 0);
  166. diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
  167. index aa8fffdf..191553e6 100644
  168. --- a/src/plugins/platforms/cocoa/qcocoawindow.h
  169. +++ b/src/plugins/platforms/cocoa/qcocoawindow.h
  170. @@ -316,6 +316,8 @@ public: // for QNSView
  171. bool m_viewIsEmbedded; // true if the m_view is actually embedded in a "foreign" NSView hiearchy
  172. bool m_viewIsToBeEmbedded; // true if the m_view is intended to be embedded in a "foreign" NSView hiearchy
  173. + QCocoaWindow *m_parentCocoaWindow;
  174. +
  175. Qt::WindowFlags m_windowFlags;
  176. Qt::WindowState m_lastReportedWindowState;
  177. Qt::WindowModality m_windowModality;
  178. diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
  179. index 86fd7b8a..c7aa5792 100644
  180. --- a/src/plugins/platforms/cocoa/qcocoawindow.mm
  181. +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
  182. @@ -325,7 +325,7 @@ static void qt_closePopups()
  183. + (void)applicationActivationChanged:(NSNotification*)notification
  184. {
  185. const id sender = self;
  186. - NSEnumerator<NSWindow*> *windowEnumerator = nullptr;
  187. + NSEnumerator* windowEnumerator = nullptr;
  188. NSApplication *application = [NSApplication sharedApplication];
  189. #if QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_12)
  190. @@ -526,6 +526,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw, WId nativeHandle)
  191. , m_nsWindow(0)
  192. , m_viewIsEmbedded(false)
  193. , m_viewIsToBeEmbedded(false)
  194. + , m_parentCocoaWindow(0)
  195. , m_lastReportedWindowState(Qt::WindowNoState)
  196. , m_windowModality(Qt::NonModal)
  197. , m_windowUnderMouse(false)
  198. @@ -594,10 +595,12 @@ QCocoaWindow::~QCocoaWindow()
  199. [m_nsWindow makeFirstResponder:nil];
  200. [m_nsWindow setContentView:nil];
  201. [m_nsWindow.helper detachFromPlatformWindow];
  202. - if (m_view.window.parentWindow)
  203. - [m_view.window.parentWindow removeChildWindow:m_view.window];
  204. - else if ([m_view superview])
  205. + if (m_view.window.parentWindow) {
  206. + if (m_parentCocoaWindow)
  207. + m_parentCocoaWindow->removeChildWindow(this);
  208. + } else if ([m_view superview]) {
  209. [m_view removeFromSuperview];
  210. + }
  211. removeMonitor();
  212. @@ -614,6 +617,7 @@ QCocoaWindow::~QCocoaWindow()
  213. foreachChildNSWindow(^(QCocoaWindow *childWindow) {
  214. [m_nsWindow removeChildWindow:childWindow->m_nsWindow];
  215. + childWindow->m_parentCocoaWindow = 0;
  216. });
  217. [m_view release];
  218. @@ -690,7 +694,7 @@ void QCocoaWindow::setCocoaGeometry(const QRect &rect)
  219. if (isChildNSWindow()) {
  220. QPlatformWindow::setGeometry(rect);
  221. - NSWindow *parentNSWindow = m_view.window.parentWindow;
  222. + NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
  223. NSRect parentWindowFrame = [parentNSWindow contentRectForFrameRect:parentNSWindow.frame];
  224. clipWindow(parentWindowFrame);
  225. @@ -744,7 +748,7 @@ void QCocoaWindow::clipWindow(const NSRect &clipRect)
  226. m_hiddenByClipping = false;
  227. if (!m_hiddenByAncestor) {
  228. [m_nsWindow orderFront:nil];
  229. - static_cast<QCocoaWindow *>(QPlatformWindow::parent())->reinsertChildWindow(this);
  230. + m_parentCocoaWindow->reinsertChildWindow(this);
  231. }
  232. }
  233. }
  234. @@ -781,7 +785,7 @@ void QCocoaWindow::show(bool becauseOfAncestor)
  235. if ([m_nsWindow isVisible])
  236. return;
  237. - if (m_view.window.parentWindow && !m_view.window.parentWindow.visible) {
  238. + if (m_parentCocoaWindow && ![m_parentCocoaWindow->m_nsWindow isVisible]) {
  239. m_hiddenByAncestor = true; // Parent still hidden, don't show now
  240. } else if ((becauseOfAncestor == m_hiddenByAncestor) // Was NEITHER explicitly hidden
  241. && !m_hiddenByClipping) { // ... NOR clipped
  242. @@ -792,7 +796,7 @@ void QCocoaWindow::show(bool becauseOfAncestor)
  243. if (!m_hiddenByClipping) { // setCocoaGeometry() can change the clipping status
  244. [m_nsWindow orderFront:nil];
  245. if (isChildNSWindow())
  246. - static_cast<QCocoaWindow *>(QPlatformWindow::parent())->reinsertChildWindow(this);
  247. + m_parentCocoaWindow->reinsertChildWindow(this);
  248. foreachChildNSWindow(^(QCocoaWindow *childWindow) {
  249. childWindow->show(true);
  250. });
  251. @@ -1190,7 +1194,7 @@ void QCocoaWindow::raise()
  252. // -[NSWindow orderFront:] doesn't work with attached windows.
  253. // The only solution is to remove and add the child window.
  254. // This will place it on top of all the other NSWindows.
  255. - NSWindow *parentNSWindow = m_view.window.parentWindow;
  256. + NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
  257. [parentNSWindow removeChildWindow:m_nsWindow];
  258. [parentNSWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
  259. } else {
  260. @@ -1226,7 +1230,7 @@ void QCocoaWindow::lower()
  261. // The only solution is to remove and add all the child windows except this one.
  262. // This will keep the current window at the bottom while adding the others on top of it,
  263. // hopefully in the same order (this is not documented anywhere in the Cocoa documentation).
  264. - NSWindow *parentNSWindow = m_view.window.parentWindow;
  265. + NSWindow *parentNSWindow = m_parentCocoaWindow->m_nsWindow;
  266. NSArray *children = [parentNSWindow.childWindows copy];
  267. for (NSWindow *child in children)
  268. if (m_nsWindow != child) {
  269. @@ -1698,14 +1702,15 @@ void QCocoaWindow::recreateWindowIfNeeded()
  270. qCDebug(lcQpaCocoaWindow) << "Reconfiguring NSWindow due to" << recreateReason;
  271. - QCocoaWindow *parentCocoaWindow = static_cast<QCocoaWindow *>(parentWindow);
  272. + // FIXME: Replace member with direct parentWindow usage (possibly cast)
  273. + m_parentCocoaWindow = static_cast<QCocoaWindow *>(parentWindow);
  274. if (shouldBeChildNSWindow) {
  275. QWindow *parentQWindow = parentWindow->window();
  276. // Ensure that all parents in the hierarchy are also child NSWindows
  277. if (!parentQWindow->property("_q_platform_MacUseNSWindow").toBool()) {
  278. parentQWindow->setProperty("_q_platform_MacUseNSWindow", QVariant(true));
  279. - parentCocoaWindow->recreateWindowIfNeeded();
  280. + m_parentCocoaWindow->recreateWindowIfNeeded();
  281. }
  282. }
  283. @@ -1713,8 +1718,8 @@ void QCocoaWindow::recreateWindowIfNeeded()
  284. if ((isContentView() && !shouldBeContentView) || (recreateReason & PanelChanged)) {
  285. qCDebug(lcQpaCocoaWindow) << "Getting rid of existing window" << m_nsWindow;
  286. [m_nsWindow closeAndRelease];
  287. - if (isChildNSWindow())
  288. - [m_view.window.parentWindow removeChildWindow:m_view.window];
  289. + if (isChildNSWindow() && oldParentCocoaWindow)
  290. + oldParentCocoaWindow->removeChildWindow(this);
  291. if (isContentView()) {
  292. // We explicitly disassociate m_view from the window's contentView,
  293. // as AppKit does not automatically do this in response to removing
  294. @@ -1730,9 +1735,9 @@ void QCocoaWindow::recreateWindowIfNeeded()
  295. if (noPreviousWindow)
  296. m_nsWindow = createNSWindow(shouldBeChildNSWindow, shouldBePanel);
  297. - if (m_view.window.parentWindow) {
  298. - if (!shouldBeChildNSWindow || (recreateReason & ParentChanged))
  299. - [m_view.window.parentWindow removeChildWindow:m_view.window];
  300. + if (oldParentCocoaWindow) {
  301. + if (!shouldBeChildNSWindow || oldParentCocoaWindow != m_parentCocoaWindow)
  302. + oldParentCocoaWindow->removeChildWindow(this);
  303. m_forwardWindow = oldParentCocoaWindow;
  304. }
  305. @@ -1759,8 +1764,8 @@ void QCocoaWindow::recreateWindowIfNeeded()
  306. setWindowState(window()->windowState());
  307. } else if (shouldBeChildNSWindow) {
  308. if (!m_hiddenByClipping) {
  309. - [parentCocoaWindow->m_nsWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
  310. - parentCocoaWindow->reinsertChildWindow(this);
  311. + [m_parentCocoaWindow->m_nsWindow addChildWindow:m_nsWindow ordered:NSWindowAbove];
  312. + m_parentCocoaWindow->reinsertChildWindow(this);
  313. }
  314. // Set properties after the window has been made a child NSWindow
  315. @@ -1771,7 +1776,7 @@ void QCocoaWindow::recreateWindowIfNeeded()
  316. if ([m_view superview])
  317. [m_view removeFromSuperview];
  318. - [parentCocoaWindow->m_view addSubview:m_view];
  319. + [m_parentCocoaWindow->m_view addSubview:m_view];
  320. QRect rect = windowGeometry();
  321. // Prevent setting a (0,0) window size; causes opengl context
  322. // "Invalid Drawable" warnings.
  323. @@ -1915,6 +1920,11 @@ bool QCocoaWindow::alwaysShowToolWindow() const
  324. return qt_mac_resolveOption(false, window(), "_q_macAlwaysShowToolWindow", "");
  325. }
  326. +void QCocoaWindow::removeChildWindow(QCocoaWindow *child)
  327. +{
  328. + [m_nsWindow removeChildWindow:child->m_nsWindow];
  329. +}
  330. +
  331. void QCocoaWindow::removeMonitor()
  332. {
  333. if (!monitor)
  334. @@ -2046,12 +2056,14 @@ Qt::WindowState QCocoaWindow::windowState() const
  335. // FIXME: Support compound states (Qt::WindowStates)
  336. NSWindow *window = m_view.window;
  337. + /*
  338. if (window.miniaturized)
  339. return Qt::WindowMinimized;
  340. + */
  341. if (window.qt_fullScreen)
  342. return Qt::WindowFullScreen;
  343. - if ((window.zoomed && !isTransitioningToFullScreen())
  344. - || (m_lastReportedWindowState == Qt::WindowMaximized && isTransitioningToFullScreen()))
  345. + if (/*(window.zoomed && !isTransitioningToFullScreen())
  346. + ||*/ (m_lastReportedWindowState == Qt::WindowMaximized && isTransitioningToFullScreen()))
  347. return Qt::WindowMaximized;
  348. // Note: We do not report Qt::WindowActive, even if isActive()
  349. @@ -2181,7 +2193,6 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window)
  350. if (!m_drawContentBorderGradient) {
  351. [window setStyleMask:[window styleMask] & ~NSTexturedBackgroundWindowMask];
  352. [[[window contentView] superview] setNeedsDisplay:YES];
  353. - window.titlebarAppearsTransparent = NO;
  354. return;
  355. }
  356. @@ -2206,7 +2217,6 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window)
  357. int effectiveBottomContentBorderThickness = m_bottomContentBorderThickness;
  358. [window setStyleMask:[window styleMask] | NSTexturedBackgroundWindowMask];
  359. - window.titlebarAppearsTransparent = YES;
  360. [window setContentBorderThickness:effectiveTopContentBorderThickness forEdge:NSMaxYEdge];
  361. [window setAutorecalculatesContentBorderThickness:NO forEdge:NSMaxYEdge];