macOS: Clean up headers

The headers are now C++ clean and can be used outside of Objective-C
code. All includes of Objective-C frameworks have been moved to the
implementation files.

Header guards have been added in the few places they were missing.

All includes are now done via #include, instead of sometimes using
the #import variant.

Change-Id: Ibb0a9c0bcfefbda4347737212e40e300a3184982
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2020-05-13 16:40:19 +02:00
parent c7d80486de
commit df2e029a06
62 changed files with 231 additions and 148 deletions

View File

@ -639,6 +639,20 @@ Q_CONSTRUCTOR_FUNCTION(qt_apple_check_os_version);
// -------------------------------------------------------------------------
void QMacNotificationObserver::remove()
{
if (observer)
[[NSNotificationCenter defaultCenter] removeObserver:observer];
observer = nullptr;
}
// -------------------------------------------------------------------------
QMacKeyValueObserver::QMacKeyValueObserver(const QMacKeyValueObserver &other)
: QMacKeyValueObserver(other.object, other.keyPath, *other.callback.get())
{
}
void QMacKeyValueObserver::addObserver(NSKeyValueObservingOptions options)
{
[object addObserver:observer forKeyPath:keyPath options:options context:callback.get()];

View File

@ -81,6 +81,24 @@
#define QT_MAC_WEAK_IMPORT(symbol) extern "C" decltype(symbol) symbol __attribute__((weak_import));
#if defined(__OBJC__)
#define QT_DECLARE_NAMESPACED_OBJC_INTERFACE(classname, definition) \
@interface QT_MANGLE_NAMESPACE(classname) : \
definition \
@end \
QT_NAMESPACE_ALIAS_OBJC_CLASS(classname);
#else
#define QT_DECLARE_NAMESPACED_OBJC_INTERFACE(classname, definition) \
Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(classname)); \
using classname = QT_MANGLE_NAMESPACE(classname);
#endif
#define QT_FORWARD_DECLARE_OBJC_ENUM(name, type) \
typedef type name;
Q_FORWARD_DECLARE_OBJC_CLASS(NSObject);
Q_FORWARD_DECLARE_OBJC_CLASS(NSString);
QT_BEGIN_NAMESPACE
template <typename T, typename U, U (*RetainFunction)(U), void (*ReleaseFunction)(U)>
class QAppleRefCounted
@ -307,24 +325,25 @@ QT_MAC_WEAK_IMPORT(_os_activity_current);
// -------------------------------------------------------------------------
#if defined( __OBJC__)
class QMacNotificationObserver
class Q_CORE_EXPORT QMacNotificationObserver
{
public:
QMacNotificationObserver() {}
#if defined( __OBJC__)
template<typename Functor>
QMacNotificationObserver(id object, NSNotificationName name, Functor callback) {
QMacNotificationObserver(NSObject *object, NSNotificationName name, Functor callback) {
observer = [[NSNotificationCenter defaultCenter] addObserverForName:name
object:object queue:nil usingBlock:^(NSNotification *) {
callback();
}
];
}
#endif
QMacNotificationObserver(const QMacNotificationObserver& other) = delete;
QMacNotificationObserver(QMacNotificationObserver&& other) : observer(other.observer) {
other.observer = nil;
other.observer = nullptr;
}
QMacNotificationObserver &operator=(const QMacNotificationObserver& other) = delete;
@ -332,26 +351,20 @@ public:
if (this != &other) {
remove();
observer = other.observer;
other.observer = nil;
other.observer = nullptr;
}
return *this;
}
void remove() {
if (observer)
[[NSNotificationCenter defaultCenter] removeObserver:observer];
observer = nil;
}
void remove();
~QMacNotificationObserver() { remove(); }
private:
id observer = nil;
NSObject *observer = nullptr;
};
QT_END_NAMESPACE
@interface QT_MANGLE_NAMESPACE(KeyValueObserver) : NSObject
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(KeyValueObserver);
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(KeyValueObserver, NSObject)
QT_BEGIN_NAMESPACE
class Q_CORE_EXPORT QMacKeyValueObserver
@ -361,16 +374,17 @@ public:
QMacKeyValueObserver() {}
#if defined( __OBJC__)
// Note: QMacKeyValueObserver must not outlive the object observed!
QMacKeyValueObserver(id object, NSString *keyPath, Callback callback,
QMacKeyValueObserver(NSObject *object, NSString *keyPath, Callback callback,
NSKeyValueObservingOptions options = NSKeyValueObservingOptionNew)
: object(object), keyPath(keyPath), callback(new Callback(callback))
{
addObserver(options);
}
#endif
QMacKeyValueObserver(const QMacKeyValueObserver &other)
: QMacKeyValueObserver(other.object, other.keyPath, *other.callback.get()) {}
QMacKeyValueObserver(const QMacKeyValueObserver &other);
QMacKeyValueObserver(QMacKeyValueObserver &&other) { swap(other, *this); }
@ -397,15 +411,16 @@ private:
std::swap(first.callback, second.callback);
}
#if defined( __OBJC__)
void addObserver(NSKeyValueObservingOptions options);
#endif
id object = nil;
NSObject *object = nullptr;
NSString *keyPath = nullptr;
std::unique_ptr<Callback> callback;
static KeyValueObserver *observer;
};
#endif
// -------------------------------------------------------------------------

