summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa
diff options
context:
space:
mode:
Diffstat (limited to 'src/plugins/platforms/cocoa')
-rw-r--r--src/plugins/platforms/cocoa/cocoa.pro2
-rw-r--r--src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm5
-rw-r--r--src/plugins/platforms/cocoa/qcocoainputcontext.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoainputcontext.mm10
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.h2
-rw-r--r--src/plugins/platforms/cocoa/qcocoaintegration.mm8
-rw-r--r--src/plugins/platforms/cocoa/qcocoasystemsettings.mm19
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.h3
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm116
-rw-r--r--src/plugins/platforms/cocoa/qnsview.h1
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm108
-rw-r--r--src/plugins/platforms/cocoa/qpaintengine_mac.mm6
12 files changed, 218 insertions, 65 deletions
diff --git a/src/plugins/platforms/cocoa/cocoa.pro b/src/plugins/platforms/cocoa/cocoa.pro
index e861f48e7b..2ae39dd16c 100644
--- a/src/plugins/platforms/cocoa/cocoa.pro
+++ b/src/plugins/platforms/cocoa/cocoa.pro
@@ -73,7 +73,7 @@ HEADERS += qcocoaintegration.h \
FORMS += $$PWD/../../../widgets/dialogs/qfiledialog.ui
RESOURCES += qcocoaresources.qrc
-LIBS += -framework Cocoa
+LIBS += -framework Cocoa -framework IOKit
QT += core-private gui-private widgets-private platformsupport-private printsupport
diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
index bfc626fdba..fd4d6605a9 100644
--- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
+++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm
@@ -404,6 +404,11 @@ void QCocoaColorDialogHelper::setCurrentColor_sys(const QColor &color)
if (!mDelegate)
createNSColorPanelDelegate();
QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *delegate = static_cast<QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *>(mDelegate);
+
+ // make sure that if ShowAlphaChannel option is set then also setShowsAlpha
+ // needs to be set, otherwise alpha value is omitted
+ [delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)];
+
NSColor *nsColor;
const QColor::Spec spec = color.spec();
if (spec == QColor::Cmyk) {
diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.h b/src/plugins/platforms/cocoa/qcocoainputcontext.h
index 172c87e2dc..1fda29209d 100644
--- a/src/plugins/platforms/cocoa/qcocoainputcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoainputcontext.h
@@ -59,7 +59,8 @@ public:
virtual void reset();
private Q_SLOTS:
- void inputItemChanged();
+ void connectSignals();
+ void focusObjectChanged(QObject *focusObject);
private:
QPointer<QWindow> mWindow;
diff --git a/src/plugins/platforms/cocoa/qcocoainputcontext.mm b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
index db3488a0f5..5ac7f72acf 100644
--- a/src/plugins/platforms/cocoa/qcocoainputcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoainputcontext.mm
@@ -83,7 +83,7 @@ QCocoaInputContext::QCocoaInputContext()
: QPlatformInputContext()
, mWindow(QGuiApplication::focusWindow())
{
- connect(qApp->inputMethod(), SIGNAL(inputItemChanged()), this, SLOT(inputItemChanged()));
+ QMetaObject::invokeMethod(this, "connectSignals", Qt::QueuedConnection);
}
QCocoaInputContext::~QCocoaInputContext()
@@ -114,7 +114,13 @@ void QCocoaInputContext::reset()
}
}
-void QCocoaInputContext::inputItemChanged()
+void QCocoaInputContext::connectSignals()
+{
+ connect(qApp, SIGNAL(focusObjectChanged(QObject*)), this, SLOT(focusObjectChanged(QObject*)));
+ focusObjectChanged(qApp->focusObject());
+}
+
+void QCocoaInputContext::focusObjectChanged(QObject *focusObject)
{
mWindow = QGuiApplication::focusWindow();
}
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.h b/src/plugins/platforms/cocoa/qcocoaintegration.h
index 97e7a7ffde..fb3ee3290e 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.h
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.h
@@ -61,6 +61,7 @@ public:
~QCocoaScreen();
QRect geometry() const { return m_geometry; }
+ QRect availableGeometry() const { return m_availableGeometry; }
int depth() const { return m_depth; }
QImage::Format format() const { return m_format; }
QSizeF physicalSize() const { return m_physicalSize; }
@@ -69,6 +70,7 @@ public:
public:
NSScreen *m_screen;
QRect m_geometry;
+ QRect m_availableGeometry;
int m_depth;
QImage::Format m_format;
QSizeF m_physicalSize;
diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm
index f5febd4a16..f91351ad46 100644
--- a/src/plugins/platforms/cocoa/qcocoaintegration.mm
+++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm
@@ -69,8 +69,12 @@ QCocoaScreen::QCocoaScreen(int screenIndex)
:QPlatformScreen()
{
m_screen = [[NSScreen screens] objectAtIndex:screenIndex];
- NSRect rect = [m_screen frame];
- m_geometry = QRect(rect.origin.x,rect.origin.y,rect.size.width,rect.size.height);
+ NSRect frameRect = [m_screen frame];
+ m_geometry = QRect(frameRect.origin.x, frameRect.origin.y, frameRect.size.width, frameRect.size.height);
+ NSRect visibleRect = [m_screen visibleFrame];
+ m_availableGeometry = QRect(visibleRect.origin.x,
+ frameRect.size.height - (visibleRect.origin.y + visibleRect.size.height), // invert y
+ visibleRect.size.width, visibleRect.size.height);
m_format = QImage::Format_RGB32;
diff --git a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
index c2f5df4d38..d02154b006 100644
--- a/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
+++ b/src/plugins/platforms/cocoa/qcocoasystemsettings.mm
@@ -122,24 +122,25 @@ QPalette * qt_mac_createSystemPalette()
palette->setColor(QPalette::Inactive, QPalette::Dark, QColor(191, 191, 191));
// System palette initialization:
- palette->setBrush( QPalette::Active, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushPrimaryHighlightColor) );
- palette->setBrush( QPalette::Inactive, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushSecondaryHighlightColor) );
+ palette->setBrush(QPalette::Active, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushPrimaryHighlightColor));
+ qc = qt_mac_colorForTheme(kThemeBrushSecondaryHighlightColor);
+ palette->setBrush(QPalette::Inactive, QPalette::Highlight, qc);
+ palette->setBrush(QPalette::Disabled, QPalette::Highlight, qc);
- palette->setBrush( QPalette::Disabled, QPalette::Highlight, qt_mac_colorForTheme(kThemeBrushSecondaryHighlightColor) );
- palette->setBrush( QPalette::Active, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonActiveDarkShadow) );
-
- palette->setBrush( QPalette::Inactive, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonInactiveDarkShadow) );
- palette->setBrush( QPalette::Disabled, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonInactiveDarkShadow) );
+ palette->setBrush(QPalette::Active, QPalette::Shadow, qt_mac_colorForTheme(kThemeBrushButtonActiveDarkShadow));
+ qc = qt_mac_colorForTheme(kThemeBrushButtonInactiveDarkShadow);
+ palette->setBrush(QPalette::Inactive, QPalette::Shadow, qc);
+ palette->setBrush(QPalette::Disabled, QPalette::Shadow, qc);
qc = qt_mac_colorForThemeTextColor(kThemeTextColorDialogActive);
palette->setColor(QPalette::Active, QPalette::Text, qc);
palette->setColor(QPalette::Active, QPalette::WindowText, qc);
palette->setColor(QPalette::Active, QPalette::HighlightedText, qc);
-
- qc = qt_mac_colorForThemeTextColor(kThemeTextColorDialogInactive);
palette->setColor(QPalette::Inactive, QPalette::Text, qc);
palette->setColor(QPalette::Inactive, QPalette::WindowText, qc);
palette->setColor(QPalette::Inactive, QPalette::HighlightedText, qc);
+
+ qc = qt_mac_colorForThemeTextColor(kThemeTextColorDialogInactive);
palette->setColor(QPalette::Disabled, QPalette::Text, qc);
palette->setColor(QPalette::Disabled, QPalette::WindowText, qc);
palette->setColor(QPalette::Disabled, QPalette::HighlightedText, qc);
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h
index 8bdb5535d5..90c5a050d0 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.h
+++ b/src/plugins/platforms/cocoa/qcocoawindow.h
@@ -92,6 +92,7 @@ public:
~QCocoaWindow();
void setGeometry(const QRect &rect);
+ void setCocoaGeometry(const QRect &rect);
void setVisible(bool visible);
Qt::WindowFlags setWindowFlags(Qt::WindowFlags flags);
void setWindowTitle(const QString &title);
@@ -110,6 +111,7 @@ public:
void windowDidMove();
void windowDidResize();
void windowWillClose();
+ bool windowIsPopupType() const;
void setCurrentContext(QCocoaGLContext *context);
QCocoaGLContext *currentContext() const;
@@ -117,6 +119,7 @@ public:
protected:
// NSWindow handling. The QCocoaWindow/QNSView can either be displayed
// in an existing NSWindow or in one created by Qt.
+ void recreateWindow(const QPlatformWindow *parentWindow);
NSWindow *createNSWindow();
void setNSWindow(NSWindow *window);
void clearNSWindow(NSWindow *window);
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 5c30e7f38b..b5e8ff2246 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -83,13 +83,19 @@
- (BOOL)canBecomeKeyWindow
{
- return NO;
+ // Most panels can be come the key window. Exceptions are:
+ if (m_cocoaPlatformWindow->window()->windowType() == Qt::ToolTip)
+ return NO;
+ if (m_cocoaPlatformWindow->window()->windowType() == Qt::SplashScreen)
+ return NO;
+ return YES;
}
@end
QCocoaWindow::QCocoaWindow(QWindow *tlw)
: QPlatformWindow(tlw)
+ , m_nsWindow(0)
, m_glContext(0)
, m_inConstructor(true)
{
@@ -98,8 +104,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
m_contentView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
setGeometry(tlw->geometry());
- m_nsWindow = createNSWindow();
- setNSWindow(m_nsWindow);
+ recreateWindow(parent());
m_inConstructor = false;
}
@@ -119,10 +124,18 @@ void QCocoaWindow::setGeometry(const QRect &rect)
qDebug() << "QCocoaWindow::setGeometry" << this << rect;
#endif
QPlatformWindow::setGeometry(rect);
+ setCocoaGeometry(rect);
+}
- NSRect bounds = qt_mac_flipRect(rect, window());
- [m_nsWindow setContentSize : bounds.size];
- [m_nsWindow setFrameOrigin : bounds.origin];
+void QCocoaWindow::setCocoaGeometry(const QRect &rect)
+{
+ if (m_nsWindow) {
+ NSRect bounds = qt_mac_flipRect(rect, window());
+ [m_nsWindow setContentSize : bounds.size];
+ [m_nsWindow setFrameOrigin : bounds.origin];
+ } else {
+ [m_contentView setFrame : NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height())];
+ }
}
void QCocoaWindow::setVisible(bool visible)
@@ -151,13 +164,16 @@ void QCocoaWindow::setVisible(bool visible)
// Make sure the QWindow has a frame ready before we show the NSWindow.
QWindowSystemInterface::handleSynchronousExposeEvent(window(), QRect(QPoint(), geometry().size()));
- if ([m_nsWindow canBecomeKeyWindow])
- [m_nsWindow makeKeyAndOrderFront:nil];
- else
- [m_nsWindow orderFront: nil];
+ if (m_nsWindow) {
+ if ([m_nsWindow canBecomeKeyWindow])
+ [m_nsWindow makeKeyAndOrderFront:nil];
+ else
+ [m_nsWindow orderFront: nil];
+ }
} else {
// qDebug() << "close" << this;
- [m_nsWindow orderOut:m_nsWindow];
+ if (m_nsWindow)
+ [m_nsWindow orderOut:m_nsWindow];
}
}
@@ -170,6 +186,8 @@ Qt::WindowFlags QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
void QCocoaWindow::setWindowTitle(const QString &title)
{
QCocoaAutoReleasePool pool;
+ if (!m_nsWindow)
+ return;
CFStringRef windowTitle = QCFString::toCFStringRef(title);
[m_nsWindow setTitle: const_cast<NSString *>(reinterpret_cast<const NSString *>(windowTitle))];
@@ -180,17 +198,21 @@ void QCocoaWindow::raise()
{
//qDebug() << "raise" << this;
// ### handle spaces (see Qt 4 raise_sys in qwidget_mac.mm)
- [m_nsWindow orderFront: m_nsWindow];
+ if (m_nsWindow)
+ [m_nsWindow orderFront: m_nsWindow];
}
void QCocoaWindow::lower()
{
- [m_nsWindow orderBack: m_nsWindow];
+ if (m_nsWindow)
+ [m_nsWindow orderBack: m_nsWindow];
}
void QCocoaWindow::propagateSizeHints()
{
QCocoaAutoReleasePool pool;
+ if (!m_nsWindow)
+ return;
[m_nsWindow setMinSize : qt_mac_toNSSize(window()->minimumSize())];
[m_nsWindow setMaxSize : qt_mac_toNSSize(window()->maximumSize())];
@@ -213,6 +235,9 @@ void QCocoaWindow::propagateSizeHints()
bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
{
+ if (!m_nsWindow)
+ return false;
+
if (grab && ![m_nsWindow isKeyWindow])
[m_nsWindow makeKeyWindow];
else if (!grab && [m_nsWindow isKeyWindow])
@@ -222,6 +247,9 @@ bool QCocoaWindow::setKeyboardGrabEnabled(bool grab)
bool QCocoaWindow::setMouseGrabEnabled(bool grab)
{
+ if (!m_nsWindow)
+ return false;
+
if (grab && ![m_nsWindow isKeyWindow])
[m_nsWindow makeKeyWindow];
else if (!grab && [m_nsWindow isKeyWindow])
@@ -231,23 +259,19 @@ bool QCocoaWindow::setMouseGrabEnabled(bool grab)
WId QCocoaWindow::winId() const
{
- return WId(m_nsWindow);
+ return WId(m_contentView);
}
-void QCocoaWindow::setParent(const QPlatformWindow *window)
+void QCocoaWindow::setParent(const QPlatformWindow *parentWindow)
{
// recreate the window for compatibility
- clearNSWindow(m_nsWindow);
- [m_nsWindow close];
- [m_nsWindow release];
-
- m_nsWindow = createNSWindow();
- setNSWindow(m_nsWindow);
+ recreateWindow(parentWindow);
+ setCocoaGeometry(geometry());
}
NSView *QCocoaWindow::contentView() const
{
- return [m_nsWindow contentView];
+ return m_contentView;
}
void QCocoaWindow::windowWillMove()
@@ -266,6 +290,9 @@ void QCocoaWindow::windowDidMove()
void QCocoaWindow::windowDidResize()
{
+ if (!m_nsWindow)
+ return;
+
NSRect rect = [[m_nsWindow contentView]frame];
// Call setFrameSize which will trigger a frameDidChangeNotification on QNSView.
[[m_nsWindow contentView] setFrameSize:rect.size];
@@ -276,6 +303,15 @@ void QCocoaWindow::windowWillClose()
QWindowSystemInterface::handleSynchronousCloseEvent(window());
}
+bool QCocoaWindow::windowIsPopupType() const
+{
+ Qt::WindowType type = window()->windowType();
+ if (type == Qt::Tool)
+ return false; // Qt::Tool has the Popup bit set but isn't, at least on Mac.
+
+ return ((type & Qt::Popup) == Qt::Popup);
+}
+
void QCocoaWindow::setCurrentContext(QCocoaGLContext *context)
{
m_glContext = context;
@@ -286,6 +322,27 @@ QCocoaGLContext *QCocoaWindow::currentContext() const
return m_glContext;
}
+void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
+{
+ // Remove current window (if any)
+ if (m_nsWindow) {
+ clearNSWindow(m_nsWindow);
+ [m_nsWindow close];
+ [m_nsWindow release];
+ m_nsWindow = 0;
+ }
+
+ if (!parentWindow) {
+ // Create a new NSWindow if this is a top-level window.
+ m_nsWindow = createNSWindow();
+ setNSWindow(m_nsWindow);
+ } else {
+ // Child windows have no NSWindow, link the NSViews instead.
+ const QCocoaWindow *parentCococaWindow = static_cast<const QCocoaWindow *>(parentWindow);
+ [parentCococaWindow->m_contentView addSubview : m_contentView];
+ }
+}
+
NSWindow * QCocoaWindow::createNSWindow()
{
QCocoaAutoReleasePool pool;
@@ -300,7 +357,7 @@ NSWindow * QCocoaWindow::createNSWindow()
// Use NSPanel for popup-type windows. (Popup, Tool, ToolTip, SplashScreen)
if ((type & Qt::Popup) == Qt::Popup) {
- if (type == Qt::Popup || type == Qt::ToolTip || type == Qt::SplashScreen) {
+ if (windowIsPopupType()) {
styleMask = NSBorderlessWindowMask;
} else {
styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask |
@@ -314,6 +371,7 @@ NSWindow * QCocoaWindow::createNSWindow()
defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up
// before the window is shown and needs a proper window.).
[window setHasShadow:YES];
+ window->m_cocoaPlatformWindow = this;
createdWindow = window;
} else {
styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask);
@@ -324,6 +382,15 @@ NSWindow * QCocoaWindow::createNSWindow()
defer:NO]; // Deferring window creation breaks OpenGL (the GL context is set up
// before the window is shown and needs a proper window.).
window->m_cocoaPlatformWindow = this;
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
+ // All windows with the WindowMaximizeButtonHint set also get a full-screen button.
+ if (flags & Qt::WindowMaximizeButtonHint)
+ [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
+ }
+#endif
+
createdWindow = window;
}
return createdWindow;
@@ -378,6 +445,9 @@ void QCocoaWindow::clearNSWindow(NSWindow *window)
// Returns the current global screen geometry for the nswindow associated with this window.
QRect QCocoaWindow::windowGeometry() const
{
+ if (!m_nsWindow)
+ return geometry();
+
NSRect rect = [m_nsWindow frame];
QPlatformScreen *onScreen = QPlatformScreen::platformScreenForWindow(window());
int flippedY = onScreen->geometry().height() - rect.origin.y - rect.size.height; // account for nswindow inverted y.
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h
index f09c9331f6..2b7caae688 100644
--- a/src/plugins/platforms/cocoa/qnsview.h
+++ b/src/plugins/platforms/cocoa/qnsview.h
@@ -61,6 +61,7 @@ QT_END_NAMESPACE
QString m_composingText;
bool m_keyEventsAccepted;
QStringList *currentCustomDragTypes;
+ Qt::KeyboardModifiers currentWheelModifiers;
}
- (id)init;
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 3a697a3602..d249158db3 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -146,24 +146,24 @@ static QTouchDevice *touchDevice = 0;
- (void)windowDidBecomeKey
{
-// QWindowSystemInterface::handleWindowActivated(m_window);
+ if (!m_platformWindow->windowIsPopupType())
+ QWindowSystemInterface::handleWindowActivated(m_window);
}
- (void)windowDidResignKey
{
-// QWindowSystemInterface::handleWindowActivated(0);
+ if (!m_platformWindow->windowIsPopupType())
+ QWindowSystemInterface::handleWindowActivated(0);
}
- (void)windowDidBecomeMain
{
// qDebug() << "window did become main" << m_window;
- QWindowSystemInterface::handleWindowActivated(m_window);
}
- (void)windowDidResignMain
{
// qDebug() << "window did resign main" << m_window;
- QWindowSystemInterface::handleWindowActivated(0);
}
@@ -304,7 +304,7 @@ static QTouchDevice *touchDevice = 0;
- (void)mouseDragged:(NSEvent *)theEvent
{
if (!(m_buttons & Qt::LeftButton))
- qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ qWarning("QNSView mouseDragged: Internal mouse button tracking invalid (missing Qt::LeftButton)");
[self handleMouseEvent:theEvent];
}
@@ -339,8 +339,8 @@ static QTouchDevice *touchDevice = 0;
- (void)rightMouseDragged:(NSEvent *)theEvent
{
- if (!(m_buttons & Qt::LeftButton))
- qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ if (!(m_buttons & Qt::RightButton))
+ qWarning("QNSView rightMouseDragged: Internal mouse button tracking invalid (missing Qt::RightButton)");
[self handleMouseEvent:theEvent];
}
@@ -404,8 +404,8 @@ static QTouchDevice *touchDevice = 0;
- (void)otherMouseDragged:(NSEvent *)theEvent
{
- if (!(m_buttons & Qt::LeftButton))
- qWarning("Internal Mousebutton tracking invalid(missing Qt::LeftButton");
+ if (!(m_buttons & ~(Qt::LeftButton | Qt::RightButton)))
+ qWarning("QNSView otherMouseDragged: Internal mouse button tracking invalid (missing Qt::MiddleButton or Qt::ExtraButton*)");
[self handleMouseEvent:theEvent];
}
@@ -545,7 +545,31 @@ static QTouchDevice *touchDevice = 0;
NSTimeInterval timestamp = [theEvent timestamp];
ulong qt_timestamp = timestamp * 1000;
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta);
+ // Set keyboard modifiers depending on event phase. A two-finger trackpad flick
+ // generates a stream of scroll events. We want the keyboard modifier state to
+ // be the state at the beginning of the flick in order to avoid changing the
+ // interpretation of the events mid-stream. One example of this happening would
+ // be when pressing cmd after scrolling in Qt Creator: not taking the phase into
+ // account causes the end of the event stream to be interpreted as font size changes.
+
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
+ NSEventPhase phase = [theEvent phase];
+ if (phase == NSEventPhaseBegan) {
+ currentWheelModifiers = [self convertKeyModifiers:[theEvent modifierFlags]];
+ }
+
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta, currentWheelModifiers);
+
+ if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
+ currentWheelModifiers = Qt::NoModifier;
+ }
+ }
+#else
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta,
+ [self convertKeyModifiers:[theEvent modifierFlags]]);
+#endif
+
}
#endif //QT_NO_WHEELEVENT
@@ -590,10 +614,11 @@ static QTouchDevice *touchDevice = 0;
QObject *fo = QGuiApplication::focusObject();
if (!m_keyEventsAccepted && fo) {
- QInputMethodQueryEvent queryEvent(Qt::ImHints);
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImHints);
if (QCoreApplication::sendEvent(fo, &queryEvent)) {
+ bool imEnabled = queryEvent.value(Qt::ImEnabled).toBool();
Qt::InputMethodHints hints = static_cast<Qt::InputMethodHints>(queryEvent.value(Qt::ImHints).toUInt());
- if (!(hints & Qt::ImhDigitsOnly || hints & Qt::ImhFormattedNumbersOnly || hints & Qt::ImhHiddenText))
+ if (imEnabled && !(hints & Qt::ImhDigitsOnly || hints & Qt::ImhFormattedNumbersOnly || hints & Qt::ImhHiddenText))
[self interpretKeyEvents:[NSArray arrayWithObject:nsevent]];
}
}
@@ -630,10 +655,15 @@ static QTouchDevice *touchDevice = 0;
}
QObject *fo = QGuiApplication::focusObject();
if (fo) {
- QInputMethodEvent e;
- e.setCommitString(commitString);
- QCoreApplication::sendEvent(fo, &e);
- m_keyEventsAccepted = true;
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ if (QCoreApplication::sendEvent(fo, &queryEvent)) {
+ if (queryEvent.value(Qt::ImEnabled).toBool()) {
+ QInputMethodEvent e;
+ e.setCommitString(commitString);
+ QCoreApplication::sendEvent(fo, &e);
+ m_keyEventsAccepted = true;
+ }
+ }
}
m_composingText.clear();
@@ -691,9 +721,14 @@ static QTouchDevice *touchDevice = 0;
QObject *fo = QGuiApplication::focusObject();
if (fo) {
- QInputMethodEvent e(preeditString, attrs);
- QCoreApplication::sendEvent(fo, &e);
- m_keyEventsAccepted = true;
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ if (QCoreApplication::sendEvent(fo, &queryEvent)) {
+ if (queryEvent.value(Qt::ImEnabled).toBool()) {
+ QInputMethodEvent e(preeditString, attrs);
+ QCoreApplication::sendEvent(fo, &e);
+ m_keyEventsAccepted = true;
+ }
+ }
}
}
@@ -702,9 +737,14 @@ static QTouchDevice *touchDevice = 0;
if (!m_composingText.isEmpty()) {
QObject *fo = QGuiApplication::focusObject();
if (fo) {
- QInputMethodEvent e;
- e.setCommitString(m_composingText);
- QCoreApplication::sendEvent(fo, &e);
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ if (QCoreApplication::sendEvent(fo, &queryEvent)) {
+ if (queryEvent.value(Qt::ImEnabled).toBool()) {
+ QInputMethodEvent e;
+ e.setCommitString(m_composingText);
+ QCoreApplication::sendEvent(fo, &e);
+ }
+ }
}
}
m_composingText.clear();
@@ -725,9 +765,11 @@ static QTouchDevice *touchDevice = 0;
QObject *fo = QGuiApplication::focusObject();
if (!fo)
return nil;
- QInputMethodQueryEvent queryEvent(Qt::ImCurrentSelection);
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImCurrentSelection);
if (!QCoreApplication::sendEvent(fo, &queryEvent))
return nil;
+ if (!queryEvent.value(Qt::ImEnabled).toBool())
+ return nil;
QString selectedText = queryEvent.value(Qt::ImCurrentSelection).toString();
if (selectedText.isEmpty())
@@ -761,9 +803,12 @@ static QTouchDevice *touchDevice = 0;
QObject *fo = QGuiApplication::focusObject();
if (!fo)
return selRange;
- QInputMethodQueryEvent queryEvent(Qt::ImCurrentSelection);
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled | Qt::ImCurrentSelection);
if (!QCoreApplication::sendEvent(fo, &queryEvent))
return selRange;
+ if (!queryEvent.value(Qt::ImEnabled).toBool())
+ return selRange;
+
QString selectedText = queryEvent.value(Qt::ImCurrentSelection).toString();
if (!selectedText.isEmpty()) {
@@ -780,6 +825,12 @@ static QTouchDevice *touchDevice = 0;
if (!fo)
return NSZeroRect;
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ if (!QCoreApplication::sendEvent(fo, &queryEvent))
+ return NSZeroRect;
+ if (!queryEvent.value(Qt::ImEnabled).toBool())
+ return NSZeroRect;
+
if (!m_window)
return NSZeroRect;
@@ -804,10 +855,19 @@ static QTouchDevice *touchDevice = 0;
- (NSArray*) validAttributesForMarkedText
{
+ if (m_window != QGuiApplication::focusWindow())
+ return nil;
+
QObject *fo = QGuiApplication::focusObject();
if (!fo)
return nil;
+ QInputMethodQueryEvent queryEvent(Qt::ImEnabled);
+ if (!QCoreApplication::sendEvent(fo, &queryEvent))
+ return nil;
+ if (!queryEvent.value(Qt::ImEnabled).toBool())
+ return nil;
+
// Support only underline color/style.
return [NSArray arrayWithObjects:NSUnderlineColorAttributeName,
NSUnderlineStyleAttributeName, nil];
diff --git a/src/plugins/platforms/cocoa/qpaintengine_mac.mm b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
index 8b8445c995..87f3713920 100644
--- a/src/plugins/platforms/cocoa/qpaintengine_mac.mm
+++ b/src/plugins/platforms/cocoa/qpaintengine_mac.mm
@@ -73,8 +73,6 @@
QT_BEGIN_NAMESPACE
-extern int qt_antialiasing_threshold; // from qcoretextfontdatabase.mm
-
/*****************************************************************************
QCoreGraphicsPaintEngine utility functions
*****************************************************************************/
@@ -1182,7 +1180,9 @@ void QCoreGraphicsPaintEngine::drawTextItem(const QPointF &pos, const QTextItem
QFontEngine *fe = ti.fontEngine;
- const bool textAA = state->renderHints() & QPainter::TextAntialiasing && fe->fontDef.pointSize > qt_antialiasing_threshold && !(fe->fontDef.styleStrategy & QFont::NoAntialias);
+ const bool textAA = ((state->renderHints() & QPainter::TextAntialiasing)
+ && (fe->fontDef.pointSize > QCoreTextFontEngine::antialiasingThreshold)
+ && !(fe->fontDef.styleStrategy & QFont::NoAntialias));
const bool lineAA = state->renderHints() & QPainter::Antialiasing;
if (textAA != lineAA)
CGContextSetShouldAntialias(d->hd, textAA);