macOS: Add qnswindow_cast helper function
Change-Id: If4394e4fbee271c926c0c1c32de1f9783319d994 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io> (cherry picked from commit ba2d109c5f091cf5307a15b096da56f50ad44412) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
88dd567930
commit
1d84c2d479
@ -36,6 +36,8 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
|
|||||||
|
|
||||||
typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
|
typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
|
||||||
|
|
||||||
|
QCocoaNSWindow *qnswindow_cast(NSWindow *window);
|
||||||
|
|
||||||
#else
|
#else
|
||||||
class QCocoaNSWindow;
|
class QCocoaNSWindow;
|
||||||
#endif // __OBJC__
|
#endif // __OBJC__
|
||||||
|
@ -58,6 +58,15 @@ static bool isMouseEvent(NSEvent *ev)
|
|||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
NSWindow<QNSWindowProtocol> *qnswindow_cast(NSWindow *window)
|
||||||
|
{
|
||||||
|
if ([window conformsToProtocol:@protocol(QNSWindowProtocol)])
|
||||||
|
return static_cast<QCocoaNSWindow *>(window);
|
||||||
|
else
|
||||||
|
return nil;
|
||||||
|
}
|
||||||
|
|
||||||
@implementation QNSWindow
|
@implementation QNSWindow
|
||||||
#define QNSWINDOW_PROTOCOL_IMPLMENTATION 1
|
#define QNSWINDOW_PROTOCOL_IMPLMENTATION 1
|
||||||
#include "qnswindow.mm"
|
#include "qnswindow.mm"
|
||||||
|
@ -23,9 +23,7 @@ static inline bool isWhiteSpace(const QString &s)
|
|||||||
|
|
||||||
static QCocoaWindow *toPlatformWindow(NSWindow *window)
|
static QCocoaWindow *toPlatformWindow(NSWindow *window)
|
||||||
{
|
{
|
||||||
if ([window conformsToProtocol:@protocol(QNSWindowProtocol)])
|
return qnswindow_cast(window).platformWindow;
|
||||||
return static_cast<QCocoaNSWindow *>(window).platformWindow;
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@implementation QNSWindowDelegate
|
@implementation QNSWindowDelegate
|
||||||
|
Loading…
x
Reference in New Issue
Block a user