View File

@ -36,18 +36,16 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCOCOAACCESIBILITY_H
#define QCOCOAACCESIBILITY_H
#include <AppKit/AppKit.h>
#ifndef QT_NO_ACCESSIBILITY
#include <QtGui>
#include <qpa/qplatformaccessibility.h>
#include "qcocoaaccessibilityelement.h"
#ifndef QT_NO_ACCESSIBILITY
QT_BEGIN_NAMESPACE
class QCocoaAccessibility : public QPlatformAccessibility
@ -81,6 +79,7 @@ namespace QCocoaAccessible {
demand.
*/
#if defined(__OBJC__)
NSString *macRole(QAccessibleInterface *interface);
NSString *macSubrole(QAccessibleInterface *interface);
bool shouldBeIgnored(QAccessibleInterface *interface);
@ -89,6 +88,7 @@ NSString *getTranslatedAction(const QString &qtAction);
QString translateAction(NSString *nsAction, QAccessibleInterface *interface);
bool hasValueAttribute(QAccessibleInterface *interface);
id getValueAttribute(QAccessibleInterface *interface);
#endif // __OBJC__
}

View File

@ -36,6 +36,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoaaccessibility.h"
#include "qcocoaaccessibilityelement.h"
#include <QtGui/qaccessible.h>

View File

@ -36,28 +36,21 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#ifndef QCOCOAACCESIBILITYELEMENT_H
#define QCOCOAACCESIBILITYELEMENT_H
#ifndef QT_NO_ACCESSIBILITY
#include <QtCore/qglobal.h>
#include <QtCore/private/qcore_mac_p.h>
#include <QtGui/qaccessible.h>
#ifndef QT_NO_ACCESSIBILITY
#import <Cocoa/Cocoa.h>
#import <AppKit/NSAccessibility.h>
#import <qaccessible.h>
@interface QT_MANGLE_NAMESPACE(QMacAccessibilityElement) : NSObject <NSAccessibilityElement>
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QMacAccessibilityElement, NSObject <NSAccessibilityElement>
- (instancetype)initWithId:(QAccessible::Id)anId;
+ (instancetype)elementWithId:(QAccessible::Id)anId;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement);
)
#endif // QT_NO_ACCESSIBILITY

View File

@ -36,6 +36,9 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoaaccessibilityelement.h"
#include "qcocoaaccessibility.h"
#include "qcocoahelpers.h"
@ -46,8 +49,6 @@
#include <QtGui/private/qaccessiblebridgeutils_p.h>
#include <QtGui/qaccessible.h>
#import <AppKit/NSAccessibility.h>
QT_USE_NAMESPACE
#ifndef QT_NO_ACCESSIBILITY

View File

