diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-10-05 13:22:42 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2019-10-15 20:09:28 +0200 |
commit | 027d45cb57a7cf20b2714509250a87f1e8842b9c (patch) | |
tree | cb76992b6640dcb31df618a4349bf9f2c9759bd6 /src/plugins/platforms/cocoa/qnsview.mm | |
parent | 05a829f923a88e69b2ceaa372820a2dcb8c083cd (diff) |
macOS: Simplify Objective-C namespacing
We only need to use the QT_MANGLE_NAMESPACE macro when declaring the
interface of the class. As long as we couple that with an alias
declaration using QT_NAMESPACE_ALIAS_OBJC_CLASS, any further uses
of the class name can be un-namespaced, including declaring
categories on the class.
The only snag with QT_NAMESPACE_ALIAS_OBJC_CLASS is that it can
only be used once per class and translation unit, so forward
declarations get hairy, but we can avoid that by just including
the headers instead.
Change-Id: I333bcd18fe1e18d81fbd560b0941c98b1c32460e
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src/plugins/platforms/cocoa/qnsview.mm')
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 5309449dce..a6e5ca5f7b 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -66,13 +66,13 @@ #include "qcocoaintegration.h" // Private interface -@interface QT_MANGLE_NAMESPACE(QNSView) () +@interface QNSView () - (BOOL)isTransparentForUserInput; @property (assign) NSView* previousSuperview; @property (assign) NSWindow* previousWindow; @end -@interface QT_MANGLE_NAMESPACE(QNSView) (Drawing) <CALayerDelegate> +@interface QNSView (Drawing) <CALayerDelegate> - (void)initDrawing; @end @@ -84,7 +84,9 @@ - (void)cursorUpdate:(NSEvent *)theEvent; @end -@interface QT_MANGLE_NAMESPACE(QNSView) (Mouse) +QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSViewMouseMoveHelper); + +@interface QNSView (Mouse) - (void)initMouse; - (NSPoint)screenMousePoint:(NSEvent *)theEvent; - (void)mouseMovedImpl:(NSEvent *)theEvent; @@ -92,28 +94,28 @@ - (void)mouseExitedImpl:(NSEvent *)theEvent; @end -@interface QT_MANGLE_NAMESPACE(QNSView) (Touch) +@interface QNSView (Touch) @end -@interface QT_MANGLE_NAMESPACE(QNSView) (Tablet) +@interface QNSView (Tablet) - (bool)handleTabletEvent:(NSEvent *)theEvent; @end -@interface QT_MANGLE_NAMESPACE(QNSView) (Gestures) +@interface QNSView (Gestures) @end -@interface QT_MANGLE_NAMESPACE(QNSView) (Dragging) +@interface QNSView (Dragging) -(void)registerDragTypes; @end -@interface QT_MANGLE_NAMESPACE(QNSView) (Keys) +@interface QNSView (Keys) @end -@interface QT_MANGLE_NAMESPACE(QNSView) (ComplexText) <NSTextInputClient> +@interface QNSView (ComplexText) <NSTextInputClient> - (void)textInputContextKeyboardSelectionDidChangeNotification:(NSNotification *)textInputContextKeyboardSelectionDidChangeNotification; @end -@implementation QT_MANGLE_NAMESPACE(QNSView) { +@implementation QNSView { QPointer<QCocoaWindow> m_platformWindow; Qt::MouseButtons m_buttons; Qt::MouseButtons m_acceptedMouseDowns; @@ -125,7 +127,7 @@ bool m_sendUpAsRightButton; Qt::KeyboardModifiers m_currentWheelModifiers; NSString *m_inputSource; - QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper; + QNSViewMouseMoveHelper *m_mouseMoveHelper; bool m_resendKeyEvent; bool m_scrolling; bool m_updatingDrag; @@ -379,7 +381,7 @@ // ----------------------------------------------------- -@implementation QT_MANGLE_NAMESPACE(QNSView) (QtExtras) +@implementation QNSView (QtExtras) - (QCocoaWindow*)platformWindow { |