diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-10-18 13:58:30 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2016-10-18 13:59:52 +0200 |
commit | e61833a1e59cea9718d29a954f91dbb1d7dac3c3 (patch) | |
tree | e5415bd97ba7b21181dc2a8dc048aba08155e496 /src/plugins | |
parent | 45580aa92557caa4f3f5be783573ddb80602e494 (diff) | |
parent | 542a76c490cee7359f9c5116248977cab72b7b63 (diff) |
Merge branch 5.8 into dev
Conflicts:
src/plugins/platforms/cocoa/qnsview.mm
Change-Id: I655e8d04cece341e8b9fb69e94c09335ffa108e1
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 9 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qmacclipboard.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qmacdefines_mac.h | 57 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.h | 6 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 154 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsviewaccessibility.mm | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qt_mac_p.h | 4 |
9 files changed, 108 insertions, 130 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm index 5c27cf8059..b2b9fe2c1e 100644 --- a/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm +++ b/src/plugins/platforms/cocoa/qcocoaeventdispatcher.mm @@ -85,7 +85,6 @@ #include "private/qguiapplication_p.h" #include <qdebug.h> -#undef slots #include <AppKit/AppKit.h> #include <Carbon/Carbon.h> diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index 5bee708b76..1a66cec0e3 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -45,7 +45,6 @@ #include <QtGui/QOpenGLContext> #include <QtGui/QWindow> -#undef slots #include <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index f87ddab455..2d4e53a420 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -388,7 +388,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) if (tlw->type() == Qt::ForeignWindow) { m_view = (NSView *)WId(tlw->property("_q_foreignWinId").value<WId>()); } else { - m_view = [[QNSView alloc] initWithQWindow:tlw platformWindow:this]; + m_view = [[QNSView alloc] initWithCocoaWindow:this]; // Enable high-dpi OpenGL for retina displays. Enabling has the side // effect that Cocoa will start calling glViewport(0, 0, width, height), // overriding any glViewport calls in application code. This is usually not a @@ -433,13 +433,6 @@ QCocoaWindow::~QCocoaWindow() if (window()->type() != Qt::ForeignWindow) [[NSNotificationCenter defaultCenter] removeObserver:m_view]; - // The QNSView object may outlive the corresponding QCocoaWindow object, - // for example during app shutdown when the QNSView is embedded in a - // foregin NSView hiearchy. Clear the pointers to the QWindow/QCocoaWindow - // here to make sure QNSView does not dereference stale pointers. - if (window()->type() != Qt::ForeignWindow) - [qnsview_cast(m_view) clearQWindowPointers]; - // While it is unlikely that this window will be in the popup stack // during deletetion we clear any pointers here to make sure. if (QCocoaIntegration::instance()) { diff --git a/src/plugins/platforms/cocoa/qmacclipboard.h b/src/plugins/platforms/cocoa/qmacclipboard.h index a3abacf849..2ee0cb91e4 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.h +++ b/src/plugins/platforms/cocoa/qmacclipboard.h @@ -43,8 +43,6 @@ #include <QtGui> #include <QtPlatformSupport/private/qmacmime_p.h> -#undef slots - #import <AppKit/AppKit.h> QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qmacdefines_mac.h b/src/plugins/platforms/cocoa/qmacdefines_mac.h index e27f805fca..9e229b8dcb 100644 --- a/src/plugins/platforms/cocoa/qmacdefines_mac.h +++ b/src/plugins/platforms/cocoa/qmacdefines_mac.h @@ -93,42 +93,31 @@ typedef signed int OSStatus; typedef signed long OSStatus; #endif +typedef struct OpaqueEventHandlerCallRef * EventHandlerCallRef; +typedef struct OpaqueEventRef * EventRef; +typedef struct OpaqueMenuRef * MenuRef; +typedef struct OpaquePasteboardRef* PasteboardRef; +typedef struct OpaqueRgnHandle * RgnHandle; +typedef const struct __HIShape *HIShapeRef; +typedef struct __HIShape *HIMutableShapeRef; +typedef struct CGRect CGRect; +typedef struct CGImage *CGImageRef; +typedef struct CGContext *CGContextRef; +typedef struct GDevice * GDPtr; +typedef GDPtr * GDHandle; +typedef struct OpaqueIconRef * IconRef; + #ifdef __OBJC__ -# ifdef slots -# define old_slots slots -# undef slots -# endif -#include <AppKit/AppKit.h> -# ifdef old_slots -# undef slots -# define slots -# undef old_slots -# endif +typedef NSWindow* OSWindowRef; +typedef NSView *OSViewRef; +typedef NSMenu *OSMenuRef; +typedef NSEvent *OSEventRef; +#else +typedef void *OSWindowRef; +typedef void *OSViewRef; +typedef void *OSMenuRef; +typedef void *OSEventRef; #endif - typedef struct OpaqueEventHandlerCallRef * EventHandlerCallRef; - typedef struct OpaqueEventRef * EventRef; - typedef struct OpaqueMenuRef * MenuRef; - typedef struct OpaquePasteboardRef* PasteboardRef; - typedef struct OpaqueRgnHandle * RgnHandle; - typedef const struct __HIShape *HIShapeRef; - typedef struct __HIShape *HIMutableShapeRef; - typedef struct CGRect CGRect; - typedef struct CGImage *CGImageRef; - typedef struct CGContext *CGContextRef; - typedef struct GDevice * GDPtr; - typedef GDPtr * GDHandle; - typedef struct OpaqueIconRef * IconRef; -# ifdef __OBJC__ - typedef NSWindow* OSWindowRef; - typedef NSView *OSViewRef; - typedef NSMenu *OSMenuRef; - typedef NSEvent *OSEventRef; -# else - typedef void *OSWindowRef; - typedef void *OSViewRef; - typedef void *OSMenuRef; - typedef void *OSEventRef; -# endif typedef PasteboardRef OSPasteboardRef; typedef struct AEDesc AEDescList; diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index 963b29ebbb..abaff39e81 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -64,8 +64,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); CGImageRef m_maskImage; uchar *m_maskData; bool m_shouldInvalidateWindowShadow; - QPointer<QWindow> m_window; - QCocoaWindow *m_platformWindow; + QPointer<QCocoaWindow> m_platformWindow; NSTrackingArea *m_trackingArea; Qt::MouseButtons m_buttons; Qt::MouseButtons m_acceptedMouseDowns; @@ -91,8 +90,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); } - (id)init; -- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow; -- (void) clearQWindowPointers; +- (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow; #ifndef QT_NO_OPENGL - (void)setQCocoaGLContext:(QCocoaGLContext *)context; #endif diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index ca4df73e6d..dfdc3facb4 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -126,6 +126,11 @@ static bool _q_dontOverrideCtrlLMB = false; @end +// Private interface +@interface QT_MANGLE_NAMESPACE(QNSView) () +- (BOOL)isTransparentForUserInput; +@end + @implementation QT_MANGLE_NAMESPACE(QNSView) + (void)initialize @@ -140,7 +145,6 @@ static bool _q_dontOverrideCtrlLMB = false; m_backingStore = 0; m_maskImage = 0; m_shouldInvalidateWindowShadow = false; - m_window = 0; m_buttons = Qt::NoButton; m_acceptedMouseDowns = Qt::NoButton; m_frameStrutButtons = Qt::NoButton; @@ -177,7 +181,6 @@ static bool _q_dontOverrideCtrlLMB = false; CGImageRelease(m_maskImage); [m_trackingArea release]; m_maskImage = 0; - m_window = 0; m_subscribesForGlobalFrameNotifications = false; [m_inputSource release]; [[NSNotificationCenter defaultCenter] removeObserver:self]; @@ -188,13 +191,12 @@ static bool _q_dontOverrideCtrlLMB = false; [super dealloc]; } -- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow +- (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow { self = [self init]; if (!self) return 0; - m_window = window; m_platformWindow = platformWindow; m_sendKeyEvent = false; m_trackingArea = nil; @@ -229,12 +231,6 @@ static bool _q_dontOverrideCtrlLMB = false; return self; } -- (void) clearQWindowPointers -{ - m_window = 0; - m_platformWindow = 0; -} - #ifndef QT_NO_OPENGL - (void) setQCocoaGLContext:(QCocoaGLContext *)context { @@ -272,7 +268,7 @@ static bool _q_dontOverrideCtrlLMB = false; if ([self superview]) { m_platformWindow->m_viewIsEmbedded = true; - QWindowSystemInterface::handleGeometryChange(m_window, m_platformWindow->geometry()); + QWindowSystemInterface::handleGeometryChange(m_platformWindow->window(), m_platformWindow->geometry()); m_platformWindow->updateExposedGeometry(); QWindowSystemInterface::flushWindowSystemEvents(); } else { @@ -288,7 +284,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)viewWillMoveToWindow:(NSWindow *)newWindow { // ### Merge "normal" window code path with this one for 5.1. - if (!(m_window->type() & Qt::SubWindow)) + if (!(m_platformWindow->window()->type() & Qt::SubWindow)) return; if (newWindow) { @@ -303,11 +299,11 @@ static bool _q_dontOverrideCtrlLMB = false; - (QWindow *)topLevelWindow { - QWindow *focusWindow = m_window; + QWindow *focusWindow = m_platformWindow->window(); // For widgets we need to do a bit of trickery as the window // to activate is the window of the top-level widget. - if (qstrcmp(m_window->metaObject()->className(), "QWidgetWindow") == 0) { + if (qstrcmp(focusWindow->metaObject()->className(), "QWidgetWindow") == 0) { while (focusWindow->parent()) { focusWindow = focusWindow->parent(); } @@ -357,7 +353,7 @@ static bool _q_dontOverrideCtrlLMB = false; if (m_platformWindow->m_inSetStyleMask && !self.window) return; - qCDebug(lcQpaCocoaWindow) << "[QNSView udpateGeometry:]" << m_window + qCDebug(lcQpaCocoaWindow) << "[QNSView udpateGeometry:]" << m_platformWindow->window() << "current" << m_platformWindow->geometry() << "new" << geometry; // Call setGeometry on QPlatformWindow. (not on QCocoaWindow, @@ -373,7 +369,7 @@ static bool _q_dontOverrideCtrlLMB = false; // Send a geometry change event to Qt, if it's ready to handle events if (!m_platformWindow->m_inConstructor) { - QWindowSystemInterface::handleGeometryChange(m_window, geometry); + QWindowSystemInterface::handleGeometryChange(m_platformWindow->window(), geometry); m_platformWindow->updateExposedGeometry(); // Guard against processing window system events during QWindow::setGeometry // calles, which Qt and Qt applications do not excpect. @@ -392,7 +388,7 @@ static bool _q_dontOverrideCtrlLMB = false; // So we should say that it is maximized because it actually is. if (newState == Qt::WindowNoState && m_platformWindow->m_effectivelyMaximized) newState = Qt::WindowMaximized; - QWindowSystemInterface::handleWindowStateChanged(m_window, newState); + QWindowSystemInterface::handleWindowStateChanged(m_platformWindow->window(), newState); // We want to read the window state back from the window, // but the event we just sent may be asynchronous. QWindowSystemInterface::flushWindowSystemEvents(); @@ -406,7 +402,7 @@ static bool _q_dontOverrideCtrlLMB = false; NSString *notificationName = [windowNotification name]; if (notificationName == NSWindowDidBecomeKeyNotification) { if (!m_platformWindow->windowIsPopupType() && !m_isMenuView) - QWindowSystemInterface::handleWindowActivated(m_window); + QWindowSystemInterface::handleWindowActivated(m_platformWindow->window()); } else if (notificationName == NSWindowDidResignKeyNotification) { // key window will be non-nil if another window became key... do not // set the active window to zero here, the new key window's @@ -440,12 +436,12 @@ static bool _q_dontOverrideCtrlLMB = false; } } } else if (notificationName == NSWindowDidChangeScreenNotification) { - if (m_window) { + if (m_platformWindow->window()) { NSUInteger screenIndex = [[NSScreen screens] indexOfObject:self.window.screen]; if (screenIndex != NSNotFound) { QCocoaScreen *cocoaScreen = QCocoaIntegration::instance()->screenAtIndex(screenIndex); if (cocoaScreen) - QWindowSystemInterface::handleWindowScreenChanged(m_window, cocoaScreen->screen()); + QWindowSystemInterface::handleWindowScreenChanged(m_platformWindow->window(), cocoaScreen->screen()); m_platformWindow->updateExposedGeometry(); } } @@ -492,7 +488,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void) flushBackingStore:(QCocoaBackingStore *)backingStore region:(const QRegion &)region offset:(QPoint)offset { - qCDebug(lcQpaCocoaWindow) << "[QNSView flushBackingStore:]" << m_window << region.rectCount() << region.boundingRect() << offset; + qCDebug(lcQpaCocoaWindow) << "[QNSView flushBackingStore:]" << m_platformWindow->window() << region.rectCount() << region.boundingRect() << offset; m_backingStore = backingStore; m_backingStoreOffset = offset * m_backingStore->paintDevice()->devicePixelRatio(); @@ -557,7 +553,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void) drawRect:(NSRect)dirtyRect { - qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_window << QRectF::fromCGRect(NSRectToCGRect(dirtyRect)); + qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_platformWindow->window() << QRectF::fromCGRect(NSRectToCGRect(dirtyRect)); #ifndef QT_NO_OPENGL if (m_glContext && m_shouldSetGLContextinDrawRect) { @@ -642,11 +638,17 @@ static bool _q_dontOverrideCtrlLMB = false; return YES; } +- (BOOL)isTransparentForUserInput +{ + return m_platformWindow->window() && + m_platformWindow->window()->flags() & Qt::WindowTransparentForInput; +} + - (BOOL)becomeFirstResponder { - if (!m_window || !m_platformWindow) + if (!m_platformWindow) return NO; - if (m_window->flags() & Qt::WindowTransparentForInput) + if ([self isTransparentForUserInput]) return NO; if (!m_platformWindow->windowIsPopupType() && !m_isMenuView) QWindowSystemInterface::handleWindowActivated([self topLevelWindow]); @@ -655,15 +657,15 @@ static bool _q_dontOverrideCtrlLMB = false; - (BOOL)acceptsFirstResponder { - if (!m_window || !m_platformWindow) + if (!m_platformWindow) return NO; if (m_isMenuView) return NO; if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder()) return NO; - if (m_window->flags() & Qt::WindowTransparentForInput) + if ([self isTransparentForUserInput]) return NO; - if ((m_window->flags() & Qt::ToolTip) == Qt::ToolTip) + if ((m_platformWindow->window()->flags() & Qt::ToolTip) == Qt::ToolTip) return NO; return YES; } @@ -671,9 +673,9 @@ static bool _q_dontOverrideCtrlLMB = false; - (BOOL)acceptsFirstMouse:(NSEvent *)theEvent { Q_UNUSED(theEvent) - if (!m_window || !m_platformWindow) + if (!m_platformWindow) return NO; - if (m_window->flags() & Qt::WindowTransparentForInput) + if ([self isTransparentForUserInput]) return NO; return YES; } @@ -682,7 +684,7 @@ static bool _q_dontOverrideCtrlLMB = false; { NSView *candidate = [super hitTest:aPoint]; if (candidate == self) { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput)) + if ([self isTransparentForUserInput]) return nil; } return candidate; @@ -771,7 +773,7 @@ static bool _q_dontOverrideCtrlLMB = false; nativeDrag->setLastMouseEvent(theEvent, self); Qt::KeyboardModifiers keyboardModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]]; - QWindowSystemInterface::handleMouseEvent(targetView->m_window, timestamp, qtWindowPoint, qtScreenPoint, + QWindowSystemInterface::handleMouseEvent(targetView->m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_buttons, keyboardModifiers, Qt::MouseEventNotSynthesized); } @@ -825,12 +827,12 @@ static bool _q_dontOverrideCtrlLMB = false; QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); ulong timestamp = [theEvent timestamp] * 1000; - QWindowSystemInterface::handleFrameStrutMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons); + QWindowSystemInterface::handleFrameStrutMouseEvent(m_platformWindow->window(), timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons); } - (bool)handleMouseDownEvent:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput)) + if ([self isTransparentForUserInput]) return false; Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); @@ -862,7 +864,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (bool)handleMouseDraggedEvent:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput)) + if ([self isTransparentForUserInput]) return false; Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); @@ -883,7 +885,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (bool)handleMouseUpEvent:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput)) + if ([self isTransparentForUserInput]) return false; Qt::MouseButton button = cocoaButton2QtButton([theEvent buttonNumber]); @@ -906,7 +908,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseDown:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return [super mouseDown:theEvent]; m_sendUpAsRightButton = false; @@ -1075,7 +1077,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (void)mouseMovedImpl:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return; QPointF windowPoint; @@ -1097,7 +1099,7 @@ static bool _q_dontOverrideCtrlLMB = false; // Cocoa keeps firing mouse move events for obscured parent views. Qt should not // send those events so filter them out here. - if (childWindow != m_window) + if (childWindow != m_platformWindow->window()) return; [self handleMouseEvent: theEvent]; @@ -1108,7 +1110,7 @@ static bool _q_dontOverrideCtrlLMB = false; Q_UNUSED(theEvent) m_platformWindow->m_windowUnderMouse = true; - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return; // Top-level windows generate enter events for sub-windows. @@ -1127,7 +1129,7 @@ static bool _q_dontOverrideCtrlLMB = false; Q_UNUSED(theEvent); m_platformWindow->m_windowUnderMouse = false; - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return; // Top-level windows generate leave events for sub-windows. @@ -1203,16 +1205,16 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) windowPoint.x(), windowPoint.y(), screenPoint.x(), screenPoint.y(), static_cast<uint>(buttons), pressure, xTilt, yTilt, rotation); - QWindowSystemInterface::handleTabletEvent(m_window, timestamp, windowPoint, screenPoint, + QWindowSystemInterface::handleTabletEvent(m_platformWindow->window(), timestamp, windowPoint, screenPoint, deviceData.device, deviceData.pointerType, buttons, pressure, xTilt, yTilt, tangentialPressure, rotation, z, deviceData.uid, keyboardModifiers); return true; } -- (void)tabletPoint: (NSEvent *)theEvent +- (void)tabletPoint:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return [super tabletPoint:theEvent]; [self handleTabletEvent: theEvent]; @@ -1258,9 +1260,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) return device; } -- (void)tabletProximity: (NSEvent *)theEvent +- (void)tabletProximity:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return [super tabletProximity:theEvent]; ulong timestamp = [theEvent timestamp] * 1000; @@ -1307,11 +1309,11 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) } } -- (bool) shouldSendSingleTouch +- (bool)shouldSendSingleTouch { // QtWidgets expects single-point touch events, QtDeclarative does not. // Until there is an API we solve this by looking at the window class type. - return m_window->inherits("QWidgetWindow"); + return m_platformWindow->window()->inherits("QWidgetWindow"); } - (void)touchesBeganWithEvent:(NSEvent *)event @@ -1319,7 +1321,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesBeganWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points); + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); } - (void)touchesMovedWithEvent:(NSEvent *)event @@ -1327,7 +1329,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesMovedWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points); + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); } - (void)touchesEndedWithEvent:(NSEvent *)event @@ -1335,7 +1337,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesEndedWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points); + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); } - (void)touchesCancelledWithEvent:(NSEvent *)event @@ -1343,7 +1345,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; const QList<QWindowSystemInterface::TouchPoint> points = QCocoaTouch::getCurrentTouchPointList(event, [self shouldSendSingleTouch]); qCDebug(lcQpaTouch) << "touchesCancelledWithEvent" << points; - QWindowSystemInterface::handleTouchEvent(m_window, timestamp * 1000, touchDevice, points); + QWindowSystemInterface::handleTouchEvent(m_platformWindow->window(), timestamp * 1000, touchDevice, points); } #ifndef QT_NO_GESTURES @@ -1375,7 +1377,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::ZoomNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::ZoomNativeGesture, [event magnification], windowPoint, screenPoint); } @@ -1387,7 +1389,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::SmartZoomNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SmartZoomNativeGesture, zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint); zoomIn = !zoomIn; } @@ -1401,7 +1403,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::RotateNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::RotateNativeGesture, -[event rotation], windowPoint, screenPoint); } @@ -1423,7 +1425,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) else if ([event deltaY] == -1) angle = 270.0f; - QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::SwipeNativeGesture, + QWindowSystemInterface::handleGestureEventWithRealValue(m_platformWindow->window(), timestamp, Qt::SwipeNativeGesture, angle, windowPoint, screenPoint); } @@ -1434,7 +1436,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; qCDebug(lcQpaGestures) << "beginGestureWithEvent @" << windowPoint; - QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::BeginNativeGesture, + QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::BeginNativeGesture, windowPoint, screenPoint); } @@ -1445,7 +1447,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF windowPoint; QPointF screenPoint; [self convertFromScreen:[self screenMousePoint:event] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::EndNativeGesture, + QWindowSystemInterface::handleGestureEvent(m_platformWindow->window(), timestamp, Qt::EndNativeGesture, windowPoint, screenPoint); } #endif // QT_NO_GESTURES @@ -1453,7 +1455,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) #ifndef QT_NO_WHEELEVENT - (void)scrollWheel:(NSEvent *)theEvent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return [super scrollWheel:theEvent]; QPoint angleDelta; @@ -1526,7 +1528,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) // "isInverted": natural OS X scrolling, inverted from the Qt/other platform/Jens perspective. bool isInverted = [theEvent isDirectionInvertedFromDevice]; - QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source, isInverted); + QWindowSystemInterface::handleWheelEvent(m_platformWindow->window(), qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph, source, isInverted); } #endif //QT_NO_WHEELEVENT @@ -1634,7 +1636,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)keyDown:(NSEvent *)nsevent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return [super keyDown:nsevent]; const bool accepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyPress)]; @@ -1656,7 +1658,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) - (void)keyUp:(NSEvent *)nsevent { - if (m_window && (m_window->flags() & Qt::WindowTransparentForInput) ) + if ([self isTransparentForUserInput]) return [super keyUp:nsevent]; const bool keyUpAccepted = [self handleKeyEvent:nsevent eventType:int(QEvent::KeyRelease)]; @@ -1717,7 +1719,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) if ((delta & mac_mask) == 0u) continue; - QWindowSystemInterface::handleKeyEvent(m_window, + QWindowSystemInterface::handleKeyEvent(m_platformWindow->window(), timestamp, (lastKnownModifiers & mac_mask) ? QEvent::KeyRelease : QEvent::KeyPress, modifier_key_symbols[i].qt_code, @@ -1930,12 +1932,12 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) if (!queryEvent.value(Qt::ImEnabled).toBool()) return NSZeroRect; - if (!m_window) + if (!m_platformWindow->window()) return NSZeroRect; // The returned rect is always based on the internal cursor. QRect mr = qApp->inputMethod()->cursorRectangle().toRect(); - QPoint mp = m_window->mapToGlobal(mr.bottomLeft()); + QPoint mp = m_platformWindow->window()->mapToGlobal(mr.bottomLeft()); NSRect rect; rect.origin.x = mp.x(); @@ -1952,9 +1954,9 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) return NSNotFound; } -- (NSArray*) validAttributesForMarkedText +- (NSArray*)validAttributesForMarkedText { - if (m_window != QGuiApplication::focusWindow()) + if (m_platformWindow->window() != QGuiApplication::focusWindow()) return nil; QObject *fo = QGuiApplication::focusObject(); @@ -2129,7 +2131,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin QPoint qt_windowPoint(windowPoint.x, windowPoint.y); Qt::DropActions qtAllowed = qt_mac_mapNSDragOperations([sender draggingSourceOperationMask]); - QWindow *target = findEventTargetWindow(m_window); + QWindow *target = findEventTargetWindow(m_platformWindow->window()); if (!target) return NSDragOperationNone; @@ -2140,11 +2142,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); if (nativeDrag->currentDrag()) { // The drag was started from within the application - response = QWindowSystemInterface::handleDrag(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed); + response = QWindowSystemInterface::handleDrag(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed); [self updateCursorFromDragResponse:response drag:nativeDrag]; } else { QCocoaDropData mimeData([sender draggingPasteboard]); - response = QWindowSystemInterface::handleDrag(target, &mimeData, mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed); + response = QWindowSystemInterface::handleDrag(target, &mimeData, mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed); } return qt_mac_mapDropAction(response.acceptedAction()); @@ -2152,7 +2154,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (void)draggingExited:(id <NSDraggingInfo>)sender { - QWindow *target = findEventTargetWindow(m_window); + QWindow *target = findEventTargetWindow(m_platformWindow->window()); if (!target) return; @@ -2160,13 +2162,13 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin QPoint qt_windowPoint(windowPoint.x, windowPoint.y); // Send 0 mime data to indicate drag exit - QWindowSystemInterface::handleDrag(target, 0, mapWindowCoordinates(m_window, target, qt_windowPoint), Qt::IgnoreAction); + QWindowSystemInterface::handleDrag(target, 0, mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), Qt::IgnoreAction); } // called on drop, send the drop to Qt and return if it was accepted. - (BOOL)performDragOperation:(id <NSDraggingInfo>)sender { - QWindow *target = findEventTargetWindow(m_window); + QWindow *target = findEventTargetWindow(m_platformWindow->window()); if (!target) return false; @@ -2178,10 +2180,10 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); if (nativeDrag->currentDrag()) { // The drag was started from within the application - response = QWindowSystemInterface::handleDrop(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed); + response = QWindowSystemInterface::handleDrop(target, nativeDrag->platformDropData(), mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed); } else { QCocoaDropData mimeData([sender draggingPasteboard]); - response = QWindowSystemInterface::handleDrop(target, &mimeData, mapWindowCoordinates(m_window, target, qt_windowPoint), qtAllowed); + response = QWindowSystemInterface::handleDrop(target, &mimeData, mapWindowCoordinates(m_platformWindow->window(), target, qt_windowPoint), qtAllowed); } if (response.isAccepted()) { QCocoaDrag* nativeDrag = QCocoaIntegration::instance()->drag(); @@ -2196,7 +2198,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin { Q_UNUSED(session); Q_UNUSED(operation); - QWindow *target = findEventTargetWindow(m_window); + QWindow *target = findEventTargetWindow(m_platformWindow->window()); if (!target) return; @@ -2213,7 +2215,7 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); - QWindowSystemInterface::handleMouseEvent(target, mapWindowCoordinates(m_window, target, qtWindowPoint), qtScreenPoint, m_buttons); + QWindowSystemInterface::handleMouseEvent(target, mapWindowCoordinates(m_platformWindow->window(), target, qtWindowPoint), qtScreenPoint, m_buttons); } @end diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index bfb4ba8124..73e1f41dd5 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -53,10 +53,10 @@ @implementation QNSView (QNSViewAccessibility) - (id)childAccessibleElement { - if (!m_window->accessibleRoot()) + if (!m_platformWindow->window()->accessibleRoot()) return nil; - QAccessible::Id childId = QAccessible::uniqueId(m_window->accessibleRoot()); + QAccessible::Id childId = QAccessible::uniqueId(m_platformWindow->window()->accessibleRoot()); return [QMacAccessibilityElement elementWithId: childId]; } diff --git a/src/plugins/platforms/cocoa/qt_mac_p.h b/src/plugins/platforms/cocoa/qt_mac_p.h index ce17919e8c..fdcf3bcdd3 100644 --- a/src/plugins/platforms/cocoa/qt_mac_p.h +++ b/src/plugins/platforms/cocoa/qt_mac_p.h @@ -51,13 +51,13 @@ // We mean it. // -#include "qmacdefines_mac.h" - #ifdef __OBJC__ #include <AppKit/AppKit.h> #include <objc/runtime.h> #endif +#include "qmacdefines_mac.h" + #include <CoreServices/CoreServices.h> #include "QtCore/qglobal.h" |