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/qcocoaglcontext.h4
-rw-r--r--src/plugins/platforms/cocoa/qcocoaglcontext.mm21
-rw-r--r--src/plugins/platforms/cocoa/qcocoatheme.mm13
-rw-r--r--src/plugins/platforms/cocoa/qnsview.mm48
4 files changed, 55 insertions, 31 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h
index b8582022f6..4f80511f61 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.h
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h
@@ -71,10 +71,14 @@ public:
static NSOpenGLPixelFormat *createNSOpenGLPixelFormat(const QSurfaceFormat &format);
NSOpenGLContext *nsOpenGLContext() const;
+ bool isSharing() const;
+ bool isValid() const;
+
private:
void setActiveWindow(QWindow *window);
NSOpenGLContext *m_context;
+ NSOpenGLContext *m_shareContext;
QSurfaceFormat m_format;
QWeakPointer<QWindow> m_currentWindow;
};
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
index 960163d727..637678c19e 100644
--- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm
+++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm
@@ -51,13 +51,19 @@
QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share)
: m_format(format)
{
- QCocoaAutoReleasePool pool; // For the SG Canvas render thread.
+ QCocoaAutoReleasePool pool; // For the SG Canvas render thread
NSOpenGLPixelFormat *pixelFormat = static_cast <NSOpenGLPixelFormat *>(qcgl_createNSOpenGLPixelFormat(format));
- NSOpenGLContext *actualShare = share ? static_cast<QCocoaGLContext *>(share)->m_context : 0;
+ m_shareContext = share ? static_cast<QCocoaGLContext *>(share)->nsOpenGLContext() : nil;
m_context = [NSOpenGLContext alloc];
- [m_context initWithFormat:pixelFormat shareContext:actualShare];
+ [m_context initWithFormat:pixelFormat shareContext:m_shareContext];
+
+ if (!m_context && m_shareContext) {
+ // try without shared context
+ m_shareContext = nil;
+ [m_context initWithFormat:pixelFormat shareContext:nil];
+ }
const GLint interval = 1;
[m_context setValues:&interval forParameter:NSOpenGLCPSwapInterval];
@@ -139,3 +145,12 @@ NSOpenGLContext *QCocoaGLContext::nsOpenGLContext() const
return m_context;
}
+bool QCocoaGLContext::isValid() const
+{
+ return m_context != nil;
+}
+
+bool QCocoaGLContext::isSharing() const
+{
+ return m_shareContext != nil;
+}
diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm
index ad20c2fb27..0fef3234b4 100644
--- a/src/plugins/platforms/cocoa/qcocoatheme.mm
+++ b/src/plugins/platforms/cocoa/qcocoatheme.mm
@@ -105,13 +105,16 @@ QPlatformDialogHelper * QCocoaTheme::createPlatformDialogHelper(DialogType dialo
QVariant QCocoaTheme::themeHint(ThemeHint hint) const
{
switch (hint) {
- case QPlatformTheme::StyleNames:
- return QStringList() << QLatin1Literal("macintosh");
- break;
- default:
- return QPlatformTheme::themeHint(hint);
+ case QPlatformTheme::StyleNames:
+ return QStringList(QStringLiteral("macintosh"));
+ case QPlatformTheme::DialogButtonBoxLayout:
+ return QVariant(1); // QDialogButtonBox::MacLayout
+ case KeyboardScheme:
+ return QVariant(int(MacKeyboardScheme));
+ default:
break;
}
+ return QPlatformTheme::themeHint(hint);
}
QT_END_NAMESPACE
diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm
index 577e0751c6..a43b3fe893 100644
--- a/src/plugins/platforms/cocoa/qnsview.mm
+++ b/src/plugins/platforms/cocoa/qnsview.mm
@@ -371,14 +371,11 @@ static QTouchDevice *touchDevice = 0;
#ifndef QT_NO_WHEELEVENT
- (void)scrollWheel:(NSEvent *)theEvent
{
- int deltaX = 0;
- int deltaY = 0;
- int deltaZ = 0;
-
const EventRef carbonEvent = (EventRef)[theEvent eventRef];
const UInt32 carbonEventKind = carbonEvent ? ::GetEventKind(carbonEvent) : 0;
const bool scrollEvent = carbonEventKind == kEventMouseScroll;
+ QPoint angleDelta;
if (scrollEvent) {
// The mouse device contains pixel scroll wheel support (Mighty Mouse, Trackpad).
// Since deviceDelta is delivered as pixels rather than degrees, we need to
@@ -389,40 +386,45 @@ static QTouchDevice *touchDevice = 0;
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
- deltaX = [theEvent scrollingDeltaX] * pixelsToDegrees;
- deltaY = [theEvent scrollingDeltaY] * pixelsToDegrees;
- // scrollingDeltaZ API is missing.
+ angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees);
+ angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees);
} else
#endif
{
- deltaX = [theEvent deviceDeltaX] * pixelsToDegrees;
- deltaY = [theEvent deviceDeltaY] * pixelsToDegrees;
- deltaZ = [theEvent deviceDeltaZ] * pixelsToDegrees;
+ angleDelta.setX([theEvent deviceDeltaX] * pixelsToDegrees);
+ angleDelta.setY([theEvent deviceDeltaY] * pixelsToDegrees);
}
} else {
// carbonEventKind == kEventMouseWheelMoved
// Remove acceleration, and use either -120 or 120 as delta:
- deltaX = qBound(-120, int([theEvent deltaX] * 10000), 120);
- deltaY = qBound(-120, int([theEvent deltaY] * 10000), 120);
- deltaZ = qBound(-120, int([theEvent deltaZ] * 10000), 120);
+ angleDelta.setX(qBound(-120, int([theEvent deltaX] * 10000), 120));
+ angleDelta.setY(qBound(-120, int([theEvent deltaY] * 10000), 120));
}
+ QPoint pixelDelta;
+#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
+ if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
+ if ([theEvent hasPreciseScrollingDeltas]) {
+ pixelDelta.setX([theEvent scrollingDeltaX]);
+ pixelDelta.setY([theEvent scrollingDeltaY]);
+ } else {
+ // docs: "In the case of !hasPreciseScrollingDeltas, multiply the delta with the line width."
+ // scrollingDeltaX seems to return a minimum value of 0.1 in this case, map that to two pixels.
+ const CGFloat lineWithEstimate = 20.0;
+ pixelDelta.setX([theEvent scrollingDeltaX] * lineWithEstimate);
+ pixelDelta.setY([theEvent scrollingDeltaY] * lineWithEstimate);
+ }
+ }
+#endif
+
+
NSPoint windowPoint = [self convertPoint: [theEvent locationInWindow] fromView: nil];
QPoint qt_windowPoint(windowPoint.x, windowPoint.y);
NSTimeInterval timestamp = [theEvent timestamp];
ulong qt_timestamp = timestamp * 1000;
- if (deltaX != 0)
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaX, Qt::Horizontal);
-
- if (deltaY != 0)
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaY, Qt::Vertical);
-
- if (deltaZ != 0)
- // Qt doesn't explicitly support wheels with a Z component. In a misguided attempt to
- // try to be ahead of the pack, I'm adding this extra value.
- QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, deltaY, (Qt::Orientation)3);
+ QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_windowPoint, pixelDelta, angleDelta);
}
#endif //QT_NO_WHEELEVENT