diff options
Diffstat (limited to 'src/plugins/platforms/cocoa')
22 files changed, 361 insertions, 153 deletions
diff --git a/src/plugins/platforms/cocoa/images/sizeallcursor.png b/src/plugins/platforms/cocoa/images/sizeallcursor.png Binary files differnew file mode 100644 index 0000000000..bb5381ba32 --- /dev/null +++ b/src/plugins/platforms/cocoa/images/sizeallcursor.png diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm index e135f36e78..1371eb3658 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibility.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibility.mm @@ -40,8 +40,7 @@ ****************************************************************************/ #include "qcocoaaccessibility.h" #include "qcocoaaccessibilityelement.h" -#include <qaccessible.h> -#include <QtGui/private/qaccessible2_p.h> +#include <QtGui/qaccessible.h> #include <private/qcore_mac_p.h> QCocoaAccessibility::QCocoaAccessibility() @@ -56,12 +55,8 @@ QCocoaAccessibility::~QCocoaAccessibility() void QCocoaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) { - QObject *object = event->object(); - if (!object) - return; - - QAccessibleInterface *interface = event->accessibleInterface(); - if (!interface) + QAccessible::Id interfaceId = event->uniqueId(); + if (!interfaceId) return; switch (event->type()) { @@ -69,7 +64,7 @@ void QCocoaAccessibility::notifyAccessibilityUpdate(QAccessibleEvent *event) case QAccessible::TextInserted : case QAccessible::TextRemoved : case QAccessible::TextUpdated : { - QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithId : QAccessible::uniqueId(interface) parent : nil]; + QCocoaAccessibleElement *element = [QCocoaAccessibleElement createElementWithId : interfaceId parent : nil]; [element autorelease]; NSAccessibilityPostNotification(element, NSAccessibilityValueChangedNotification); break; } diff --git a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm index 7eae22f720..8e20a96a48 100644 --- a/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm +++ b/src/plugins/platforms/cocoa/qcocoaaccessibilityelement.mm @@ -42,8 +42,7 @@ #include "qcocoaaccessibility.h" #include "qcocoahelpers.h" -#include <QAccessible> -#include <QtGui/private/qaccessible2_p.h> +#include <QtGui/qaccessible.h> #import <AppKit/NSAccessibility.h> diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm index c293f4cd52..551a59823c 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm @@ -115,8 +115,8 @@ QT_USE_NAMESPACE QCocoaPostMessageArgs *args = reinterpret_cast<QCocoaPostMessageArgs *>(lower | (upper << 32)); // Special case for convenience: if the argument is an NSNumber, we unbox it directly. // Use NSValue instead if this behaviour is unwanted. - id a1 = ([args->arg1 isKindOfClass:[NSNumber class]]) ? (id)[args->arg1 intValue] : args->arg1; - id a2 = ([args->arg2 isKindOfClass:[NSNumber class]]) ? (id)[args->arg2 intValue] : args->arg2; + id a1 = ([args->arg1 isKindOfClass:[NSNumber class]]) ? (id)[args->arg1 longValue] : args->arg1; + id a2 = ([args->arg2 isKindOfClass:[NSNumber class]]) ? (id)[args->arg2 longValue] : args->arg2; switch (args->argCount) { case 0: [args->target performSelector:args->selector]; diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index d90d77ec1d..be2bab8ce7 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -82,6 +82,7 @@ static NSButton *macCreateButton(const char *text, NSView *superview) BOOL mDialogIsExecuting; BOOL mResultSet; }; +- (void)restoreOriginalContentView; - (void)relayout; - (void)updateQtColor; - (void)finishOffWithCode:(NSInteger)code; diff --git a/src/plugins/platforms/cocoa/qcocoacursor.h b/src/plugins/platforms/cocoa/qcocoacursor.h index dfa1fcff81..f332240724 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.h +++ b/src/plugins/platforms/cocoa/qcocoacursor.h @@ -55,12 +55,13 @@ public: QCocoaCursor(); ~QCocoaCursor(); - virtual void changeCursor(QCursor * widgetCursor, QWindow * widget); + virtual void changeCursor(QCursor *cursor, QWindow *window); virtual QPoint pos() const; virtual void setPos(const QPoint &position); private: QHash<Qt::CursorShape, NSCursor *> m_cursors; - NSCursor *createCursorData(QCursor *); + NSCursor *convertCursor(QCursor *cursor); + NSCursor *createCursorData(QCursor * cursor); NSCursor *createCursorFromBitmap(const QBitmap *bitmap, const QBitmap *mask, const QPoint hotspot = QPoint()); NSCursor *createCursorFromPixmap(const QPixmap pixmap, const QPoint hotspot = QPoint()); }; diff --git a/src/plugins/platforms/cocoa/qcocoacursor.mm b/src/plugins/platforms/cocoa/qcocoacursor.mm index e5b41e7a88..13f6423701 100644 --- a/src/plugins/platforms/cocoa/qcocoacursor.mm +++ b/src/plugins/platforms/cocoa/qcocoacursor.mm @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qcocoacursor.h" +#include "qcocoawindow.h" #include "qcocoahelpers.h" #include "qcocoaautoreleasepool.h" @@ -63,82 +64,90 @@ QCocoaCursor::~QCocoaCursor() void QCocoaCursor::changeCursor(QCursor *cursor, QWindow *window) { - Q_UNUSED(window); + NSCursor * cocoaCursor = convertCursor(cursor); + if (QPlatformWindow * platformWindow = window->handle()) + static_cast<QCocoaWindow *>(platformWindow)->setWindowCursor(cocoaCursor); +} + +QPoint QCocoaCursor::pos() const +{ + return qt_mac_flipPoint([NSEvent mouseLocation]).toPoint(); +} + +void QCocoaCursor::setPos(const QPoint &position) +{ + CGPoint pos; + pos.x = position.x(); + pos.y = position.y(); + + CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0); + CGEventPost(kCGHIDEventTap, e); + CFRelease(e); +} + +NSCursor *QCocoaCursor::convertCursor(QCursor * cursor) +{ const Qt::CursorShape newShape = cursor ? cursor->shape() : Qt::ArrowCursor; + NSCursor *cocoaCursor; + // Check for a suitable built-in NSCursor first: switch (newShape) { case Qt::ArrowCursor: - [[NSCursor arrowCursor] set]; + cocoaCursor= [NSCursor arrowCursor]; break; case Qt::CrossCursor: - [[NSCursor crosshairCursor] set]; + cocoaCursor = [NSCursor crosshairCursor]; break; case Qt::IBeamCursor: - [[NSCursor IBeamCursor] set]; + cocoaCursor = [NSCursor IBeamCursor]; break; case Qt::WhatsThisCursor: //for now just use the pointing hand case Qt::PointingHandCursor: - [[NSCursor pointingHandCursor] set]; + cocoaCursor = [NSCursor pointingHandCursor]; break; case Qt::SplitVCursor: - [[NSCursor resizeUpDownCursor] set]; + cocoaCursor = [NSCursor resizeUpDownCursor]; break; case Qt::SplitHCursor: - [[NSCursor resizeLeftRightCursor] set]; + cocoaCursor = [NSCursor resizeLeftRightCursor]; break; case Qt::OpenHandCursor: - [[NSCursor openHandCursor] set]; + cocoaCursor = [NSCursor openHandCursor]; break; case Qt::ClosedHandCursor: - [[NSCursor closedHandCursor] set]; + cocoaCursor = [NSCursor closedHandCursor]; break; case Qt::DragMoveCursor: - [[NSCursor crosshairCursor] set]; + cocoaCursor = [NSCursor crosshairCursor]; break; case Qt::DragCopyCursor: - [[NSCursor crosshairCursor] set]; + cocoaCursor = [NSCursor crosshairCursor]; break; case Qt::DragLinkCursor: - [[NSCursor dragLinkCursor] set]; + cocoaCursor = [NSCursor dragLinkCursor]; break; default : { // No suitable OS cursor exist, use cursors provided // by Qt for the rest. Check for a cached cursor: - NSCursor *cocoaCursor = m_cursors.value(newShape); + cocoaCursor = m_cursors.value(newShape); if (cocoaCursor && cursor->shape() == Qt::BitmapCursor) { [cocoaCursor release]; cocoaCursor = 0; } if (cocoaCursor == 0) { cocoaCursor = createCursorData(cursor); - if (cocoaCursor == 0) { - [[NSCursor arrowCursor] set]; - return; - } + if (cocoaCursor == 0) + return [NSCursor arrowCursor]; + m_cursors.insert(newShape, cocoaCursor); } - [cocoaCursor set]; break; } } + return cocoaCursor; } -QPoint QCocoaCursor::pos() const -{ - return qt_mac_flipPoint([NSEvent mouseLocation]).toPoint(); -} - -void QCocoaCursor::setPos(const QPoint &position) -{ - CGPoint pos; - pos.x = position.x(); - pos.y = position.y(); - - CGEventRef e = CGEventCreateMouseEvent(0, kCGEventMouseMoved, pos, 0); - CGEventPost(kCGHIDEventTap, e); - CFRelease(e); -} // Creates an NSCursor for the given QCursor. NSCursor *QCocoaCursor::createCursorData(QCursor *cursor) @@ -218,8 +227,8 @@ NSCursor *QCocoaCursor::createCursorData(QCursor *cursor) return createCursorFromPixmap(pixmap, hotspot); break; } case Qt::SizeAllCursor: { - QPixmap pixmap = QPixmap(QLatin1String(":/qt-project.org/mac/cursors/images/pluscursor.png")); - return createCursorFromPixmap(pixmap, hotspot); + QPixmap pixmap = QPixmap(QLatin1String(":/qt-project.org/mac/cursors/images/sizeallcursor.png")); + return createCursorFromPixmap(pixmap, QPoint(8, 8)); break; } case Qt::BusyCursor: { QPixmap pixmap = QPixmap(QLatin1String(":/qt-project.org/mac/cursors/images/waitcursor.png")); diff --git a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm index b3bc4a8ebf..1ad833ee44 100644 --- a/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafiledialoghelper.mm @@ -61,12 +61,12 @@ #include <stdlib.h> #include <qabstracteventdispatcher.h> #include "qcocoaautoreleasepool.h" -#include <QFileSystemWatcher> #include <QDir> #include <qpa/qplatformnativeinterface.h> #import <AppKit/NSSavePanel.h> +#import <CoreFoundation/CFNumber.h> QT_FORWARD_DECLARE_CLASS(QString) QT_FORWARD_DECLARE_CLASS(QStringList) @@ -74,30 +74,6 @@ QT_FORWARD_DECLARE_CLASS(QFileInfo) QT_FORWARD_DECLARE_CLASS(QWindow) QT_USE_NAMESPACE -class CachedEntries: public QObject { -public: - CachedEntries(QDir::Filters filters) : mFilters(filters) { - QObject::connect(&mFSWatcher, &QFileSystemWatcher::directoryChanged, this, &CachedEntries::updateDirCache); - } - QString directory() const { - const QStringList &dirs = mFSWatcher.directories(); - return (dirs.count() ? dirs[0] : QString()); - } - QStringList entries() const { - return mQDirFilterEntryList; - } - void updateDirCache(const QString &path) { - mFSWatcher.removePaths(mFSWatcher.directories()); - mFSWatcher.addPath(path); - mQDirFilterEntryList = QDir(path).entryList(mFilters); - } - -private: - QFileSystemWatcher mFSWatcher; - QStringList mQDirFilterEntryList; - QDir::Filters mFilters; -}; - typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions; @class QT_MANGLE_NAMESPACE(QNSOpenSavePanelDelegate); @@ -117,7 +93,6 @@ typedef QSharedPointer<QFileDialogOptions> SharedPointerFileDialogOptions; int mReturnCode; SharedPointerFileDialogOptions mOptions; - CachedEntries *mCachedEntries; QString *mCurrentSelection; QStringList *mNameFilterDropDownList; QStringList *mSelectedNameFilter; @@ -164,7 +139,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate); [mSavePanel setDelegate:self]; mReturnCode = -1; mHelper = helper; - mCachedEntries = new CachedEntries(mOptions->filter()); mNameFilterDropDownList = new QStringList(mOptions->nameFilters()); QString selectedVisualNameFilter = mOptions->initiallySelectedNameFilter(); mSelectedNameFilter = new QStringList([self findStrippedFilterWithVisualFilterName:selectedVisualNameFilter]); @@ -197,7 +171,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSOpenSavePanelDelegate); - (void)dealloc { - delete mCachedEntries; delete mNameFilterDropDownList; delete mSelectedNameFilter; delete mCurrentSelection; @@ -308,6 +281,22 @@ static QString strippedText(QString s) }]; } +- (BOOL)isHiddenFile:(NSString *)filename isDir:(BOOL)isDir +{ + CFURLRef url = CFURLCreateWithFileSystemPath(kCFAllocatorDefault, (CFStringRef)filename, kCFURLPOSIXPathStyle, isDir); + CFBooleanRef isHidden; + Boolean errorOrHidden = false; + if (!CFURLCopyResourcePropertyForKey(url, kCFURLIsHiddenKey, &isHidden, NULL)) { + errorOrHidden = true; + } else { + if (CFBooleanGetValue(isHidden)) + errorOrHidden = true; + CFRelease(isHidden); + } + CFRelease(url); + return errorOrHidden; +} + - (BOOL)panel:(id)sender shouldShowFilename:(NSString *)filename { Q_UNUSED(sender); @@ -316,8 +305,13 @@ static QString strippedText(QString s) return NO; // Always accept directories regardless of their names (unless it is a bundle): - BOOL isDir; - if ([[NSFileManager defaultManager] fileExistsAtPath:filename isDirectory:&isDir] && isDir) { + NSFileManager *fm = [NSFileManager defaultManager]; + NSDictionary *fileAttrs = [fm attributesOfItemAtPath:filename error:nil]; + if (!fileAttrs) + return NO; // Error accessing the file means 'no'. + NSString *fileType = [fileAttrs fileType]; + bool isDir = [fileType isEqualToString:NSFileTypeDirectory]; + if (isDir) { if ([mSavePanel treatsFilePackagesAsDirectories] == NO) { if ([[NSWorkspace sharedWorkspace] isFilePackageAtPath:filename] == NO) return YES; @@ -325,24 +319,35 @@ static QString strippedText(QString s) } QString qtFileName = QCFString::toQString(filename); - QFileInfo info(qtFileName.normalized(QString::NormalizationForm_C)); - QString path = info.absolutePath(); - if (mCachedEntries->directory() != path) { - mCachedEntries->updateDirCache(path); - } - // Check if the QDir filter accepts the file: - if (!mCachedEntries->entries().contains(info.fileName())) - return NO; - // No filter means accept everything - if (mSelectedNameFilter->isEmpty()) - return YES; + bool nameMatches = mSelectedNameFilter->isEmpty(); // Check if the current file name filter accepts the file: - for (int i=0; i<mSelectedNameFilter->size(); ++i) { + for (int i = 0; !nameMatches && i < mSelectedNameFilter->size(); ++i) { if (QDir::match(mSelectedNameFilter->at(i), qtFileName)) - return YES; + nameMatches = true; + } + if (!nameMatches) + return NO; + + QDir::Filters filter = mOptions->filter(); + if ((!(filter & (QDir::Dirs | QDir::AllDirs)) && isDir) + || (!(filter & QDir::Files) && [fileType isEqualToString:NSFileTypeRegular]) + || ((filter & QDir::NoSymLinks) && [fileType isEqualToString:NSFileTypeSymbolicLink])) + return NO; + + bool filterPermissions = ((filter & QDir::PermissionMask) + && (filter & QDir::PermissionMask) != QDir::PermissionMask); + if (filterPermissions) { + if ((!(filter & QDir::Readable) && [fm isReadableFileAtPath:filename]) + || (!(filter & QDir::Writable) && [fm isWritableFileAtPath:filename]) + || (!(filter & QDir::Executable) && [fm isExecutableFileAtPath:filename])) + return NO; } - return NO; + if (!(filter & QDir::Hidden) + && (qtFileName.startsWith(QLatin1Char('.')) || [self isHiddenFile:filename isDir:isDir])) + return NO; + + return YES; } - (NSString *)panel:(id)sender userEnteredFilename:(NSString *)filename confirmed:(BOOL)okFlag @@ -461,7 +466,7 @@ static QString strippedText(QString s) Q_UNUSED(sender); if (!mHelper) return; - if ([path isEqualToString:mCurrentDir]) + if (!(path && path.length) || [path isEqualToString:mCurrentDir]) return; [mCurrentDir release]; diff --git a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm index 91fb52eb6d..dc22da0983 100644 --- a/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoafontdialoghelper.mm @@ -121,6 +121,7 @@ static QFont qfontForCocoaFont(NSFont *cocoaFont, const QFont &resolveFont) BOOL mDialogIsExecuting; BOOL mResultSet; }; +- (void)restoreOriginalContentView; - (void)relayout; - (void)relayoutToContentSize:(NSSize)frameSize; - (void)updateQtFont; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.h b/src/plugins/platforms/cocoa/qcocoaglcontext.h index 29affb0e4a..e1d4b602c9 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.h +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.h @@ -77,6 +77,7 @@ public: private: void setActiveWindow(QWindow *window); + void updateSurfaceFormat(); NSOpenGLContext *m_context; NSOpenGLContext *m_shareContext; diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 3dee137038..144144338f 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -48,6 +48,74 @@ #import <Cocoa/Cocoa.h> +static inline QByteArray getGlString(GLenum param) +{ + if (const GLubyte *s = glGetString(param)) + return QByteArray(reinterpret_cast<const char*>(s)); + return QByteArray(); +} + +#if !defined(GL_CONTEXT_FLAGS) +#define GL_CONTEXT_FLAGS 0x821E +#endif + +#if !defined(GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT) +#define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x0001 +#endif + +#if !defined(GL_CONTEXT_PROFILE_MASK) +#define GL_CONTEXT_PROFILE_MASK 0x9126 +#endif + +#if !defined(GL_CONTEXT_CORE_PROFILE_BIT) +#define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 +#endif + +#if !defined(GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) +#define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 +#endif + +static void updateFormatFromContext(QSurfaceFormat *format) +{ + Q_ASSERT(format); + + // Update the version, profile, and context bit of the format + int major = 0, minor = 0; + QByteArray versionString(getGlString(GL_VERSION)); + if (QPlatformOpenGLContext::parseOpenGLVersion(versionString, major, minor)) { + format->setMajorVersion(major); + format->setMinorVersion(minor); + } + + format->setProfile(QSurfaceFormat::NoProfile); + + Q_ASSERT(format->renderableType() == QSurfaceFormat::OpenGL); + if (format->version() < qMakePair(3, 0)) { + format->setOption(QSurfaceFormat::DeprecatedFunctions); + return; + } + + // Version 3.0 onwards - check if it includes deprecated functionality + GLint value = 0; + glGetIntegerv(GL_CONTEXT_FLAGS, &value); + if (!(value & GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT)) + format->setOption(QSurfaceFormat::DeprecatedFunctions); + + // Debug context option not supported on OS X + + if (format->version() < qMakePair(3, 2)) + return; + + // Version 3.2 and newer have a profile + value = 0; + glGetIntegerv(GL_CONTEXT_PROFILE_MASK, &value); + + if (value & GL_CONTEXT_CORE_PROFILE_BIT) + format->setProfile(QSurfaceFormat::CoreProfile); + else if (value & GL_CONTEXT_COMPATIBILITY_PROFILE_BIT) + format->setProfile(QSurfaceFormat::CompatibilityProfile); +} + QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLContext *share) : m_context(nil), m_shareContext(nil), @@ -82,6 +150,8 @@ QCocoaGLContext::QCocoaGLContext(const QSurfaceFormat &format, QPlatformOpenGLCo int zeroOpacity = 0; [m_context setValues:&zeroOpacity forParameter:NSOpenGLCPSurfaceOpacity]; } + + updateSurfaceFormat(); } QCocoaGLContext::~QCocoaGLContext() @@ -112,6 +182,8 @@ bool QCocoaGLContext::makeCurrent(QPlatformSurface *surface) QWindow *window = static_cast<QCocoaWindow *>(surface)->window(); setActiveWindow(window); + if (![m_context view]) + return false; [m_context makeCurrentContext]; update(); return true; @@ -135,6 +207,74 @@ void QCocoaGLContext::setActiveWindow(QWindow *window) [(QNSView *) cocoaWindow->contentView() setQCocoaGLContext:this]; } +void QCocoaGLContext::updateSurfaceFormat() +{ + // At present it is impossible to turn an option off on a QSurfaceFormat (see + // https://codereview.qt-project.org/#change,70599). So we have to populate + // the actual surface format from scratch + QSurfaceFormat requestedFormat = m_format; + m_format = QSurfaceFormat(); + m_format.setRenderableType(QSurfaceFormat::OpenGL); + + // CoreGL doesn't require a drawable to make the context current + CGLContextObj oldContext = CGLGetCurrentContext(); + CGLContextObj ctx = static_cast<CGLContextObj>([m_context CGLContextObj]); + CGLSetCurrentContext(ctx); + + // Get the data that OpenGL provides + updateFormatFromContext(&m_format); + + // Get the data contained within the pixel format + CGLPixelFormatObj cglPixelFormat = static_cast<CGLPixelFormatObj>(CGLGetPixelFormat(ctx)); + NSOpenGLPixelFormat *pixelFormat = [[NSOpenGLPixelFormat alloc] initWithCGLPixelFormatObj:cglPixelFormat]; + + int colorSize = -1; + [pixelFormat getValues:&colorSize forAttribute:NSOpenGLPFAColorSize forVirtualScreen:0]; + if (colorSize > 0) { + // This seems to return the total color buffer depth, including alpha + m_format.setRedBufferSize(colorSize / 4); + m_format.setGreenBufferSize(colorSize / 4); + m_format.setBlueBufferSize(colorSize / 4); + } + + // The pixel format always seems to return 8 for alpha. However, the framebuffer only + // seems to have alpha enabled if we requested it explicitly. I can't find any other + // attribute to check explicitly for this so we use our best guess for alpha. + int alphaSize = -1; + [pixelFormat getValues:&alphaSize forAttribute:NSOpenGLPFAAlphaSize forVirtualScreen:0]; + if (alphaSize > 0 && requestedFormat.alphaBufferSize() > 0) + m_format.setAlphaBufferSize(alphaSize); + + int depthSize = -1; + [pixelFormat getValues:&depthSize forAttribute:NSOpenGLPFADepthSize forVirtualScreen:0]; + if (depthSize > 0) + m_format.setDepthBufferSize(depthSize); + + int stencilSize = -1; + [pixelFormat getValues:&stencilSize forAttribute:NSOpenGLPFAStencilSize forVirtualScreen:0]; + if (stencilSize > 0) + m_format.setStencilBufferSize(stencilSize); + + int samples = -1; + [pixelFormat getValues:&samples forAttribute:NSOpenGLPFASamples forVirtualScreen:0]; + if (samples > 0) + m_format.setSamples(samples); + + int doubleBuffered = -1; + [pixelFormat getValues:&doubleBuffered forAttribute:NSOpenGLPFADoubleBuffer forVirtualScreen:0]; + m_format.setSwapBehavior(doubleBuffered == 1 ? QSurfaceFormat::DoubleBuffer : QSurfaceFormat::SingleBuffer); + + int steroBuffers = -1; + [pixelFormat getValues:&steroBuffers forAttribute:NSOpenGLPFAStereo forVirtualScreen:0]; + if (steroBuffers == 1) + m_format.setOption(QSurfaceFormat::StereoBuffers); + + [pixelFormat release]; + + // Restore the original context + CGLSetCurrentContext(oldContext); +} + void QCocoaGLContext::doneCurrent() { if (m_currentWindow && m_currentWindow.data()->handle()) diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 197a2058af..4a5696b35e 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -599,7 +599,17 @@ NSRect qt_mac_flipRect(const QRect &rect, QWindow *window) { QPlatformScreen *onScreen = QPlatformScreen::platformScreenForWindow(window); int flippedY = onScreen->geometry().height() - (rect.y() + rect.height()); - + QList<QScreen *> screens = QGuiApplication::screens(); + if (screens.size() > 1) { + int height = 0; + foreach (QScreen *scr, screens) + height = qMax(height, scr->size().height()); + int difference = height - onScreen->geometry().height(); + if (difference > 0) + flippedY += difference; + else + flippedY -= difference; + } // In case of automatic positioning, try to put as much of the window onscreen as possible. if (window->isTopLevel() && qt_window_private(const_cast<QWindow*>(window))->positionAutomatic && flippedY < 0) flippedY = onScreen->geometry().height() - onScreen->availableGeometry().height() - onScreen->availableGeometry().y(); diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 2e42b9acda..0af635be6f 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -63,7 +63,6 @@ static void initResources() { - Q_INIT_RESOURCE_EXTERN(qcocoaresources) Q_INIT_RESOURCE(qcocoaresources); } diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index 14b8dee101..329c7a264a 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -84,6 +84,7 @@ static inline QCocoaMenuLoader *getMenuLoader() } - (id) initWithMenu:(QCocoaMenu*) m; +- (BOOL)hasShortcut:(NSMenu *)menu forKey:(NSString *)key forModifiers:(NSUInteger)modifier; @end @@ -465,17 +466,21 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf nsPos.y = screen->availableVirtualSize().height() - nsPos.y; } - // Finally, we need to synthesize an event. - NSEvent *menuEvent = [NSEvent mouseEventWithType:NSRightMouseDown - location:nsPos - modifierFlags:0 - timestamp:0 - windowNumber:view ? view.window.windowNumber : 0 - context:nil - eventNumber:0 - clickCount:1 - pressure:1.0]; - [NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view]; + if (view) { + // Finally, we need to synthesize an event. + NSEvent *menuEvent = [NSEvent mouseEventWithType:NSRightMouseDown + location:nsPos + modifierFlags:0 + timestamp:0 + windowNumber:view ? view.window.windowNumber : 0 + context:nil + eventNumber:0 + clickCount:1 + pressure:1.0]; + [NSMenu popUpContextMenu:m_nativeMenu withEvent:menuEvent forView:view]; + } else { + [m_nativeMenu popUpMenuPositioningItem:nsItem atLocation:nsPos inView:0]; + } } // The calls above block, and also swallow any mouse release event, diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 0fea55ac68..5a8664747e 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -175,6 +175,7 @@ void QCocoaMenuBar::handleReparent(QWindow *newParentWindow) if (newParentWindow == NULL) { m_window = NULL; } else { + newParentWindow->create(); m_window = static_cast<QCocoaWindow*>(newParentWindow->handle()); m_window->setMenubar(this); } diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 013f9931ff..3bba1ee1d5 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -338,6 +338,8 @@ QString QCocoaMenuItem::mergeText() return qt_mac_applicationmenu_string(4); } else if (m_native == [loader quitMenuItem]) { return qt_mac_applicationmenu_string(5).arg(qt_mac_applicationName()); + } else if (m_text.contains('\t')) { + return m_text.left(m_text.indexOf('\t')); } return m_text; } @@ -349,6 +351,8 @@ QKeySequence QCocoaMenuItem::mergeAccel() return QKeySequence(QKeySequence::Preferences); else if (m_native == [loader quitMenuItem]) return QKeySequence(QKeySequence::Quit); + else if (m_text.contains('\t')) + return QKeySequence(m_text.mid(m_text.indexOf('\t') + 1), QKeySequence::NativeText); return m_shortcut; } diff --git a/src/plugins/platforms/cocoa/qcocoaresources.qrc b/src/plugins/platforms/cocoa/qcocoaresources.qrc index 392300bb03..9e0640db7d 100644 --- a/src/plugins/platforms/cocoa/qcocoaresources.qrc +++ b/src/plugins/platforms/cocoa/qcocoaresources.qrc @@ -4,7 +4,7 @@ <file>images/forbiddencursor.png</file> <file>images/spincursor.png</file> <file>images/waitcursor.png</file> -<file>images/pluscursor.png</file> +<file>images/sizeallcursor.png</file> </qresource> <qresource prefix="/qt-project.org/mac/style"> <file>images/leopard-unified-toolbar-on.png</file> diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 7f0f07e912..4f5a208f43 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -154,6 +154,8 @@ public: void setMenubar(QCocoaMenuBar *mb); QCocoaMenuBar *menubar() const; + void setWindowCursor(NSCursor *cursor); + void registerTouch(bool enable); qreal devicePixelRatio() const; @@ -190,11 +192,13 @@ public: // for QNSView Qt::WindowState m_synchedWindowState; Qt::WindowModality m_windowModality; QPointer<QWindow> m_activePopupWindow; - QPointer<QWindow> m_underMouseWindow; + QPointer<QWindow> m_enterLeaveTargetWindow; + bool m_windowUnderMouse; bool m_inConstructor; QCocoaGLContext *m_glContext; QCocoaMenuBar *m_menubar; + NSCursor *m_windowCursor; bool m_hasModalSession; bool m_frameStrutEventsEnabled; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 845cc1202f..4da47f4f1f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -206,9 +206,11 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_nsWindowDelegate(0) , m_synchedWindowState(Qt::WindowActive) , m_windowModality(Qt::NonModal) + , m_windowUnderMouse(false) , m_inConstructor(true) , m_glContext(0) , m_menubar(0) + , m_windowCursor(0) , m_hasModalSession(false) , m_frameStrutEventsEnabled(false) , m_isExposed(false) @@ -463,19 +465,19 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags) { Qt::WindowType type = static_cast<Qt::WindowType>(int(flags & Qt::WindowType_Mask)); NSInteger styleMask = NSBorderlessWindowMask; + if (flags & Qt::FramelessWindowHint) + return styleMask; if ((type & Qt::Popup) == Qt::Popup) { - if (!windowIsPopupType(type) && !(flags & Qt::FramelessWindowHint)) + if (!windowIsPopupType(type)) styleMask = (NSUtilityWindowMask | NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask); } else { - // Filter flags for supported properties - flags &= Qt::WindowType_Mask | Qt::FramelessWindowHint | Qt::WindowTitleHint | - Qt::WindowMinMaxButtonsHint | Qt::WindowCloseButtonHint | Qt::CustomizeWindowHint; - if (flags == Qt::Window) { + if (type == Qt::Window && !(flags & Qt::CustomizeWindowHint)) { styleMask = (NSResizableWindowMask | NSClosableWindowMask | NSMiniaturizableWindowMask | NSTitledWindowMask); - } else if ((flags & Qt::Dialog) == Qt::Dialog) { + } else if (type == Qt::Dialog) { if (flags & Qt::CustomizeWindowHint) { - styleMask = NSResizableWindowMask; + if (flags & Qt::WindowMaximizeButtonHint) + styleMask = NSResizableWindowMask; if (flags & Qt::WindowTitleHint) styleMask |= NSTitledWindowMask; if (flags & Qt::WindowCloseButtonHint) @@ -485,8 +487,8 @@ NSUInteger QCocoaWindow::windowStyleMask(Qt::WindowFlags flags) } else { styleMask = NSResizableWindowMask | NSClosableWindowMask | NSTitledWindowMask; } - } else if (!(flags & Qt::FramelessWindowHint)) { - if ((flags & Qt::Dialog) || (flags & Qt::WindowMaximizeButtonHint)) + } else { + if (flags & Qt::WindowMaximizeButtonHint) styleMask |= NSResizableWindowMask; if (flags & Qt::WindowTitleHint) styleMask |= NSTitledWindowMask; @@ -711,7 +713,10 @@ WId QCocoaWindow::winId() const void QCocoaWindow::setParent(const QPlatformWindow *parentWindow) { // recreate the window for compatibility + bool unhideAfterRecreate = parentWindow && !m_contentViewIsToBeEmbedded && ![m_contentView isHidden]; recreateWindow(parentWindow); + if (unhideAfterRecreate) + [m_contentView setHidden:NO]; setCocoaGeometry(geometry()); } @@ -1030,6 +1035,23 @@ QCocoaMenuBar *QCocoaWindow::menubar() const return m_menubar; } +void QCocoaWindow::setWindowCursor(NSCursor *cursor) +{ + // This function is called (via QCocoaCursor) by Qt to set + // the cursor for this window. It can be called for a window + // that is not currenly under the mouse pointer (for example + // for a popup window.) Qt expects the set cursor to "stick": + // it should be accociated with the window until a different + // cursor is set. + + // Cocoa has different abstractions. We can set the cursor *now*: + if (m_windowUnderMouse) + [cursor set]; + // or we can set the cursor on mouse enter/leave using tracking + // areas. This is done in QNSView, save the cursor: + m_windowCursor = cursor; +} + void QCocoaWindow::registerTouch(bool enable) { m_registerTouchCount += enable ? 1 : -1; diff --git a/src/plugins/platforms/cocoa/qmacclipboard.mm b/src/plugins/platforms/cocoa/qmacclipboard.mm index 95143fd8ea..b5c50d676f 100644 --- a/src/plugins/platforms/cocoa/qmacclipboard.mm +++ b/src/plugins/platforms/cocoa/qmacclipboard.mm @@ -105,7 +105,8 @@ QMacPasteboard::~QMacPasteboard() for (int i = 0; i < promises.count(); ++i) { const Promise &promise = promises.at(i); QCFString flavor = QCFString(promise.convertor->flavorFor(promise.mime)); - promiseKeeper(paste, (PasteboardItemID)promise.itemId, flavor, this); + NSInteger pbItemId = promise.itemId; + promiseKeeper(paste, reinterpret_cast<PasteboardItemID>(pbItemId), flavor, this); } if (paste) @@ -311,9 +312,9 @@ QMacPasteboard::setMimeData(QMimeData *mime_src) int numItems = c->count(mime_src); for (int item = 0; item < numItems; ++item) { - const int itemID = item+1; //id starts at 1 + const NSInteger itemID = item+1; //id starts at 1 promises.append(QMacPasteboard::Promise(itemID, c, mimeType, mimeData, item)); - PasteboardPutItemFlavor(paste, (PasteboardItemID)itemID, QCFString(flavor), 0, kPasteboardFlavorNoFlags); + PasteboardPutItemFlavor(paste, reinterpret_cast<PasteboardItemID>(itemID), QCFString(flavor), 0, kPasteboardFlavorNoFlags); #ifdef DEBUG_PASTEBOARD qDebug(" - adding %d %s [%s] <%s> [%d]", itemID, qPrintable(mimeType), qPrintable(flavor), qPrintable(c->convertorName()), item); diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index f90fc6b205..71c4de3b69 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -496,7 +496,7 @@ static QTouchDevice *touchDevice = 0; return YES; } -- (void)convertFromEvent:(NSEvent *)event toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint +- (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint { // Calculate the mouse position in the QWindow and Qt screen coordinate system, // starting from coordinates in the NSWindow coordinate system. @@ -516,23 +516,22 @@ static QTouchDevice *touchDevice = 0; // NSView and QWindow are equal coordinate systems: the QWindow covers the // entire NSView, and we've set the NSView's isFlipped property to true. - NSPoint nsWindowPoint = [event locationInWindow]; // NSWindow coordinates - - NSPoint nsViewPoint = [self convertPoint: nsWindowPoint fromView: nil]; // NSView/QWindow coordinates - *qtWindowPoint = QPointF(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates - NSWindow *window = [self window]; + NSPoint nsWindowPoint; // Use convertRectToScreen if available (added in 10.7). #if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7 - if ([window respondsToSelector:@selector(convertRectToScreen:)]) { - NSRect screenRect = [window convertRectToScreen : NSMakeRect(nsWindowPoint.x, nsWindowPoint.y, 0, 0)]; // OS X screen coordinates - *qtScreenPoint = QPointF(screenRect.origin.x, qt_mac_flipYCoordinate(screenRect.origin.y)); // Qt screen coordinates + if ([window respondsToSelector:@selector(convertRectFromScreen:)]) { + NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)]; + nsWindowPoint = windowRect.origin; // NSWindow coordinates } else #endif { - NSPoint screenPoint = [window convertBaseToScreen : NSMakePoint(nsWindowPoint.x, nsWindowPoint.y)]; - *qtScreenPoint = QPointF(screenPoint.x, qt_mac_flipYCoordinate(screenPoint.y)); + nsWindowPoint = [window convertScreenToBase:mouseLocation]; // NSWindow coordinates } + NSPoint nsViewPoint = [self convertPoint: nsWindowPoint fromView: nil]; // NSView/QWindow coordinates + *qtWindowPoint = QPointF(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates + + *qtScreenPoint = QPointF(mouseLocation.x, qt_mac_flipYCoordinate(mouseLocation.y)); // Qt screen coordinates } - (void)resetMouseButtons @@ -546,7 +545,7 @@ static QTouchDevice *touchDevice = 0; QPointF qtWindowPoint; QPointF qtScreenPoint; - [self convertFromEvent:theEvent toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&qtWindowPoint andScreenPoint:&qtScreenPoint]; ulong timestamp = [theEvent timestamp] * 1000; QCocoaDrag* nativeDrag = static_cast<QCocoaDrag *>(QGuiApplicationPrivate::platformIntegration()->drag()); @@ -672,7 +671,7 @@ static QTouchDevice *touchDevice = 0; // mouse moves delivered to it (Apple recommends keeping it OFF because there // is a performance hit). So it goes. NSUInteger trackingOptions = NSTrackingMouseEnteredAndExited | NSTrackingActiveInActiveApp - | NSTrackingInVisibleRect | NSTrackingMouseMoved; + | NSTrackingInVisibleRect | NSTrackingMouseMoved | NSTrackingCursorUpdate; NSTrackingArea *ta = [[[NSTrackingArea alloc] initWithRect:[self frame] options:trackingOptions owner:self @@ -681,6 +680,13 @@ static QTouchDevice *touchDevice = 0; [self addTrackingArea:ta]; } +-(void)cursorUpdate:(NSEvent *)theEvent +{ + Q_UNUSED(theEvent) + if (m_platformWindow->m_windowCursor) + [m_platformWindow->m_windowCursor set]; +} + - (void)mouseMoved:(NSEvent *)theEvent { if (m_window->flags() & Qt::WindowTransparentForInput) @@ -688,7 +694,7 @@ static QTouchDevice *touchDevice = 0; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:theEvent toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; QWindow *childWindow = m_platformWindow->childWindowAt(windowPoint.toPoint()); // Top-level windows generate enter-leave events for sub-windows. @@ -697,9 +703,9 @@ static QTouchDevice *touchDevice = 0; // handling mouseEnter and mouseLeave envents, since they are sent // individually to different views. if (m_platformWindow->m_nsWindow && childWindow) { - if (childWindow != m_platformWindow->m_underMouseWindow) { - QWindowSystemInterface::handleEnterLeaveEvent(childWindow, m_platformWindow->m_underMouseWindow, windowPoint, screenPoint); - m_platformWindow->m_underMouseWindow = childWindow; + if (childWindow != m_platformWindow->m_enterLeaveTargetWindow) { + QWindowSystemInterface::handleEnterLeaveEvent(childWindow, m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint); + m_platformWindow->m_enterLeaveTargetWindow = childWindow; } } @@ -713,6 +719,8 @@ static QTouchDevice *touchDevice = 0; - (void)mouseEntered:(NSEvent *)theEvent { + m_platformWindow->m_windowUnderMouse = true; + if (m_window->flags() & Qt::WindowTransparentForInput) return [super mouseEntered:theEvent]; @@ -722,13 +730,15 @@ static QTouchDevice *touchDevice = 0; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:theEvent toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; - m_platformWindow->m_underMouseWindow = m_platformWindow->childWindowAt(windowPoint.toPoint()); - QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_underMouseWindow, windowPoint, screenPoint); + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + m_platformWindow->m_enterLeaveTargetWindow = m_platformWindow->childWindowAt(windowPoint.toPoint()); + QWindowSystemInterface::handleEnterEvent(m_platformWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint); } - (void)mouseExited:(NSEvent *)theEvent { + m_platformWindow->m_windowUnderMouse = false; + if (m_window->flags() & Qt::WindowTransparentForInput) return [super mouseExited:theEvent]; Q_UNUSED(theEvent); @@ -737,8 +747,8 @@ static QTouchDevice *touchDevice = 0; if (!m_platformWindow->m_nsWindow) return; - QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_underMouseWindow); - m_platformWindow->m_underMouseWindow = 0; + QWindowSystemInterface::handleLeaveEvent(m_platformWindow->m_enterLeaveTargetWindow); + m_platformWindow->m_enterLeaveTargetWindow = 0; } - (void)rightMouseDown:(NSEvent *)theEvent @@ -812,7 +822,7 @@ Q_GLOBAL_STATIC(QCocoaTabletDeviceDataHash, tabletDeviceDataHash) QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent: theEvent toWindowPoint: &windowPoint andScreenPoint: &screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint: &windowPoint andScreenPoint: &screenPoint]; uint deviceId = [theEvent deviceID]; if (!tabletDeviceDataHash->contains(deviceId)) { @@ -985,7 +995,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:event toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::ZoomNativeGesture, [event magnification], windowPoint, screenPoint); } @@ -1000,7 +1010,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:event toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::SmartZoomNativeGesture, zoomIn ? 1.0f : 0.0f, windowPoint, screenPoint); zoomIn = !zoomIn; @@ -1015,7 +1025,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:event toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; QWindowSystemInterface::handleGestureEventWithRealValue(m_window, timestamp, Qt::RotateNativeGesture, -[event rotation], windowPoint, screenPoint); } @@ -1028,7 +1038,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:event toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; qreal angle = 0.0f; if ([event deltaX] == 1) @@ -1052,7 +1062,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:event toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::BeginNativeGesture, windowPoint, screenPoint); } @@ -1065,7 +1075,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) const NSTimeInterval timestamp = [event timestamp]; QPointF windowPoint; QPointF screenPoint; - [self convertFromEvent:event toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; QWindowSystemInterface::handleGestureEvent(m_window, timestamp, Qt::EndNativeGesture, windowPoint, screenPoint); } @@ -1125,7 +1135,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) QPointF qt_windowPoint; QPointF qt_screenPoint; - [self convertFromEvent:theEvent toWindowPoint:&qt_windowPoint andScreenPoint:&qt_screenPoint]; + [self convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&qt_windowPoint andScreenPoint:&qt_screenPoint]; NSTimeInterval timestamp = [theEvent timestamp]; ulong qt_timestamp = timestamp * 1000; diff --git a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm index 86e5066fbb..e8f26aa8c4 100644 --- a/src/plugins/platforms/cocoa/qnsviewaccessibility.mm +++ b/src/plugins/platforms/cocoa/qnsviewaccessibility.mm @@ -47,7 +47,7 @@ #include "qcocoaaccessibilityelement.h" #include <qpa/qplatformintegration.h> -#include <QtGui/private/qaccessible2_p.h> +#include <QtGui/qaccessible.h> #include <QtCore/QDebug> #import <AppKit/NSAccessibility.h> |