@ -83,16 +83,13 @@
// We mean it.
//
#ifndef QCOCOAAPPLICATION_H
#define QCOCOAAPPLICATION_H
#include <qglobal.h>
#include <QtCore/private/qcore_mac_p.h>
#import <AppKit/AppKit.h>
@interface QT_MANGLE_NAMESPACE(QNSApplication) : NSApplication
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSApplication);
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QNSApplication, NSApplication)
QT_BEGIN_NAMESPACE
@ -101,3 +98,4 @@ void qt_resetNSApplicationSendEvent();
QT_END_NAMESPACE
#endif // QCOCOAAPPLICATION_H

View File

@ -71,6 +71,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoaapplication.h"
#include "qcocoaintrospection.h"

View File

@ -84,24 +84,26 @@
// We mean it.
//
#import <AppKit/AppKit.h>
#ifndef QCOCOAAPPLICATIONDELEGATE_H
#define QCOCOAAPPLICATIONDELEGATE_H
#include <qglobal.h>
#include <private/qcore_mac_p.h>
#include "qcocoansmenu.h"
@interface QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) : NSObject <NSApplicationDelegate>
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QCocoaApplicationDelegate, NSObject <NSApplicationDelegate>
@property (nonatomic, retain) NSMenu *dockMenu;
+ (instancetype)sharedDelegate;
- (void)setReflectionDelegate:(NSObject<NSApplicationDelegate> *)oldDelegate;
- (void)removeAppleEventHandlers;
- (bool)inLaunch;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaApplicationDelegate);
)
#if defined(__OBJC__)
@interface QCocoaApplicationDelegate (MenuAPI)
- (void)qt_itemFired:(QCocoaNSMenuItem *)item;
@end
#endif
#endif // QCOCOAAPPLICATIONDELEGATE_H

View File

@ -71,13 +71,15 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#import "qcocoaapplicationdelegate.h"
#include "qcocoaapplicationdelegate.h"
#include "qcocoaintegration.h"
#include "qcocoamenu.h"
#include "qcocoamenuloader.h"
#include "qcocoamenuitem.h"
#include "qcocoansmenu.h"
#include "qcocoahelpers.h"
#if QT_CONFIG(sessionmanager)
# include "qcocoasessionmanager.h"

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoabackingstore.h"
#include "qcocoawindow.h"

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include <QtCore/qdebug.h>
#include <QtCore/qtimer.h>
#include <qpa/qplatformtheme.h>
@ -46,8 +48,6 @@
#include "qcocoaeventdispatcher.h"
#include "private/qcoregraphics_p.h"
#import <AppKit/AppKit.h>
QT_USE_NAMESPACE
@interface QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) : NSObject<NSWindowDelegate, QNSPanelDelegate>

View File

@ -40,11 +40,11 @@
#ifndef QWINDOWSCURSOR_H
#define QWINDOWSCURSOR_H
#include <AppKit/AppKit.h>
#include <QtCore>
#include <qpa/qplatformcursor.h>
Q_FORWARD_DECLARE_OBJC_CLASS(NSCursor);
QT_BEGIN_NAMESPACE
class QCocoaCursor : public QPlatformCursor

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoacursor.h"
#include "qcocoawindow.h"
#include "qcocoascreen.h"

View File

@ -40,7 +40,6 @@
#ifndef QCOCOADRAG_H
#define QCOCOADRAG_H
#include <AppKit/AppKit.h>
#include <QtGui>
#include <qpa/qplatformdrag.h>
#include <private/qsimpledrag_p.h>
@ -50,6 +49,10 @@
#include <QtCore/qeventloop.h>
Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
Q_FORWARD_DECLARE_OBJC_CLASS(NSEvent);
Q_FORWARD_DECLARE_OBJC_CLASS(NSPasteboard);
QT_BEGIN_NAMESPACE
class QCocoaDrag : public QPlatformDrag

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoadrag.h"
#include "qmacclipboard.h"
#include "qcocoahelpers.h"

View File

@ -71,6 +71,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoaeventdispatcher.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
@ -89,8 +91,6 @@
#include <QtCore/qdebug.h>
#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
static inline CFRunLoopRef mainRunLoop()

View File

