diff options
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r-- | src/plugins/platforms/cocoa/.prev_CMakeLists.txt | 150 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/CMakeLists.txt | 154 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/cocoa.pro | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaintegration.mm | 27 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoamenuitem.mm | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 17 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qmultitouch_mac_p.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindowdelegate.mm | 12 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qpaintengine_mac.mm | 2 |
11 files changed, 352 insertions, 17 deletions
diff --git a/src/plugins/platforms/cocoa/.prev_CMakeLists.txt b/src/plugins/platforms/cocoa/.prev_CMakeLists.txt new file mode 100644 index 0000000000..1491340b65 --- /dev/null +++ b/src/plugins/platforms/cocoa/.prev_CMakeLists.txt @@ -0,0 +1,150 @@ +# Generated from cocoa.pro. + +##################################################################### +## QCocoaIntegrationPlugin Plugin: +##################################################################### + +qt_add_plugin(QCocoaIntegrationPlugin + OUTPUT_NAME qcocoa + TYPE platforms + SOURCES + main.mm + messages.cpp messages.h + qcocoaapplication.h qcocoaapplication.mm + qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm + qcocoabackingstore.h qcocoabackingstore.mm + qcocoaclipboard.h qcocoaclipboard.mm + qcocoacursor.h qcocoacursor.mm + qcocoadrag.h qcocoadrag.mm + qcocoaeventdispatcher.h qcocoaeventdispatcher.mm + qcocoahelpers.h qcocoahelpers.mm + qcocoainputcontext.h qcocoainputcontext.mm + qcocoaintegration.h qcocoaintegration.mm + qcocoaintrospection.h qcocoaintrospection.mm + qcocoakeymapper.h qcocoakeymapper.mm + qcocoamenu.h qcocoamenu.mm + qcocoamenubar.h qcocoamenubar.mm + qcocoamenuitem.h qcocoamenuitem.mm + qcocoamenuloader.h qcocoamenuloader.mm + qcocoamimetypes.h qcocoamimetypes.mm + qcocoanativeinterface.h qcocoanativeinterface.mm + qcocoansmenu.h qcocoansmenu.mm + qcocoascreen.h qcocoascreen.mm + qcocoaservices.h qcocoaservices.mm + qcocoasystemtrayicon.h qcocoasystemtrayicon.mm + qcocoatheme.h qcocoatheme.mm + qcocoawindow.h qcocoawindow.mm + qcocoawindowmanager.h qcocoawindowmanager.mm + qiosurfacegraphicsbuffer.h qiosurfacegraphicsbuffer.mm + qmacclipboard.h qmacclipboard.mm + qmultitouch_mac.mm qmultitouch_mac_p.h + qnsview.h qnsview.mm + qnswindow.h qnswindow.mm + qnswindowdelegate.h qnswindowdelegate.mm + PUBLIC_LIBRARIES + ${FWAppKit} + ${FWCarbon} + ${FWCoreServices} + ${FWCoreVideo} + ${FWIOKit} + ${FWIOSurface} + ${FWMetal} + ${FWQuartzCore} + Cups::Cups + Qt::ClipboardSupportPrivate + Qt::Core + Qt::CorePrivate + Qt::FontDatabaseSupportPrivate + Qt::GraphicsSupportPrivate + Qt::Gui + Qt::GuiPrivate + Qt::ThemeSupportPrivate +) + +# Resources: +set(qcocoaresources_resource_files + "images/sizeallcursor.png" + "images/spincursor.png" + "images/waitcursor.png" +) + +qt_add_resource(QCocoaIntegrationPlugin "qcocoaresources" + PREFIX + "/qt-project.org/mac/cursors" + FILES + ${qcocoaresources_resource_files} +) + + +#### Keys ignored in scope 1:.:.:cocoa.pro:<TRUE>: +# OTHER_FILES = "cocoa.json" + +## Scopes: +##################################################################### + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_opengl + SOURCES + qcocoaglcontext.h qcocoaglcontext.mm +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_vulkan + SOURCES + qcocoavulkaninstance.h qcocoavulkaninstance.mm + PUBLIC_LIBRARIES + Qt::VulkanSupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_accessibility + SOURCES + qcocoaaccessibility.h qcocoaaccessibility.mm + qcocoaaccessibilityelement.h qcocoaaccessibilityelement.mm + PUBLIC_LIBRARIES + Qt::AccessibilitySupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager + SOURCES + qcocoasessionmanager.cpp qcocoasessionmanager.h +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets + SOURCES + qpaintengine_mac.mm qpaintengine_mac_p.h + PUBLIC_LIBRARIES + Qt::WidgetsPrivate +) + +#### Keys ignored in scope 8:.:.:cocoa.pro:TARGET Qt::Widgets: +# QT_FOR_CONFIG = "widgets" + +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets + SOURCES + qcocoaprintdevice.h qcocoaprintdevice.mm + qcocoaprintersupport.h qcocoaprintersupport.mm + qprintengine_mac.mm qprintengine_mac_p.h + PUBLIC_LIBRARIES + Qt::PrintSupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets + SOURCES + qcocoacolordialoghelper.h qcocoacolordialoghelper.mm +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_filedialog AND TARGET Qt::Widgets + SOURCES + qcocoafiledialoghelper.h qcocoafiledialoghelper.mm +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_fontdialog AND TARGET Qt::Widgets + SOURCES + qcocoafontdialoghelper.h qcocoafontdialoghelper.mm +) + +#### Keys ignored in scope 13:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +# PLUGIN_EXTENDS = "-" diff --git a/src/plugins/platforms/cocoa/CMakeLists.txt b/src/plugins/platforms/cocoa/CMakeLists.txt new file mode 100644 index 0000000000..9e8b162aec --- /dev/null +++ b/src/plugins/platforms/cocoa/CMakeLists.txt @@ -0,0 +1,154 @@ +# Generated from cocoa.pro. + +# special case: +qt_find_package(Cups PROVIDED_TARGETS Cups::Cups) + +##################################################################### +## QCocoaIntegrationPlugin Plugin: +##################################################################### + +qt_add_plugin(QCocoaIntegrationPlugin + OUTPUT_NAME qcocoa + DEFAULT_IF ${QT_QPA_DEFAULT_PLATFORM} MATCHES cocoa # special case + TYPE platforms + SOURCES + main.mm + messages.cpp messages.h + qcocoaapplication.h qcocoaapplication.mm + qcocoaapplicationdelegate.h qcocoaapplicationdelegate.mm + qcocoabackingstore.h qcocoabackingstore.mm + qcocoaclipboard.h qcocoaclipboard.mm + qcocoacursor.h qcocoacursor.mm + qcocoadrag.h qcocoadrag.mm + qcocoaeventdispatcher.h qcocoaeventdispatcher.mm + qcocoahelpers.h qcocoahelpers.mm + qcocoainputcontext.h qcocoainputcontext.mm + qcocoaintegration.h qcocoaintegration.mm + qcocoaintrospection.h qcocoaintrospection.mm + qcocoakeymapper.h qcocoakeymapper.mm + qcocoamenu.h qcocoamenu.mm + qcocoamenubar.h qcocoamenubar.mm + qcocoamenuitem.h qcocoamenuitem.mm + qcocoamenuloader.h qcocoamenuloader.mm + qcocoamimetypes.h qcocoamimetypes.mm + qcocoanativeinterface.h qcocoanativeinterface.mm + qcocoansmenu.h qcocoansmenu.mm + qcocoascreen.h qcocoascreen.mm + qcocoaservices.h qcocoaservices.mm + qcocoasystemtrayicon.h qcocoasystemtrayicon.mm + qcocoatheme.h qcocoatheme.mm + qcocoawindow.h qcocoawindow.mm + qcocoawindowmanager.h qcocoawindowmanager.mm + qiosurfacegraphicsbuffer.h qiosurfacegraphicsbuffer.mm + qmacclipboard.h qmacclipboard.mm + qmultitouch_mac.mm qmultitouch_mac_p.h + qnsview.h qnsview.mm + qnswindow.h qnswindow.mm + qnswindowdelegate.h qnswindowdelegate.mm + PUBLIC_LIBRARIES + ${FWAppKit} + ${FWCarbon} + ${FWCoreServices} + ${FWCoreVideo} + ${FWIOKit} + ${FWIOSurface} + ${FWMetal} + ${FWQuartzCore} + Cups::Cups + Qt::ClipboardSupportPrivate + Qt::Core + Qt::CorePrivate + Qt::FontDatabaseSupportPrivate + Qt::GraphicsSupportPrivate + Qt::Gui + Qt::GuiPrivate + Qt::ThemeSupportPrivate +) + +# Resources: +set(qcocoaresources_resource_files + "images/sizeallcursor.png" + "images/spincursor.png" + "images/waitcursor.png" +) + +qt_add_resource(QCocoaIntegrationPlugin "qcocoaresources" + PREFIX + "/qt-project.org/mac/cursors" + FILES + ${qcocoaresources_resource_files} +) + + +#### Keys ignored in scope 1:.:.:cocoa.pro:<TRUE>: +# OTHER_FILES = "cocoa.json" + +## Scopes: +##################################################################### + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_opengl + SOURCES + qcocoaglcontext.h qcocoaglcontext.mm +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_vulkan + SOURCES + qcocoavulkaninstance.h qcocoavulkaninstance.mm + PUBLIC_LIBRARIES + Qt::VulkanSupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_accessibility + SOURCES + qcocoaaccessibility.h qcocoaaccessibility.mm + qcocoaaccessibilityelement.h qcocoaaccessibilityelement.mm + PUBLIC_LIBRARIES + Qt::AccessibilitySupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_sessionmanager + SOURCES + qcocoasessionmanager.cpp qcocoasessionmanager.h +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PlatformCompositorSupportPrivate + PUBLIC_LIBRARIES + Qt::PlatformCompositorSupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::Widgets + SOURCES + qpaintengine_mac.mm qpaintengine_mac_p.h + PUBLIC_LIBRARIES + Qt::WidgetsPrivate +) + +#### Keys ignored in scope 8:.:.:cocoa.pro:TARGET Qt::Widgets: +# QT_FOR_CONFIG = "widgets" + +qt_extend_target(QCocoaIntegrationPlugin CONDITION TARGET Qt::PrintSupport AND TARGET Qt::Widgets + SOURCES + qcocoaprintdevice.h qcocoaprintdevice.mm + qcocoaprintersupport.h qcocoaprintersupport.mm + qprintengine_mac.mm qprintengine_mac_p.h + PUBLIC_LIBRARIES + Qt::PrintSupportPrivate +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_colordialog AND TARGET Qt::Widgets + SOURCES + qcocoacolordialoghelper.h qcocoacolordialoghelper.mm +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_filedialog AND TARGET Qt::Widgets + SOURCES + qcocoafiledialoghelper.h qcocoafiledialoghelper.mm +) + +qt_extend_target(QCocoaIntegrationPlugin CONDITION QT_FEATURE_fontdialog AND TARGET Qt::Widgets + SOURCES + qcocoafontdialoghelper.h qcocoafontdialoghelper.mm +) + +#### Keys ignored in scope 13:.:.:cocoa.pro:NOT TARGET___equals____ss_QT_DEFAULT_QPA_PLUGIN: +# PLUGIN_EXTENDS = "-" diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro index a919963cf4..953346c56e 100644 --- a/src/plugins/platforms/cocoa/cocoa.pro +++ b/src/plugins/platforms/cocoa/cocoa.pro @@ -101,6 +101,8 @@ QT += \ qtConfig(vulkan): QT += vulkan_support-private +qtHaveModule(platformcompositor_support-private): QT += platformcompositor_support-private + CONFIG += no_app_extension_api_only qtHaveModule(widgets) { diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h index 0c14e07551..30838ba254 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.h +++ b/src/plugins/platforms/cocoa/qcocoaintegration.h @@ -128,6 +128,8 @@ public: void beep() const override; + void closePopups(QWindow *forWindow = nullptr); + private Q_SLOTS: void focusWindowChanged(QWindow *); diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index deddcd3f98..1fb250317d 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -68,6 +68,10 @@ #include <QtFontDatabaseSupport/private/qfontengine_coretext_p.h> +#if QT_CONFIG(opengl) +#include <QtPlatformCompositorSupport/qpa/qplatformbackingstoreopenglsupport.h> +#endif + #ifdef QT_WIDGETS_LIB #include <QtWidgets/qtwidgetsglobal.h> #if QT_CONFIG(filedialog) @@ -324,10 +328,16 @@ QPlatformBackingStore *QCocoaIntegration::createPlatformBackingStore(QWindow *wi return nullptr; } + QPlatformBackingStore *backingStore = nullptr; if (platformWindow->view().layer) - return new QCALayerBackingStore(window); + backingStore = new QCALayerBackingStore(window); else - return new QNSWindowBackingStore(window); + backingStore = new QNSWindowBackingStore(window); + +#if QT_CONFIG(opengl) + backingStore->setOpenGLSupport(new QPlatformBackingStoreOpenGLSupport(backingStore)); +#endif + return backingStore; } QAbstractEventDispatcher *QCocoaIntegration::createEventDispatcher() const @@ -480,6 +490,19 @@ void QCocoaIntegration::beep() const NSBeep(); } +void QCocoaIntegration::closePopups(QWindow *forWindow) +{ + for (auto it = m_popupWindowStack.begin(); it != m_popupWindowStack.end();) { + auto *popup = *it; + if (!forWindow || popup->window()->transientParent() == forWindow) { + it = m_popupWindowStack.erase(it); + QWindowSystemInterface::handleCloseEvent<QWindowSystemInterface::SynchronousDelivery>(popup->window()); + } else { + ++it; + } + } +} + void QCocoaIntegration::focusWindowChanged(QWindow *focusWindow) { // Don't revert icon just because we lost focus diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 5aa41eeb22..a2100a6369 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -53,7 +53,6 @@ #include <QtGui/private/qcoregraphics_p.h> #include <QtCore/QDebug> -#include <QtCore/QRegExp> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index b15c0ac31c..4bff1de515 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -151,6 +151,7 @@ public: Q_NOTIFICATION_HANDLER(NSWindowDidEndLiveResizeNotification) void windowDidEndLiveResize(); Q_NOTIFICATION_HANDLER(NSWindowDidBecomeKeyNotification) void windowDidBecomeKey(); Q_NOTIFICATION_HANDLER(NSWindowDidResignKeyNotification) void windowDidResignKey(); + Q_NOTIFICATION_HANDLER(NSWindowWillMiniaturizeNotification) void windowWillMiniaturize(); Q_NOTIFICATION_HANDLER(NSWindowDidMiniaturizeNotification) void windowDidMiniaturize(); Q_NOTIFICATION_HANDLER(NSWindowDidDeminiaturizeNotification) void windowDidDeminiaturize(); Q_NOTIFICATION_HANDLER(NSWindowWillEnterFullScreenNotification) void windowWillEnterFullScreen(); diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index c539afbfcd..35b0ec2d40 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -71,14 +71,6 @@ enum { defaultWindowHeight = 160 }; -static void qt_closePopups() -{ - while (QCocoaWindow *popup = QCocoaIntegration::instance()->popPopupWindow()) { - QWindowSystemInterface::handleCloseEvent(popup->window()); - QWindowSystemInterface::flushWindowSystemEvents(); - } -} - Q_LOGGING_CATEGORY(lcCocoaNotifications, "qt.qpa.cocoa.notifications"); static void qRegisterNotificationCallbacks() @@ -819,6 +811,11 @@ void QCocoaWindow::windowDidExitFullScreen() } } +void QCocoaWindow::windowWillMiniaturize() +{ + QCocoaIntegration::instance()->closePopups(window()); +} + void QCocoaWindow::windowDidMiniaturize() { if (!isContentView()) @@ -1153,7 +1150,7 @@ void QCocoaWindow::viewDidChangeGlobalFrame() void QCocoaWindow::windowWillMove() { // Close any open popups on window move - qt_closePopups(); + QCocoaIntegration::instance()->closePopups(); } void QCocoaWindow::windowDidMove() @@ -1284,7 +1281,7 @@ void QCocoaWindow::windowWillClose() { // Close any open popups on window closing. if (window() && !windowIsPopupType(window()->type())) - qt_closePopups(); + QCocoaIntegration::instance()->closePopups(); } // ----------------------- NSWindowDelegate callbacks ----------------------- diff --git a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h index 044bcd1882..dff289f746 100644 --- a/src/plugins/platforms/cocoa/qmultitouch_mac_p.h +++ b/src/plugins/platforms/cocoa/qmultitouch_mac_p.h @@ -58,6 +58,7 @@ #include <qpa/qwindowsysteminterface.h> #include <qhash.h> #include <QtCore> +#include <QtGui/qtouchdevice.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 9502a315d8..3ad9085dea 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -47,7 +47,13 @@ #include <qpa/qplatformscreen.h> #include <qpa/qwindowsysteminterface.h> -static QRegExp whitespaceRegex = QRegExp(QStringLiteral("\\s*")); +static inline bool isWhiteSpace(const QString &s) +{ + for (int i = 0; i < s.size(); ++i) + if (!s.at(i).isSpace()) + return false; + return true; +} static QCocoaWindow *toPlatformWindow(NSWindow *window) { @@ -113,7 +119,7 @@ static QCocoaWindow *toPlatformWindow(NSWindow *window) // Only pop up document path if the filename is non-empty. We allow whitespace, to // allow faking a window icon by setting the file path to a single space character. - return !whitespaceRegex.exactMatch(platformWindow->window()->filePath()); + return !isWhiteSpace(platformWindow->window()->filePath()); } - (BOOL)window:(NSWindow *)window shouldDragDocumentWithEvent:(NSEvent *)event from:(NSPoint)dragImageLocation withPasteboard:(NSPasteboard *)pasteboard @@ -127,6 +133,6 @@ static QCocoaWindow *toPlatformWindow(NSWindow *window) // Only allow drag if the filename is non-empty. We allow whitespace, to // allow faking a window icon by setting the file path to a single space. - return !whitespaceRegex.exactMatch(platformWindow->window()->filePath()); + return !isWhiteSpace(platformWindow->window()->filePath()); } @end diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm index df71f76644..429c47dc3b 100644 --- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm +++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm @@ -90,7 +90,7 @@ CGImageRef qt_mac_create_imagemask(const QPixmap &pixmap, const QRectF &sr) image = image.convertToFormat(QImage::Format_ARGB32_Premultiplied); const int sx = qRound(sr.x()), sy = qRound(sr.y()), sw = qRound(sr.width()), sh = qRound(sr.height()); - const int sbpr = image.bytesPerLine(); + const qsizetype sbpr = image.bytesPerLine(); const uint nbytes = sw * sh; // alpha is always 255 for bitmaps, ignore it in this case. const quint32 mask = pixmap.depth() == 1 ? 0x00ffffff : 0xffffffff; |