summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2014-07-03 23:56:45 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2014-07-03 23:56:45 +0200
commit39a290af6cea538dbbdb207d03d2af3602015c95 (patch)
tree19aa95412d02cf53e87c53364ef3ca98780c45c6 /src/plugins/platforms/cocoa
parent0541516907da117c391b6c8d9820209673fcd9cd (diff)
parent19d289ab1b5bde3e136765e5432b5c7d004df3a4 (diff)
Merge remote-tracking branch 'origin/5.3' into dev
Conflicts: src/gui/accessible/qaccessiblecache_mac.mm src/gui/accessible/qaccessiblecache_p.h src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h src/plugins/platforms/cocoa/qcocoawindow.h src/plugins/platforms/cocoa/qcocoawindow.mm src/widgets/kernel/qwidget_qpa.cpp Manually moved change in qwidget_qpa.cpp to qwidget.cpp (cd07830e3b27da7e96a0a83f91ba08c168b45e62) Change-Id: Ia51f471f9b53de2f3b07d77ea89db9303ac8961d
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h11
-rw-r--r--src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm2
-rw-r--r--src/plugins/platforms/cocoa/qcocoamenuitem.mm7
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h21
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm28
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h1
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm18
-rw-r--r--src/plugins/platforms/cocoa/qnswindowdelegate.h4
8 files changed, 69 insertions, 23 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
index ca34deceef..4a5baefbc5 100644
--- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
+++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.h
@@ -43,22 +43,25 @@
#include <QtCore/qglobal.h>
+#include "qt_mac_p.h"
+
#import <Cocoa/Cocoa.h>
#import <AppKit/NSAccessibility.h>
#import <qaccessible.h>
-Q_FORWARD_DECLARE_OBJC_CLASS(QMacAccessibilityElement);
+@class QT_MANGLE_NAMESPACE(QMacAccessibilityElement);
-@interface QMacAccessibilityElement : NSObject {
+@interface QT_MANGLE_NAMESPACE(QMacAccessibilityElement) : NSObject {
NSString *role;
QAccessible::Id axid;
}
- (id)initWithId:(QAccessible::Id)anId;
-+ (QMacAccessibilityElement *)elementWithId:(QAccessible::Id)anId;
++ (QT_MANGLE_NAMESPACE(QMacAccessibilityElement) *)elementWithId:(QAccessible::Id)anId;
@end
-#endif
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QMacAccessibilityElement);
+#endif
diff --git a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
index 2f5355b180..efe3269d42 100644
--- a/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
+++ b/src/plugins/platforms/cocoa/qcocoaapplicationdelegate.mm
@@ -433,7 +433,7 @@ static void cleanupCocoaApplicationDelegate()
{
Q_UNUSED(replyEvent);
NSString *urlString = [[event paramDescriptorForKeyword:keyDirectObject] stringValue];
- QWindowSystemInterface::handleFileOpenEvent(QCFString::toQString(urlString));
+ QWindowSystemInterface::handleFileOpenEvent(QUrl(QCFString::toQString(urlString)));
}
- (void)appleEventQuit:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEventDescriptor *)replyEvent
diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
index 32692edde4..4b9a0146a9 100644
--- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm
+++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm
@@ -329,12 +329,13 @@ NSMenuItem *QCocoaMenuItem::sync()
[m_native setKeyEquivalentModifierMask:NSCommandKeyMask];
}
+ NSImage *img = nil;
if (!m_icon.isNull()) {
- NSImage *img = qt_mac_create_nsimage(m_icon);
+ img = qt_mac_create_nsimage(m_icon);
[img setSize:NSMakeSize(16, 16)];
- [m_native setImage: img];
- [img release];
}
+ [m_native setImage:img];
+ [img release];
[m_native setState:m_checked ? NSOnState : NSOffState];
return m_native;
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 66a81b0d9f..8f885ab5f3 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -51,14 +51,15 @@
#include "qcocoaglcontext.h"
#endif
#include "qnsview.h"
+#include "qt_mac_p.h"
QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
-@class QNSWindowHelper;
+@class QT_MANGLE_NAMESPACE(QNSWindowHelper);
@protocol QNSWindowProtocol
-@property (nonatomic, readonly) QNSWindowHelper *helper;
+@property (nonatomic, readonly) QT_MANGLE_NAMESPACE(QNSWindowHelper) *helper;
- (void)superSendEvent:(NSEvent *)theEvent;
- (void)closeAndRelease;
@@ -67,7 +68,7 @@ QT_FORWARD_DECLARE_CLASS(QCocoaWindow)
typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
-@interface QNSWindowHelper : NSObject
+@interface QT_MANGLE_NAMESPACE(QNSWindowHelper) : NSObject
{
QCocoaNSWindow *_window;
QCocoaWindow *_platformWindow;
@@ -86,7 +87,9 @@ typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
@end
-@interface QNSWindow : NSWindow<QNSWindowProtocol>
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowHelper);
+
+@interface QT_MANGLE_NAMESPACE(QNSWindow) : NSWindow<QNSWindowProtocol>
{
QNSWindowHelper *_helper;
}
@@ -99,7 +102,9 @@ typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
@end
-@interface QNSPanel : NSPanel<QNSWindowProtocol>
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindow);
+
+@interface QT_MANGLE_NAMESPACE(QNSPanel) : NSPanel<QNSWindowProtocol>
{
QNSWindowHelper *_helper;
}
@@ -112,7 +117,9 @@ typedef NSWindow<QNSWindowProtocol> QCocoaNSWindow;
@end
-@class QNSWindowDelegate;
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSPanel);
+
+@class QT_MANGLE_NAMESPACE(QNSWindowDelegate);
QT_BEGIN_NAMESPACE
// QCocoaWindow
@@ -227,6 +234,7 @@ public:
void obscureWindow();
void updateExposedGeometry();
QWindow *childWindowAt(QPoint windowPoint);
+ bool shouldRefuseKeyWindowAndFirstResponder();
protected:
void recreateWindow(const QPlatformWindow *parentWindow);
QCocoaNSWindow *createNSWindow();
@@ -267,6 +275,7 @@ public: // for QNSView
bool m_windowUnderMouse;
bool m_inConstructor;
+ bool m_inSetVisible;
#ifndef QT_NO_OPENGL
QCocoaGLContext *m_glContext;
#endif
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index a7ebf4148c..29b983cd89 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -239,6 +239,9 @@ static bool isMouseEvent(NSEvent *ev)
if (!pw || pw->m_isNSWindowChild)
return NO;
+ if (pw->shouldRefuseKeyWindowAndFirstResponder())
+ return NO;
+
// The default implementation returns NO for title-bar less windows,
// override and return yes here to make sure popup windows such as
// the combobox popup can become the key window.
@@ -316,6 +319,9 @@ static bool isMouseEvent(NSEvent *ev)
if (!pw)
return NO;
+ if (pw->shouldRefuseKeyWindowAndFirstResponder())
+ return NO;
+
// Only tool or dialog windows should become key:
Qt::WindowType type = pw->window()->type();
if (type == Qt::Tool || type == Qt::Dialog)
@@ -368,6 +374,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
, m_windowModality(Qt::NonModal)
, m_windowUnderMouse(false)
, m_inConstructor(true)
+ , m_inSetVisible(false)
#ifndef QT_NO_OPENGL
, m_glContext(0)
#endif
@@ -616,6 +623,8 @@ void QCocoaWindow::setVisible(bool visible)
if (m_isNSWindowChild && m_hiddenByClipping)
return;
+ m_inSetVisible = true;
+
QCocoaAutoReleasePool pool;
QCocoaWindow *parentCocoaWindow = 0;
if (window()->transientParent())
@@ -755,6 +764,8 @@ void QCocoaWindow::setVisible(bool visible)
[parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask];
}
}
+
+ m_inSetVisible = false;
}
NSInteger QCocoaWindow::windowLevel(Qt::WindowFlags flags)
@@ -1784,6 +1795,23 @@ QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint)
return targetWindow;
}
+bool QCocoaWindow::shouldRefuseKeyWindowAndFirstResponder()
+{
+ // This function speaks up if there's any reason
+ // to refuse key window or first responder state.
+
+ if (window()->flags() & Qt::WindowDoesNotAcceptFocus)
+ return true;
+
+ if (m_inSetVisible) {
+ QVariant showWithoutActivating = window()->property("_q_showWithoutActivating");
+ if (showWithoutActivating.isValid() && showWithoutActivating.toBool())
+ return true;
+ }
+
+ return false;
+}
+
QMargins QCocoaWindow::frameMargins() const
{
NSRect frameW = [m_nsWindow frame];
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index 53eee4a95d..a75e366a73 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -65,6 +65,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QNSViewMouseMoveHelper);
QWindow *m_window;
QCocoaWindow *m_platformWindow;
Qt::MouseButtons m_buttons;
+ Qt::MouseButtons m_frameStrutButtons;
QString m_composingText;
bool m_sendKeyEvent;
QStringList *currentCustomDragTypes;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 4a562f8a4e..cc8fe51e0f 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -142,6 +142,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
m_shouldInvalidateWindowShadow = false;
m_window = 0;
m_buttons = Qt::NoButton;
+ m_frameStrutButtons = Qt::NoButton;
m_sendKeyEvent = false;
m_subscribesForGlobalFrameNotifications = false;
#ifndef QT_NO_OPENGL
@@ -603,7 +604,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
- (BOOL)acceptsFirstResponder
{
- if (m_window->flags() & Qt::WindowDoesNotAcceptFocus)
+ if (m_platformWindow->shouldRefuseKeyWindowAndFirstResponder())
return NO;
if (m_window->flags() & Qt::WindowTransparentForInput)
return NO;
@@ -661,6 +662,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
- (void)resetMouseButtons
{
m_buttons = Qt::NoButton;
+ m_frameStrutButtons = Qt::NoButton;
}
- (void)handleMouseEvent:(NSEvent *)theEvent
@@ -693,22 +695,22 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
NSEventType ty = [theEvent type];
switch (ty) {
case NSLeftMouseDown:
- m_buttons |= Qt::LeftButton;
+ m_frameStrutButtons |= Qt::LeftButton;
break;
case NSLeftMouseUp:
- m_buttons &= ~Qt::LeftButton;
+ m_frameStrutButtons &= ~Qt::LeftButton;
break;
case NSRightMouseDown:
- m_buttons |= Qt::RightButton;
+ m_frameStrutButtons |= Qt::RightButton;
break;
case NSRightMouseUp:
- m_buttons &= ~Qt::RightButton;
+ m_frameStrutButtons &= ~Qt::RightButton;
break;
case NSOtherMouseDown:
- m_buttons |= cocoaButton2QtButton([theEvent buttonNumber]);
+ m_frameStrutButtons |= cocoaButton2QtButton([theEvent buttonNumber]);
break;
case NSOtherMouseUp:
- m_buttons &= ~cocoaButton2QtButton([theEvent buttonNumber]);
+ m_frameStrutButtons &= ~cocoaButton2QtButton([theEvent buttonNumber]);
default:
break;
}
@@ -726,7 +728,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
QPoint qtScreenPoint = QPoint(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y));
ulong timestamp = [theEvent timestamp] * 1000;
- QWindowSystemInterface::handleFrameStrutMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_buttons);
+ QWindowSystemInterface::handleFrameStrutMouseEvent(m_window, timestamp, qtWindowPoint, qtScreenPoint, m_frameStrutButtons);
}
- (void)mouseDown:(NSEvent *)theEvent
diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h
index 5717551cc3..083466861b 100644
--- a/src/plugins/platforms/cocoa/qnswindowdelegate.h
+++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h
@@ -46,7 +46,7 @@
#include "qcocoawindow.h"
-@interface QNSWindowDelegate : NSObject <NSWindowDelegate>
+@interface QT_MANGLE_NAMESPACE(QNSWindowDelegate) : NSObject <NSWindowDelegate>
{
QCocoaWindow *m_cocoaWindow;
}
@@ -62,4 +62,6 @@
@end
+QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSWindowDelegate);
+
#endif // QNSWINDOWDELEGATE_H