@ -44,12 +44,7 @@
#include <qpa/qplatformdialoghelper.h>
#include <QtCore/private/qcore_mac_p.h>
#import <AppKit/NSSavePanel.h>
@interface QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate) : NSObject<NSOpenSavePanelDelegate>
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate);
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QNSOpenSavePanelDelegate, NSObject<NSOpenSavePanelDelegate>)
QT_BEGIN_NAMESPACE

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include <qpa/qplatformtheme.h>
#include "qcocoafiledialoghelper.h"
@ -64,8 +66,7 @@
#include <qpa/qplatformnativeinterface.h>
#import <AppKit/NSSavePanel.h>
#import <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFNumber.h>
QT_FORWARD_DECLARE_CLASS(QString)
QT_FORWARD_DECLARE_CLASS(QStringList)

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include <QtCore/qtimer.h>
#include <QtGui/qfontdatabase.h>
#include <qpa/qplatformtheme.h>
@ -49,8 +51,6 @@
#include "qcocoahelpers.h"
#include "qcocoaeventdispatcher.h"
#import <AppKit/AppKit.h>
#if !CGFLOAT_DEFINED
typedef float CGFloat; // Should only not be defined on 32-bit platforms
#endif

View File

@ -46,7 +46,8 @@
#include <QtGui/QOpenGLContext>
#include <QtGui/QWindow>
#include <AppKit/AppKit.h>
Q_FORWARD_DECLARE_OBJC_CLASS(NSOpenGLContext);
Q_FORWARD_DECLARE_OBJC_CLASS(NSOpenGLPixelFormat);
QT_BEGIN_NAMESPACE

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoaglcontext.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"
@ -46,8 +48,6 @@
#include <QtPlatformHeaders/qcocoanativecontext.h>
#include <dlfcn.h>
#import <AppKit/AppKit.h>
static inline QByteArray getGlString(GLenum param)
{
if (const GLubyte *s = glGetString(param))

View File

@ -51,8 +51,6 @@
// We mean it.
//
#include <AppKit/AppKit.h>
#include <private/qguiapplication_p.h>
#include <QtCore/qoperatingsystemversion.h>
#include <QtCore/qloggingcategory.h>
@ -62,6 +60,8 @@
#include <objc/runtime.h>
#include <objc/message.h>
#if defined(__OBJC__)
Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSView));
struct mach_header;
@ -377,5 +377,7 @@ QSendSuperHelper<Args...> qt_objcDynamicSuperHelper(id receiver, SEL selector, A
// Same as calling super, but the super_class field resolved at runtime instead of compile time
#define qt_objcDynamicSuper(...) qt_objcDynamicSuperHelper(self, _cmd, ##__VA_ARGS__)
#endif // __OBJC__
#endif //QCOCOAHELPERS_H

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include <qpa/qplatformtheme.h>
#include "qcocoahelpers.h"

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qnsview.h"
#include "qcocoainputcontext.h"
#include "qcocoanativeinterface.h"

View File

@ -40,8 +40,6 @@
#ifndef QPLATFORMINTEGRATION_COCOA_H
#define QPLATFORMINTEGRATION_COCOA_H
#include <AppKit/AppKit.h>
#include "qcocoacursor.h"
#include "qcocoawindow.h"
#include "qcocoanativeinterface.h"
@ -59,6 +57,8 @@
#include <qpa/qplatformintegration.h>
#include <QtGui/private/qcoretextfontdatabase_p.h>
Q_FORWARD_DECLARE_OBJC_CLASS(NSToolbar);
QT_BEGIN_NAMESPACE
class QCocoaIntegration : public QObject, public QPlatformIntegration

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoaintegration.h"
#include "qcocoawindow.h"

View File

@ -71,8 +71,11 @@
**
****************************************************************************/
#ifndef QCOCOAINTROSPECTION_H
#define QCOCOAINTROSPECTION_H
#include <qglobal.h>
#import <objc/objc-class.h>
#include <objc/objc-class.h>
QT_BEGIN_NAMESPACE
@ -80,3 +83,5 @@ void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class prox
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel);
QT_END_NAMESPACE
#endif // QCOCOAINTROSPECTION_H

