summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-10-12 15:33:13 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2016-10-13 16:52:01 +0000
commitc79710a1819d906bbcf98e3fa2a1133e5c5cb66e (patch)
treecf7ff8e4c4de051ca9d242817e2747b65c409fff
parent2f505b79a49bdf5ba8d084e13ab339bcf956c849 (diff)
macOS: Remove QNSView member m_window in favor of going via m_platformWindow
The two should never be out of sync, but by having them as separate members we risk that they do. By going though m_platformWindow for QWindow access, it's also more clear in the callsites that we're dealing with a QWindow instead of a NSWindow, as referenced though self.window. Finally, removing the member slims down memory use of a QNSView, however small. Change-Id: Iec96cebf813fae82d3af339331781419f234c28b Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm2
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h3
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm148
-rw-r--r--src/plugins/platforms/cocoa/qnsviewaccessibility.mm4
4 files changed, 82 insertions, 75 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 6700bc28a9..4be1917f2d 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
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 57b159bbf5..abaff39e81 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -64,7 +64,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
CGImageRef m_maskImage;
uchar *m_maskData;
bool m_shouldInvalidateWindowShadow;
- QPointer<QWindow> m_window;
QPointer<QCocoaWindow> m_platformWindow;
NSTrackingArea *m_trackingArea;
Qt::MouseButtons m_buttons;
@@ -91,7 +90,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper));
}
- (id)init;
-- (id)initWithQWindow:(QWindow *)window platformWindow:(QCocoaWindow *) platformWindow;
+- (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 1f92dc82d6..f90713d48d 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;
@@ -266,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 {
@@ -282,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) {
@@ -297,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();
}
@@ -351,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,
@@ -367,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.
@@ -386,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();
@@ -400,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
@@ -434,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();
}
}
@@ -486,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();
@@ -551,7 +553,7 @@ static bool _q_dontOverrideCtrlLMB = false;
- (void) drawRect:(NSRect)dirtyRect
{
- qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_window << QRectF::fromCGRect(dirtyRect);
+ qCDebug(lcQpaCocoaWindow) << "[QNSView drawRect:]" << m_platformWindow->window() << QRectF::fromCGRect(dirtyRect);
#ifndef QT_NO_OPENGL
if (m_glContext && m_shouldSetGLContextinDrawRect) {
@@ -636,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]);
@@ -649,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;
}
@@ -665,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;
}
@@ -676,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;
@@ -765,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);
}
@@ -819,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]);
@@ -856,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]);
@@ -877,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]);
@@ -900,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;
@@ -1069,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;
@@ -1091,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];
@@ -1102,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.
@@ -1121,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.
@@ -1197,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];
@@ -1252,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;
@@ -1301,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
@@ -1313,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
@@ -1321,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
@@ -1329,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
@@ -1337,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
@@ -1369,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);
}
@@ -1381,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;
}
@@ -1395,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);
}
@@ -1417,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);
}
@@ -1428,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);
}
@@ -1439,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
@@ -1447,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;
@@ -1520,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
@@ -1628,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)];
@@ -1650,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)];
@@ -1711,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,
@@ -1924,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();
@@ -1946,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();
@@ -2123,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;
@@ -2134,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());
@@ -2146,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;
@@ -2154,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;
@@ -2172,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();
@@ -2190,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;
@@ -2207,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];
}