summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-05-20 13:46:21 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-05-23 21:09:46 +0200
commit56d6e000f7487c59172330ebd23a718268c508f1 (patch)
tree1494432583b1569816075091a8075b31d795f77c /src/plugins/platforms/cocoa/qcocoawindow.mm
parent9fd407fc6a29c94b4568dd042a05c208255179e0 (diff)
parentc276aa51303b7c6f8e4cd854aadf8344a906e50f (diff)
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts: mkspecs/wince80colibri-armv7-msvc2012/qmake.conf qmake/generators/win32/msvc_vcproj.cpp src/corelib/global/qnamespace.h src/corelib/global/qnamespace.qdoc src/corelib/io/qfsfileengine_win.cpp src/corelib/tools/tools.pri src/network/ssl/qsslconfiguration_p.h src/plugins/platforms/linuxfb/qlinuxfbscreen.cpp src/plugins/platforms/windows/windows.pri src/src.pro src/tools/bootstrap/bootstrap.pro src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/dialogs/qfilesystemmodel.cpp tests/auto/testlib/selftests/expected_cmptest.teamcity tests/auto/testlib/selftests/expected_cmptest.txt Change-Id: I4d2ac78f0dcc97f008186bbbc769c6fe588ab0e5
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm37
1 files changed, 22 insertions, 15 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 01e72303be..eaa0170748 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -90,7 +90,7 @@ static bool isMouseEvent(NSEvent *ev)
self = [super init];
if (self) {
_window = window;
- _platformWindow = platformWindow;
+ _platformWindow.assign(platformWindow);
_window.delegate = [[QNSWindowDelegate alloc] initWithQCocoaWindow:_platformWindow];
@@ -99,7 +99,6 @@ static bool isMouseEvent(NSEvent *ev)
// make sure that m_nsWindow stays valid until the
// QCocoaWindow is deleted by Qt.
[_window setReleasedWhenClosed:NO];
- _watcher = &_platformWindow->sentinel;
}
return self;
@@ -108,19 +107,19 @@ static bool isMouseEvent(NSEvent *ev)
- (void)handleWindowEvent:(NSEvent *)theEvent
{
QCocoaWindow *pw = self.platformWindow;
- if (_watcher && pw && pw->m_forwardWindow) {
+ if (pw && pw->m_forwardWindow) {
if (theEvent.type == NSLeftMouseUp || theEvent.type == NSLeftMouseDragged) {
QNSView *forwardView = pw->m_qtView;
if (theEvent.type == NSLeftMouseUp) {
[forwardView mouseUp:theEvent];
- pw->m_forwardWindow = 0;
+ pw->m_forwardWindow.clear();
} else {
[forwardView mouseDragged:theEvent];
}
}
if (!pw->m_isNSWindowChild && theEvent.type == NSLeftMouseDown) {
- pw->m_forwardWindow = 0;
+ pw->m_forwardWindow.clear();
}
}
@@ -147,7 +146,7 @@ static bool isMouseEvent(NSEvent *ev)
if (!self.window.delegate)
return; // Already detached, pending NSAppKitDefined event
- if (_watcher && pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
+ if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
NSPoint loc = [theEvent locationInWindow];
NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]];
NSRect contentFrame = [[self.window contentView] frame];
@@ -162,8 +161,7 @@ static bool isMouseEvent(NSEvent *ev)
- (void)detachFromPlatformWindow
{
- _platformWindow = 0;
- _watcher.clear();
+ self.platformWindow.clear();
[self.window.delegate release];
self.window.delegate = nil;
}
@@ -184,7 +182,7 @@ static bool isMouseEvent(NSEvent *ev)
- (void)dealloc
{
_window = nil;
- _platformWindow = 0;
+ self.platformWindow.clear();
[super dealloc];
}
@@ -336,6 +334,18 @@ static bool isMouseEvent(NSEvent *ev)
@end
+void QCocoaWindowPointer::assign(QCocoaWindow *w)
+{
+ window = w;
+ watcher = &w->sentinel;
+}
+
+void QCocoaWindowPointer::clear()
+{
+ window = Q_NULLPTR;
+ watcher.clear();
+}
+
const int QCocoaWindow::NoAlertRequest = -1;
QCocoaWindow::QCocoaWindow(QWindow *tlw)
@@ -343,7 +353,6 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_contentView(nil)
, m_qtView(nil)
, m_nsWindow(0)
- , m_forwardWindow(0)
, m_contentViewIsEmbedded(false)
, m_contentViewIsToBeEmbedded(false)
, m_parentCocoaWindow(0)
@@ -1138,8 +1147,7 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
if (grab && ![m_nsWindow isKeyWindow])
[m_nsWindow makeKeyWindow];
- else if (!grab && [m_nsWindow isKeyWindow])
- [m_nsWindow resignKeyWindow];
+
return true;
}
@@ -1151,8 +1159,7 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab)
if (grab && ![m_nsWindow isKeyWindow])
[m_nsWindow makeKeyWindow];
- else if (!grab && [m_nsWindow isKeyWindow])
- [m_nsWindow resignKeyWindow];
+
return true;
}
@@ -1339,7 +1346,7 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
if (oldParentCocoaWindow) {
if (!m_isNSWindowChild || oldParentCocoaWindow != m_parentCocoaWindow)
oldParentCocoaWindow->removeChildWindow(this);
- m_forwardWindow = oldParentCocoaWindow;
+ m_forwardWindow.assign(oldParentCocoaWindow);
}
setNSWindow(m_nsWindow);