View File

@ -40,14 +40,13 @@
#ifndef QCOCOAKEYMAPPER_H
#define QCOCOAKEYMAPPER_H
#include "qcocoahelpers.h"
#include <AppKit/AppKit.h>
#include <Carbon/Carbon.h>
#include <QtCore/QList>
#include <QtGui/QKeyEvent>
#include <QtCore/private/qcore_mac_p.h>
QT_BEGIN_NAMESPACE
/*

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoakeymapper.h"
#include <QtCore/QDebug>

View File

@ -43,6 +43,7 @@
#include <QtCore/QList>
#include <qpa/qplatformmenu.h>
#include "qcocoamenuitem.h"
#include "qcocoansmenu.h"

View File

@ -38,6 +38,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoamenu.h"
#include "qcocoansmenu.h"

View File

@ -38,6 +38,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include <qpa/qplatformtheme.h>
#include "qcocoamenuitem.h"

View File

@ -51,12 +51,11 @@
// We mean it.
//
#import <AppKit/AppKit.h>
#include <QtCore/private/qcore_mac_p.h>
QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem);
@interface QT_MANGLE_NAMESPACE(QCocoaMenuLoader) : NSObject
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QCocoaMenuLoader, NSObject
+ (instancetype)sharedMenuLoader;
- (NSMenu *)menu;
- (void)ensureAppMenuInMenu:(NSMenu *)menu;
@ -68,8 +67,6 @@ QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem);
- (NSMenuItem *)appSpecificMenuItem:(QCocoaMenuItem *)platformItem;
- (void)qtTranslateApplicationMenu;
- (NSArray<NSMenuItem *> *)mergeable;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaMenuLoader);
)
#endif // QCOCOAMENULOADER_P_H

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoamenuloader.h"
#include "qcocoahelpers.h"

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoamimetypes.h"
#include <QtGui/private/qmacmime_p.h>
#include "qcocoahelpers.h"

View File

@ -37,9 +37,12 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoanativeinterface.h"
#include "qcocoawindow.h"
#include "qcocoamenu.h"
#include "qcocoansmenu.h"
#include "qcocoamenubar.h"
#include "qcocoahelpers.h"
#include "qcocoaapplicationdelegate.h"
@ -63,8 +66,6 @@
#include <QtPlatformHeaders/qcocoawindowfunctions.h>
#include <AppKit/AppKit.h>
#if QT_CONFIG(vulkan)
#include <MoltenVK/mvk_vulkan.h>
#endif

View File

@ -51,32 +51,26 @@
// We mean it.
//
#import <AppKit/AppKit.h>
#include "qcocoahelpers.h"
#include <QtCore/private/qcore_mac_p.h>
QT_FORWARD_DECLARE_CLASS(QCocoaMenu);
QT_FORWARD_DECLARE_CLASS(QCocoaMenuItem);
@interface QT_MANGLE_NAMESPACE(QCocoaNSMenuDelegate) : NSObject <NSMenuDelegate>
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QCocoaNSMenuDelegate, NSObject <NSMenuDelegate>
+ (instancetype)sharedMenuDelegate;
- (NSMenuItem *)findItemInMenu:(NSMenu *)menu forKey:(NSString *)key modifiers:(NSUInteger)modifiers;
@end
)
@interface QT_MANGLE_NAMESPACE(QCocoaNSMenu) : NSMenu
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QCocoaNSMenu, NSMenu
@property (readonly, nonatomic) QCocoaMenu *platformMenu;
- (instancetype)initWithPlatformMenu:(QCocoaMenu *)menu;
@end
)
@interface QT_MANGLE_NAMESPACE(QCocoaNSMenuItem) : NSMenuItem
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QCocoaNSMenuItem, NSMenuItem
@property (nonatomic) QCocoaMenuItem *platformMenuItem;
+ (instancetype)separatorItemWithPlatformMenuItem:(QCocoaMenuItem *)menuItem;
- (instancetype)initWithPlatformMenuItem:(QCocoaMenuItem *)menuItem;
- (instancetype)init;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaNSMenu);
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaNSMenuItem);
QT_NAMESPACE_ALIAS_OBJC_CLASS(QCocoaNSMenuDelegate);
)
#endif // QCOCOANSMENU_H

View File

@ -37,12 +37,15 @@
**
****************************************************************************/
#import "qcocoansmenu.h"
#include <AppKit/AppKit.h>
#include "qcocoansmenu.h"
#include "qcocoamenu.h"
#include "qcocoamenuitem.h"
#include "qcocoamenubar.h"
#include "qcocoawindow.h"
#import "qnsview.h"
#include "qnsview.h"
#include "qcocoahelpers.h"
#include <QtCore/qcoreapplication.h>
#include <QtCore/qcoreevent.h>

View File

@ -40,12 +40,16 @@
#ifndef QCOCOASCREEN_H
#define QCOCOASCREEN_H
#include <AppKit/AppKit.h>
#include "qcocoacursor.h"
#include <qpa/qplatformintegration.h>
#include <CoreGraphics/CoreGraphics.h>
#include <CoreVideo/CoreVideo.h>
Q_FORWARD_DECLARE_OBJC_CLASS(NSScreen);
Q_FORWARD_DECLARE_OBJC_CLASS(NSArray);
QT_BEGIN_NAMESPACE
class QCocoaIntegration;
@ -136,8 +140,10 @@ QDebug operator<<(QDebug debug, const QCocoaScreen *screen);
QT_END_NAMESPACE
#if defined(__OBJC__)
@interface NSScreen (QtExtras)
@property(readonly) CGDirectDisplayID qt_displayId;
@end
#endif
#endif // QCOCOASCREEN_H

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoascreen.h"
#include "qcocoawindow.h"

View File

@ -47,18 +47,20 @@
#if QT_CONFIG(systemtrayicon)
#include <QtCore/qstring.h>
#include <QtCore/private/qcore_mac_p.h>
#include <QtGui/qpa/qplatformsystemtrayicon.h>
#include "qcocoamenu.h"
QT_FORWARD_DECLARE_CLASS(QCocoaSystemTrayIcon);
@interface QT_MANGLE_NAMESPACE(QStatusItemDelegate) : NSObject <NSUserNotificationCenterDelegate>
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QStatusItemDelegate, NSObject <NSUserNotificationCenterDelegate>
- (instancetype)initWithSysTray:(QCocoaSystemTrayIcon *)platformSystemTray;
@property (nonatomic, assign) QCocoaSystemTrayIcon *platformSystemTray;
@end
)
QT_NAMESPACE_ALIAS_OBJC_CLASS(QStatusItemDelegate);
Q_FORWARD_DECLARE_OBJC_CLASS(NSStatusItem);
QT_BEGIN_NAMESPACE

View File

@ -72,6 +72,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoasystemtrayicon.h"
#ifndef QT_NO_SYSTEMTRAYICON
@ -83,14 +85,13 @@
#include <QtCore/private/qcore_mac_p.h>
#include "qcocoamenu.h"
#include "qcocoansmenu.h"
#include "qcocoahelpers.h"
#include "qcocoaintegration.h"
#include "qcocoascreen.h"
#include <QtGui/private/qcoregraphics_p.h>
#import <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
void QCocoaSystemTrayIcon::init()

View File

@ -37,7 +37,7 @@
**
****************************************************************************/
#import <AppKit/AppKit.h>
#include <AppKit/AppKit.h>
#include "qcocoatheme.h"

View File

@ -49,8 +49,6 @@
#include <QtCore/QHash>
#include <QtGui/private/qbasicvulkanplatforminstance_p.h>
#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
class QCocoaVulkanInstance : public QBasicPlatformVulkanInstance

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoavulkaninstance.h"
#include "qcocoawindow.h"

View File

@ -40,8 +40,6 @@
#ifndef QCOCOAWINDOW_H
#define QCOCOAWINDOW_H
#include <AppKit/AppKit.h>
#include <qpa/qplatformwindow.h>
#include <QRect>
#include <QPointer>
@ -56,6 +54,15 @@
#include <MoltenVK/mvk_vulkan.h>
#endif
Q_FORWARD_DECLARE_OBJC_CLASS(NSWindow);
Q_FORWARD_DECLARE_OBJC_CLASS(NSView);
Q_FORWARD_DECLARE_OBJC_CLASS(NSCursor);
#if !defined(__OBJC__)
using NSInteger = long;
using NSUInteger = unsigned long;
#endif
QT_BEGIN_NAMESPACE
#ifndef QT_NO_DEBUG_STREAM
@ -262,7 +269,7 @@ public: // for QNSView
static const int NoAlertRequest;
NSInteger m_alertRequest;
id monitor;
NSObject *m_monitor;
bool m_drawContentBorderGradient;
int m_topContentBorderThickness;

View File

@ -36,6 +36,10 @@
** $QT_END_LICENSE$
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include <QuartzCore/QuartzCore.h>
#include "qcocoawindow.h"
#include "qcocoaintegration.h"
#include "qcocoascreen.h"
@ -57,9 +61,6 @@
#include <QtGui/private/qcoregraphics_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <AppKit/AppKit.h>
#include <QuartzCore/QuartzCore.h>
#include <QDebug>
#include <vector>
@ -149,7 +150,7 @@ QCocoaWindow::QCocoaWindow(QWindow *win, WId nativeHandle)
, m_registerTouchCount(0)
, m_resizableTransientParent(false)
, m_alertRequest(NoAlertRequest)
, monitor(nil)
, m_monitor(nil)
, m_drawContentBorderGradient(false)
, m_topContentBorderThickness(0)
, m_bottomContentBorderThickness(0)
@ -389,7 +390,7 @@ void QCocoaWindow::setVisible(bool visible)
removeMonitor();
NSEventMask eventMask = NSEventMaskLeftMouseDown | NSEventMaskRightMouseDown
| NSEventMaskOtherMouseDown | NSEventMaskMouseMoved;
monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *e) {
m_monitor = [NSEvent addGlobalMonitorForEventsMatchingMask:eventMask handler:^(NSEvent *e) {
const auto button = cocoaButton2QtButton(e);
const auto buttons = currentlyPressedMouseButtons();
const auto eventType = cocoaEvent2QtMouseEvent(e);
@ -1678,10 +1679,10 @@ bool QCocoaWindow::alwaysShowToolWindow() const
void QCocoaWindow::removeMonitor()
{
if (!monitor)
if (!m_monitor)
return;
[NSEvent removeMonitor:monitor];
monitor = nil;
[NSEvent removeMonitor:m_monitor];
m_monitor = nil;
}
bool QCocoaWindow::setWindowModified(bool modified)

View File

@ -42,8 +42,6 @@
#include <QtCore/qglobal.h>
#include <AppKit/AppKit.h>
QT_BEGIN_NAMESPACE
class QCocoaWindowManager

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qcocoawindowmanager.h"
#include "qcocoawindow.h"

View File

@ -43,6 +43,8 @@
#include <qpa/qplatformgraphicsbuffer.h>
#include <private/qcore_mac_p.h>
#include <IOSurface/IOSurface.h>
QT_BEGIN_NAMESPACE
class QIOSurfaceGraphicsBuffer : public QPlatformGraphicsBuffer

View File

@ -43,7 +43,7 @@
#include <QtGui>
#include <QtGui/private/qmacmime_p.h>
#import <AppKit/AppKit.h>
#include <ApplicationServices/ApplicationServices.h>
QT_BEGIN_NAMESPACE

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qmacclipboard.h"
#include <QtGui/qclipboard.h>
#include <QtGui/qguiapplication.h>

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qmultitouch_mac_p.h"
#include "qcocoahelpers.h"
#include "qcocoascreen.h"

View File

@ -52,14 +52,16 @@
#define QMULTITOUCH_MAC_P_H
#include <QtCore/qglobal.h>
#import <AppKit/AppKit.h>
#include <qpa/qwindowsysteminterface.h>
#include <qhash.h>
#include <QtCore>
#include <QtGui/qtouchdevice.h>
#include <QtCore/private/qcore_mac_p.h>
Q_FORWARD_DECLARE_OBJC_CLASS(NSTouch);
QT_FORWARD_DECLARE_OBJC_ENUM(NSTouchPhase, unsigned long);
QT_BEGIN_NAMESPACE
class QCocoaTouch

View File

@ -40,9 +40,6 @@
#ifndef QNSVIEW_H
#define QNSVIEW_H
#include <AppKit/AppKit.h>
#include <MetalKit/MetalKit.h>
#include <QtCore/private/qcore_mac_p.h>
QT_BEGIN_NAMESPACE
@ -51,14 +48,13 @@ class QCocoaGLContext;
class QPointF;
QT_END_NAMESPACE
@interface QT_MANGLE_NAMESPACE(QNSView) : NSView
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QNSView, NSView
@property (nonatomic, retain) NSCursor *cursor;
- (instancetype)initWithCocoaWindow:(QCocoaWindow *)platformWindow;
- (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint;
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView);
)
#if defined(__OBJC__)
@interface QNSView (MouseAPI)
- (void)handleFrameStrutMouseEvent:(NSEvent *)theEvent;
- (void)resetMouseButtons;
@ -76,5 +72,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSView);
@interface QNSView (QtExtras)
@property (nonatomic, readonly) QCocoaWindow *platformWindow;
@end
#endif // __OBJC__
#endif //QNSVIEW_H

View File

@ -39,6 +39,9 @@
#include <QtGui/qtguiglobal.h>
#include <AppKit/AppKit.h>
#include <MetalKit/MetalKit.h>
#include "qnsview.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"

View File

@ -45,7 +45,7 @@
#include <QtGui/qaccessible.h>
#import <AppKit/NSAccessibility.h>
#include <AppKit/NSAccessibility.h>
@implementation QNSView (Accessibility)

View File

@ -44,10 +44,10 @@
#include <QPointer>
#include <QtCore/private/qcore_mac_p.h>
#include <AppKit/AppKit.h>
QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
#if defined(__OBJC__)
// @compatibility_alias doesn't work with categories or their methods
#define FullScreenProperty QT_MANGLE_NAMESPACE(FullScreenProperty)
#define qt_fullScreen QT_MANGLE_NAMESPACE(qt_fullScreen)
@ -69,10 +69,11 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
@interface QT_MANGLE_NAMESPACE(QNSWindow) : NSWindow<QNSWindowProtocol> @end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindow);
#else
class QCocoaNSWindow;
#endif // __OBJC__
@interface QT_MANGLE_NAMESPACE(QNSPanel) : NSPanel<QNSWindowProtocol> @end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSPanel);
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QNSWindow, NSWindow <QNSWindowProtocol>)
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QNSPanel, NSPanel <QNSWindowProtocol>)
#endif // QNSWINDOW_H

View File

@ -39,6 +39,8 @@
#if !defined(QNSWINDOW_PROTOCOL_IMPLMENTATION)
#include <AppKit/AppKit.h>
#include "qnswindow.h"
#include "qcocoawindow.h"
#include "qcocoahelpers.h"

View File

@ -40,16 +40,12 @@
#ifndef QNSWINDOWDELEGATE_H
#define QNSWINDOWDELEGATE_H
#include <AppKit/AppKit.h>
#include <QtCore/private/qcore_mac_p.h>
QT_BEGIN_NAMESPACE
class QCocoaWindow;
QT_END_NAMESPACE
@interface QT_MANGLE_NAMESPACE(QNSWindowDelegate) : NSObject <NSWindowDelegate>
@end
QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowDelegate);
QT_DECLARE_NAMESPACED_OBJC_INTERFACE(QNSWindowDelegate, NSObject <NSWindowDelegate>)
#endif // QNSWINDOWDELEGATE_H

View File

@ -37,6 +37,8 @@
**
****************************************************************************/
#include <AppKit/AppKit.h>
#include "qnswindowdelegate.h"
#include "qcocoahelpers.h"
#include "qcocoawindow.h"