Cocoa QPA Plugin: Remove code depending depending on OS X 10.6 and older
Snow Leopard is unsupported from 5.4.0. Change-Id: I5c269cbdc93000a4657b63559cc3c526e298e3db Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>
This commit is contained in:
parent
fc11798e8f
commit
a198ce8d8f
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the QtGui module of the Qt Toolkit.
|
** This file is part of the QtGui module of the Qt Toolkit.
|
||||||
@ -106,10 +106,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate);
|
|||||||
mResultSet = false;
|
mResultSet = false;
|
||||||
mClosingDueToKnownButton = false;
|
mClosingDueToKnownButton = false;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
[mColorPanel setRestorable:NO];
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7)
|
|
||||||
[mColorPanel setRestorable:NO];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[[NSNotificationCenter defaultCenter] addObserver:self
|
[[NSNotificationCenter defaultCenter] addObserver:self
|
||||||
selector:@selector(colorChanged:)
|
selector:@selector(colorChanged:)
|
||||||
|
@ -149,11 +149,7 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSFontPanelDelegate);
|
|||||||
mDialogIsExecuting = false;
|
mDialogIsExecuting = false;
|
||||||
mResultSet = false;
|
mResultSet = false;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
[mFontPanel setRestorable:NO];
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7)
|
|
||||||
[mFontPanel setRestorable:NO];
|
|
||||||
#endif
|
|
||||||
|
|
||||||
[mFontPanel setDelegate:self];
|
[mFontPanel setDelegate:self];
|
||||||
[[NSFontManager sharedFontManager] setDelegate:self];
|
[[NSFontManager sharedFontManager] setDelegate:self];
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the plugins of the Qt Toolkit.
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
@ -144,15 +144,8 @@ void QCocoaScreen::updateGeometry()
|
|||||||
|
|
||||||
qreal QCocoaScreen::devicePixelRatio() const
|
qreal QCocoaScreen::devicePixelRatio() const
|
||||||
{
|
{
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
NSScreen * screen = osScreen();
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
return qreal(screen ? [screen backingScaleFactor] : 1.0);
|
||||||
NSScreen * screen = osScreen();
|
|
||||||
return qreal(screen ? [screen backingScaleFactor] : 1.0);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
|
QWindow *QCocoaScreen::topLevelAt(const QPoint &point) const
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the plugins of the Qt Toolkit.
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
@ -79,43 +79,33 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
|
void qt_cocoa_change_implementation(Class baseClass, SEL originalSel, Class proxyClass, SEL replacementSel, SEL backupSel)
|
||||||
{
|
{
|
||||||
#ifndef QT_MAC_USE_COCOA
|
// The following code replaces the _implementation_ for the selector we want to hack
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
|
// (originalSel) with the implementation found in proxyClass. Then it creates
|
||||||
#endif
|
// a new 'backup' method inside baseClass containing the old, original,
|
||||||
{
|
// implementation (fakeSel). You can let the proxy implementation of originalSel
|
||||||
// The following code replaces the _implementation_ for the selector we want to hack
|
// call fakeSel if needed (similar approach to calling a super class implementation).
|
||||||
// (originalSel) with the implementation found in proxyClass. Then it creates
|
// fakeSel must also be implemented in proxyClass, as the signature is used
|
||||||
// a new 'backup' method inside baseClass containing the old, original,
|
// as template for the method one we add into baseClass.
|
||||||
// implementation (fakeSel). You can let the proxy implementation of originalSel
|
// NB: You will typically never create any instances of proxyClass; we use it
|
||||||
// call fakeSel if needed (similar approach to calling a super class implementation).
|
// only for stealing its contents and put it into baseClass.
|
||||||
// fakeSel must also be implemented in proxyClass, as the signature is used
|
if (!replacementSel)
|
||||||
// as template for the method one we add into baseClass.
|
replacementSel = originalSel;
|
||||||
// NB: You will typically never create any instances of proxyClass; we use it
|
|
||||||
// only for stealing its contents and put it into baseClass.
|
|
||||||
if (!replacementSel)
|
|
||||||
replacementSel = originalSel;
|
|
||||||
|
|
||||||
Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
|
Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
|
||||||
Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel);
|
Method replacementMethod = class_getInstanceMethod(proxyClass, replacementSel);
|
||||||
IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod));
|
IMP originalImp = method_setImplementation(originalMethod, method_getImplementation(replacementMethod));
|
||||||
|
|
||||||
if (backupSel) {
|
if (backupSel) {
|
||||||
Method backupMethod = class_getInstanceMethod(proxyClass, backupSel);
|
Method backupMethod = class_getInstanceMethod(proxyClass, backupSel);
|
||||||
class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod));
|
class_addMethod(baseClass, backupSel, originalImp, method_getTypeEncoding(backupMethod));
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)
|
void qt_cocoa_change_back_implementation(Class baseClass, SEL originalSel, SEL backupSel)
|
||||||
{
|
{
|
||||||
#ifndef QT_MAC_USE_COCOA
|
Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5)
|
Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel);
|
||||||
#endif
|
method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass));
|
||||||
{
|
|
||||||
Method originalMethod = class_getInstanceMethod(baseClass, originalSel);
|
|
||||||
Method backupMethodInBaseClass = class_getInstanceMethod(baseClass, backupSel);
|
|
||||||
method_setImplementation(originalMethod, method_getImplementation(backupMethodInBaseClass));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -466,11 +466,7 @@ bool QCocoaPrintDevice::openPpdFile()
|
|||||||
ppdClose(m_ppd);
|
ppdClose(m_ppd);
|
||||||
m_ppd = 0;
|
m_ppd = 0;
|
||||||
CFURLRef ppdURL = NULL;
|
CFURLRef ppdURL = NULL;
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
|
||||||
char ppdPath[PATH_MAX];
|
|
||||||
#else
|
|
||||||
char ppdPath[MAXPATHLEN];
|
char ppdPath[MAXPATHLEN];
|
||||||
#endif
|
|
||||||
if (PMPrinterCopyDescriptionURL(m_printer, kPMPPDDescriptionType, &ppdURL) == noErr
|
if (PMPrinterCopyDescriptionURL(m_printer, kPMPPDDescriptionType, &ppdURL) == noErr
|
||||||
&& ppdURL != NULL
|
&& ppdURL != NULL
|
||||||
&& CFURLGetFileSystemRepresentation(ppdURL, true, (UInt8*)ppdPath, sizeof(ppdPath))) {
|
&& CFURLGetFileSystemRepresentation(ppdURL, true, (UInt8*)ppdPath, sizeof(ppdPath))) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the plugins of the Qt Toolkit.
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
@ -107,26 +107,6 @@ static void selectNextKeyWindow(NSWindow *currentKeyWindow)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@interface NSWindow (CocoaWindowCategory)
|
|
||||||
- (NSRect) legacyConvertRectFromScreen:(NSRect) rect;
|
|
||||||
@end
|
|
||||||
|
|
||||||
@implementation NSWindow (CocoaWindowCategory)
|
|
||||||
- (NSRect) legacyConvertRectFromScreen:(NSRect) rect
|
|
||||||
{
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
|
||||||
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
|
||||||
return [self convertRectFromScreen: rect];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
NSRect r = rect;
|
|
||||||
r.origin = [self convertScreenToBase:rect.origin];
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
@end
|
|
||||||
|
|
||||||
|
|
||||||
@implementation QNSWindowHelper
|
@implementation QNSWindowHelper
|
||||||
|
|
||||||
@synthesize window = _window;
|
@synthesize window = _window;
|
||||||
@ -197,7 +177,7 @@ static void selectNextKeyWindow(NSWindow *currentKeyWindow)
|
|||||||
|
|
||||||
if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
|
if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
|
||||||
NSPoint loc = [theEvent locationInWindow];
|
NSPoint loc = [theEvent locationInWindow];
|
||||||
NSRect windowFrame = [self.window legacyConvertRectFromScreen:[self.window frame]];
|
NSRect windowFrame = [self.window convertRectFromScreen:[self.window frame]];
|
||||||
NSRect contentFrame = [[self.window contentView] frame];
|
NSRect contentFrame = [[self.window contentView] frame];
|
||||||
if (NSMouseInRect(loc, windowFrame, NO) &&
|
if (NSMouseInRect(loc, windowFrame, NO) &&
|
||||||
!NSMouseInRect(loc, contentFrame, NO))
|
!NSMouseInRect(loc, contentFrame, NO))
|
||||||
@ -432,19 +412,16 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
|
|||||||
} else {
|
} else {
|
||||||
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
|
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
|
||||||
m_contentView = m_qtView;
|
m_contentView = m_qtView;
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
|
||||||
// Enable high-dpi OpenGL for retina displays. Enabling has the side
|
// Enable high-dpi OpenGL for retina displays. Enabling has the side
|
||||||
// effect that Cocoa will start calling glViewport(0, 0, width, height),
|
// effect that Cocoa will start calling glViewport(0, 0, width, height),
|
||||||
// overriding any glViewport calls in application code. This is usually not a
|
// overriding any glViewport calls in application code. This is usually not a
|
||||||
// problem, except if the appilcation wants to have a "custom" viewport.
|
// problem, except if the appilcation wants to have a "custom" viewport.
|
||||||
// (like the hellogl example)
|
// (like the hellogl example)
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
|
if (tlw->supportsOpenGL()) {
|
||||||
&& tlw->supportsOpenGL()) {
|
|
||||||
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
|
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
|
||||||
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
|
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
|
||||||
[m_contentView setWantsBestResolutionOpenGLSurface:enable];
|
[m_contentView setWantsBestResolutionOpenGLSurface:enable];
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
|
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
|
||||||
"QT_MAC_WANTS_LAYER");
|
"QT_MAC_WANTS_LAYER");
|
||||||
[m_contentView setWantsLayer:enable];
|
[m_contentView setWantsLayer:enable];
|
||||||
@ -516,7 +493,8 @@ QRect QCocoaWindow::geometry() const
|
|||||||
// of view. Embedded QWindows get global (screen) geometry.
|
// of view. Embedded QWindows get global (screen) geometry.
|
||||||
if (m_contentViewIsEmbedded) {
|
if (m_contentViewIsEmbedded) {
|
||||||
NSPoint windowPoint = [m_contentView convertPoint:NSMakePoint(0, 0) toView:nil];
|
NSPoint windowPoint = [m_contentView convertPoint:NSMakePoint(0, 0) toView:nil];
|
||||||
NSPoint screenPoint = [[m_contentView window] convertBaseToScreen:windowPoint]; // ### use convertRectToScreen after 10.6 removal
|
NSRect screenRect = [[m_contentView window] convertRectToScreen:NSMakeRect(windowPoint.x, windowPoint.y, 1, 1)];
|
||||||
|
NSPoint screenPoint = screenRect.origin;
|
||||||
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
|
QPoint position = qt_mac_flipPoint(screenPoint).toPoint();
|
||||||
QSize size = qt_mac_toQRect([m_contentView bounds]).size();
|
QSize size = qt_mac_toQRect([m_contentView bounds]).size();
|
||||||
return QRect(position, size);
|
return QRect(position, size);
|
||||||
@ -681,11 +659,7 @@ void QCocoaWindow::setVisible(bool visible)
|
|||||||
// Since this isn't a native popup, the window manager doesn't close the popup when you click outside
|
// Since this isn't a native popup, the window manager doesn't close the popup when you click outside
|
||||||
NSUInteger parentStyleMask = [parentCocoaWindow->m_nsWindow styleMask];
|
NSUInteger parentStyleMask = [parentCocoaWindow->m_nsWindow styleMask];
|
||||||
if ((m_resizableTransientParent = (parentStyleMask & NSResizableWindowMask))
|
if ((m_resizableTransientParent = (parentStyleMask & NSResizableWindowMask))
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
&& !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask))
|
||||||
&& QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
|
|
||||||
&& !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
[parentCocoaWindow->m_nsWindow setStyleMask:parentStyleMask & ~NSResizableWindowMask];
|
[parentCocoaWindow->m_nsWindow setStyleMask:parentStyleMask & ~NSResizableWindowMask];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -784,11 +758,7 @@ void QCocoaWindow::setVisible(bool visible)
|
|||||||
if (parentCocoaWindow && window()->type() == Qt::Popup) {
|
if (parentCocoaWindow && window()->type() == Qt::Popup) {
|
||||||
parentCocoaWindow->m_activePopupWindow = 0;
|
parentCocoaWindow->m_activePopupWindow = 0;
|
||||||
if (m_resizableTransientParent
|
if (m_resizableTransientParent
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
&& !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask))
|
||||||
&& QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
|
|
||||||
&& !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)
|
|
||||||
#endif
|
|
||||||
)
|
|
||||||
// QTBUG-30266: a window should not be resizable while a transient popup is open
|
// QTBUG-30266: a window should not be resizable while a transient popup is open
|
||||||
[parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask];
|
[parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask];
|
||||||
}
|
}
|
||||||
@ -903,19 +873,15 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
|
|||||||
setWindowTitle(window()->title());
|
setWindowTitle(window()->title());
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
Qt::WindowType type = window()->type();
|
||||||
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
|
||||||
Qt::WindowType type = window()->type();
|
NSWindowCollectionBehavior behavior = [m_nsWindow collectionBehavior];
|
||||||
if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
|
if (flags & Qt::WindowFullscreenButtonHint)
|
||||||
NSWindowCollectionBehavior behavior = [m_nsWindow collectionBehavior];
|
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
|
||||||
if (flags & Qt::WindowFullscreenButtonHint)
|
else
|
||||||
behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
|
behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
|
||||||
else
|
[m_nsWindow setCollectionBehavior:behavior];
|
||||||
behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
|
|
||||||
[m_nsWindow setCollectionBehavior:behavior];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
setWindowZoomButton(flags);
|
setWindowZoomButton(flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1340,13 +1306,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
|
|||||||
m_nsWindow.hasShadow = NO;
|
m_nsWindow.hasShadow = NO;
|
||||||
m_nsWindow.level = NSNormalWindowLevel;
|
m_nsWindow.level = NSNormalWindowLevel;
|
||||||
NSWindowCollectionBehavior collectionBehavior =
|
NSWindowCollectionBehavior collectionBehavior =
|
||||||
NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorIgnoresCycle;
|
NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorIgnoresCycle
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
| NSWindowCollectionBehaviorFullScreenAuxiliary;
|
||||||
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
m_nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
|
||||||
collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
|
|
||||||
m_nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
m_nsWindow.collectionBehavior = collectionBehavior;
|
m_nsWindow.collectionBehavior = collectionBehavior;
|
||||||
setCocoaGeometry(window()->geometry());
|
setCocoaGeometry(window()->geometry());
|
||||||
|
|
||||||
@ -1440,15 +1402,11 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
|
|||||||
|
|
||||||
[window setHidesOnDeactivate:(type & Qt::Tool) == Qt::Tool];
|
[window setHidesOnDeactivate:(type & Qt::Tool) == Qt::Tool];
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
// Make popup windows show on the same desktop as the parent full-screen window.
|
||||||
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
|
||||||
// Make popup winows show on the same desktop as the parent full-screen window.
|
if ((type & Qt::Popup) == Qt::Popup)
|
||||||
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
|
[window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
|
||||||
|
|
||||||
if ((type & Qt::Popup) == Qt::Popup)
|
|
||||||
[window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
createdWindow = window;
|
createdWindow = window;
|
||||||
} else {
|
} else {
|
||||||
QNSWindow *window;
|
QNSWindow *window;
|
||||||
@ -1458,10 +1416,8 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
|
|||||||
createdWindow = window;
|
createdWindow = window;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
|
||||||
if ([createdWindow respondsToSelector:@selector(setRestorable:)])
|
if ([createdWindow respondsToSelector:@selector(setRestorable:)])
|
||||||
[createdWindow setRestorable: NO];
|
[createdWindow setRestorable: NO];
|
||||||
#endif
|
|
||||||
|
|
||||||
NSInteger level = windowLevel(flags);
|
NSInteger level = windowLevel(flags);
|
||||||
[createdWindow setLevel:level];
|
[createdWindow setLevel:level];
|
||||||
@ -1562,18 +1518,11 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) {
|
if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) {
|
||||||
bool fakeFullScreen = true;
|
if (window()->flags() & Qt::WindowFullscreenButtonHint) {
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
if (m_effectivelyMaximized && m_synchedWindowState == Qt::WindowFullScreen)
|
||||||
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
predictedState = Qt::WindowMaximized;
|
||||||
if (window()->flags() & Qt::WindowFullscreenButtonHint) {
|
[m_nsWindow toggleFullScreen : m_nsWindow];
|
||||||
fakeFullScreen = false;
|
} else {
|
||||||
if (m_effectivelyMaximized && m_synchedWindowState == Qt::WindowFullScreen)
|
|
||||||
predictedState = Qt::WindowMaximized;
|
|
||||||
[m_nsWindow toggleFullScreen : m_nsWindow];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
if (fakeFullScreen) {
|
|
||||||
if (newState & Qt::WindowFullScreen) {
|
if (newState & Qt::WindowFullScreen) {
|
||||||
QScreen *screen = window()->screen();
|
QScreen *screen = window()->screen();
|
||||||
if (screen) {
|
if (screen) {
|
||||||
@ -1747,20 +1696,13 @@ bool QCocoaWindow::testContentBorderAreaPosition(int position) const
|
|||||||
|
|
||||||
qreal QCocoaWindow::devicePixelRatio() const
|
qreal QCocoaWindow::devicePixelRatio() const
|
||||||
{
|
{
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
// The documented way to observe the relationship between device-independent
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
// and device pixels is to use one for the convertToBacking functions. Other
|
||||||
// The documented way to observe the relationship between device-independent
|
// methods such as [NSWindow backingScaleFacor] might not give the correct
|
||||||
// and device pixels is to use one for the convertToBacking functions. Other
|
// result, for example if setWantsBestResolutionOpenGLSurface is not set or
|
||||||
// methods such as [NSWindow backingScaleFacor] might not give the correct
|
// or ignored by the OpenGL driver.
|
||||||
// result, for example if setWantsBestResolutionOpenGLSurface is not set or
|
NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
|
||||||
// or ignored by the OpenGL driver.
|
return backingSize.height;
|
||||||
NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
|
|
||||||
return backingSize.height;
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
return 1.0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns whether the window can be expose, which it can
|
// Returns whether the window can be expose, which it can
|
||||||
|
@ -408,10 +408,6 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
|
|||||||
Qt::WindowState newState = notificationName == NSWindowDidMiniaturizeNotification ?
|
Qt::WindowState newState = notificationName == NSWindowDidMiniaturizeNotification ?
|
||||||
Qt::WindowMinimized : Qt::WindowNoState;
|
Qt::WindowMinimized : Qt::WindowNoState;
|
||||||
[self notifyWindowStateChanged:newState];
|
[self notifyWindowStateChanged:newState];
|
||||||
// NSWindowDidOrderOnScreenAndFinishAnimatingNotification is private API, and not
|
|
||||||
// emitted in 10.6, so we bring back the old behavior for that case alone.
|
|
||||||
if (newState == Qt::WindowNoState && QSysInfo::QSysInfo::MacintoshVersion == QSysInfo::MV_10_6)
|
|
||||||
m_platformWindow->exposeWindow();
|
|
||||||
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) {
|
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOffScreenNotification"]) {
|
||||||
m_platformWindow->obscureWindow();
|
m_platformWindow->obscureWindow();
|
||||||
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
|
} else if ([notificationName isEqualToString: @"NSWindowDidOrderOnScreenAndFinishAnimatingNotification"]) {
|
||||||
@ -442,19 +438,11 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
|
|||||||
m_platformWindow->updateExposedGeometry();
|
m_platformWindow->updateExposedGeometry();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else if (notificationName == NSWindowDidEnterFullScreenNotification
|
||||||
|
|| notificationName == NSWindowDidExitFullScreenNotification) {
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ?
|
||||||
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
|
Qt::WindowFullScreen : Qt::WindowNoState;
|
||||||
if (notificationName == NSWindowDidEnterFullScreenNotification
|
[self notifyWindowStateChanged:newState];
|
||||||
|| notificationName == NSWindowDidExitFullScreenNotification) {
|
|
||||||
Qt::WindowState newState = notificationName == NSWindowDidEnterFullScreenNotification ?
|
|
||||||
Qt::WindowFullScreen : Qt::WindowNoState;
|
|
||||||
[self notifyWindowStateChanged:newState];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -656,16 +644,8 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil;
|
|||||||
|
|
||||||
NSWindow *window = [self window];
|
NSWindow *window = [self window];
|
||||||
NSPoint nsWindowPoint;
|
NSPoint nsWindowPoint;
|
||||||
// Use convertRectToScreen if available (added in 10.7).
|
NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)];
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
nsWindowPoint = windowRect.origin; // NSWindow coordinates
|
||||||
if ([window respondsToSelector:@selector(convertRectFromScreen:)]) {
|
|
||||||
NSRect windowRect = [window convertRectFromScreen:NSMakeRect(mouseLocation.x, mouseLocation.y, 1, 1)];
|
|
||||||
nsWindowPoint = windowRect.origin; // NSWindow coordinates
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
nsWindowPoint = [window convertScreenToBase:mouseLocation]; // NSWindow coordinates
|
|
||||||
}
|
|
||||||
NSPoint nsViewPoint = [self convertPoint: nsWindowPoint fromView: nil]; // NSView/QWindow coordinates
|
NSPoint nsViewPoint = [self convertPoint: nsWindowPoint fromView: nil]; // NSView/QWindow coordinates
|
||||||
*qtWindowPoint = QPointF(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
|
*qtWindowPoint = QPointF(nsViewPoint.x, nsViewPoint.y); // NSView/QWindow coordinates
|
||||||
|
|
||||||
@ -1296,18 +1276,8 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
// It looks like 1/4 degrees per pixel behaves most native.
|
// It looks like 1/4 degrees per pixel behaves most native.
|
||||||
// (NB: Qt expects the unit for delta to be 8 per degree):
|
// (NB: Qt expects the unit for delta to be 8 per degree):
|
||||||
const int pixelsToDegrees = 2; // 8 * 1/4
|
const int pixelsToDegrees = 2; // 8 * 1/4
|
||||||
|
angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees);
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees);
|
||||||
if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
|
|
||||||
angleDelta.setX([theEvent scrollingDeltaX] * pixelsToDegrees);
|
|
||||||
angleDelta.setY([theEvent scrollingDeltaY] * pixelsToDegrees);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
angleDelta.setX([theEvent deviceDeltaX] * pixelsToDegrees);
|
|
||||||
angleDelta.setY([theEvent deviceDeltaY] * pixelsToDegrees);
|
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// carbonEventKind == kEventMouseWheelMoved
|
// carbonEventKind == kEventMouseWheelMoved
|
||||||
// Remove acceleration, and use either -120 or 120 as delta:
|
// Remove acceleration, and use either -120 or 120 as delta:
|
||||||
@ -1316,20 +1286,16 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
}
|
}
|
||||||
|
|
||||||
QPoint pixelDelta;
|
QPoint pixelDelta;
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
if ([theEvent hasPreciseScrollingDeltas]) {
|
||||||
if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
|
pixelDelta.setX([theEvent scrollingDeltaX]);
|
||||||
if ([theEvent hasPreciseScrollingDeltas]) {
|
pixelDelta.setY([theEvent scrollingDeltaY]);
|
||||||
pixelDelta.setX([theEvent scrollingDeltaX]);
|
} else {
|
||||||
pixelDelta.setY([theEvent scrollingDeltaY]);
|
// docs: "In the case of !hasPreciseScrollingDeltas, multiply the delta with the line width."
|
||||||
} else {
|
// scrollingDeltaX seems to return a minimum value of 0.1 in this case, map that to two pixels.
|
||||||
// docs: "In the case of !hasPreciseScrollingDeltas, multiply the delta with the line width."
|
const CGFloat lineWithEstimate = 20.0;
|
||||||
// scrollingDeltaX seems to return a minimum value of 0.1 in this case, map that to two pixels.
|
pixelDelta.setX([theEvent scrollingDeltaX] * lineWithEstimate);
|
||||||
const CGFloat lineWithEstimate = 20.0;
|
pixelDelta.setY([theEvent scrollingDeltaY] * lineWithEstimate);
|
||||||
pixelDelta.setX([theEvent scrollingDeltaX] * lineWithEstimate);
|
|
||||||
pixelDelta.setY([theEvent scrollingDeltaY] * lineWithEstimate);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
QPointF qt_windowPoint;
|
QPointF qt_windowPoint;
|
||||||
QPointF qt_screenPoint;
|
QPointF qt_screenPoint;
|
||||||
@ -1337,44 +1303,36 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent)
|
|||||||
NSTimeInterval timestamp = [theEvent timestamp];
|
NSTimeInterval timestamp = [theEvent timestamp];
|
||||||
ulong qt_timestamp = timestamp * 1000;
|
ulong qt_timestamp = timestamp * 1000;
|
||||||
|
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
|
// Prevent keyboard modifier state from changing during scroll event streams.
|
||||||
if ([theEvent respondsToSelector:@selector(scrollingDeltaX)]) {
|
// A two-finger trackpad flick generates a stream of scroll events. We want
|
||||||
// Prevent keyboard modifier state from changing during scroll event streams.
|
// the keyboard modifier state to be the state at the beginning of the
|
||||||
// A two-finger trackpad flick generates a stream of scroll events. We want
|
// flick in order to avoid changing the interpretation of the events
|
||||||
// the keyboard modifier state to be the state at the beginning of the
|
// mid-stream. One example of this happening would be when pressing cmd
|
||||||
// flick in order to avoid changing the interpretation of the events
|
// after scrolling in Qt Creator: not taking the phase into account causes
|
||||||
// mid-stream. One example of this happening would be when pressing cmd
|
// the end of the event stream to be interpreted as font size changes.
|
||||||
// after scrolling in Qt Creator: not taking the phase into account causes
|
NSEventPhase momentumPhase = [theEvent momentumPhase];
|
||||||
// the end of the event stream to be interpreted as font size changes.
|
if (momentumPhase == NSEventPhaseNone) {
|
||||||
NSEventPhase momentumPhase = [theEvent momentumPhase];
|
currentWheelModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
|
||||||
if (momentumPhase == NSEventPhaseNone) {
|
}
|
||||||
currentWheelModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
|
|
||||||
}
|
|
||||||
|
|
||||||
NSEventPhase phase = [theEvent phase];
|
NSEventPhase phase = [theEvent phase];
|
||||||
Qt::ScrollPhase ph = Qt::ScrollUpdate;
|
Qt::ScrollPhase ph = Qt::ScrollUpdate;
|
||||||
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
|
#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_8
|
||||||
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
|
if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_8) {
|
||||||
// On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin.
|
// On 10.8 and above, MayBegin is likely to happen. We treat it the same as an actual begin.
|
||||||
if (phase == NSEventPhaseMayBegin)
|
if (phase == NSEventPhaseMayBegin)
|
||||||
ph = Qt::ScrollBegin;
|
ph = Qt::ScrollBegin;
|
||||||
} else
|
} else
|
||||||
#endif
|
#endif
|
||||||
if (phase == NSEventPhaseBegan) {
|
if (phase == NSEventPhaseBegan) {
|
||||||
// On 10.7, MayBegin will not happen, so Began is the actual beginning.
|
// On 10.7, MayBegin will not happen, so Began is the actual beginning.
|
||||||
ph = Qt::ScrollBegin;
|
ph = Qt::ScrollBegin;
|
||||||
}
|
}
|
||||||
if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
|
if (phase == NSEventPhaseEnded || phase == NSEventPhaseCancelled) {
|
||||||
ph = Qt::ScrollEnd;
|
ph = Qt::ScrollEnd;
|
||||||
}
|
|
||||||
|
|
||||||
QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta,
|
|
||||||
[QNSView convertKeyModifiers:[theEvent modifierFlags]]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QWindowSystemInterface::handleWheelEvent(m_window, qt_timestamp, qt_windowPoint, qt_screenPoint, pixelDelta, angleDelta, currentWheelModifiers, ph);
|
||||||
}
|
}
|
||||||
#endif //QT_NO_WHEELEVENT
|
#endif //QT_NO_WHEELEVENT
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
**
|
**
|
||||||
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
|
||||||
** Contact: http://www.qt-project.org/legal
|
** Contact: http://www.qt-project.org/legal
|
||||||
**
|
**
|
||||||
** This file is part of the plugins of the Qt Toolkit.
|
** This file is part of the plugins of the Qt Toolkit.
|
||||||
@ -90,20 +90,13 @@ static void qt_mac_clip_cg(CGContextRef hd, const QRegion &rgn, CGAffineTransfor
|
|||||||
if (rgn.isEmpty()) {
|
if (rgn.isEmpty()) {
|
||||||
CGContextAddRect(hd, CGRectMake(0, 0, 0, 0));
|
CGContextAddRect(hd, CGRectMake(0, 0, 0, 0));
|
||||||
} else {
|
} else {
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
|
QVector<QRect> rects = rgn.rects();
|
||||||
QCFType<HIMutableShapeRef> shape = qt_mac_QRegionToHIMutableShape(rgn);
|
const int count = rects.size();
|
||||||
Q_ASSERT(!HIShapeIsEmpty(shape));
|
for (int i = 0; i < count; i++) {
|
||||||
HIShapeReplacePathInCGContext(shape, hd);
|
const QRect &r = rects[i];
|
||||||
} else {
|
CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height());
|
||||||
QVector<QRect> rects = rgn.rects();
|
CGContextAddRect(hd, mac_r);
|
||||||
const int count = rects.size();
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
const QRect &r = rects[i];
|
|
||||||
CGRect mac_r = CGRectMake(r.x(), r.y(), r.width(), r.height());
|
|
||||||
CGContextAddRect(hd, mac_r);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
CGContextClip(hd);
|
CGContextClip(hd);
|
||||||
|
|
||||||
@ -1137,184 +1130,85 @@ extern "C" {
|
|||||||
void
|
void
|
||||||
QCoreGraphicsPaintEngine::updateCompositionMode(QPainter::CompositionMode mode)
|
QCoreGraphicsPaintEngine::updateCompositionMode(QPainter::CompositionMode mode)
|
||||||
{
|
{
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
|
int cg_mode = kCGBlendModeNormal;
|
||||||
int cg_mode = kCGBlendModeNormal;
|
switch (mode) {
|
||||||
switch (mode) {
|
case QPainter::CompositionMode_Multiply:
|
||||||
case QPainter::CompositionMode_Multiply:
|
cg_mode = kCGBlendModeMultiply;
|
||||||
cg_mode = kCGBlendModeMultiply;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Screen:
|
||||||
case QPainter::CompositionMode_Screen:
|
cg_mode = kCGBlendModeScreen;
|
||||||
cg_mode = kCGBlendModeScreen;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Overlay:
|
||||||
case QPainter::CompositionMode_Overlay:
|
cg_mode = kCGBlendModeOverlay;
|
||||||
cg_mode = kCGBlendModeOverlay;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Darken:
|
||||||
case QPainter::CompositionMode_Darken:
|
cg_mode = kCGBlendModeDarken;
|
||||||
cg_mode = kCGBlendModeDarken;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Lighten:
|
||||||
case QPainter::CompositionMode_Lighten:
|
cg_mode = kCGBlendModeLighten;
|
||||||
cg_mode = kCGBlendModeLighten;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_ColorDodge:
|
||||||
case QPainter::CompositionMode_ColorDodge:
|
cg_mode = kCGBlendModeColorDodge;
|
||||||
cg_mode = kCGBlendModeColorDodge;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_ColorBurn:
|
||||||
case QPainter::CompositionMode_ColorBurn:
|
cg_mode = kCGBlendModeColorBurn;
|
||||||
cg_mode = kCGBlendModeColorBurn;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_HardLight:
|
||||||
case QPainter::CompositionMode_HardLight:
|
cg_mode = kCGBlendModeHardLight;
|
||||||
cg_mode = kCGBlendModeHardLight;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_SoftLight:
|
||||||
case QPainter::CompositionMode_SoftLight:
|
cg_mode = kCGBlendModeSoftLight;
|
||||||
cg_mode = kCGBlendModeSoftLight;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Difference:
|
||||||
case QPainter::CompositionMode_Difference:
|
cg_mode = kCGBlendModeDifference;
|
||||||
cg_mode = kCGBlendModeDifference;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Exclusion:
|
||||||
case QPainter::CompositionMode_Exclusion:
|
cg_mode = kCGBlendModeExclusion;
|
||||||
cg_mode = kCGBlendModeExclusion;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Plus:
|
||||||
case QPainter::CompositionMode_Plus:
|
cg_mode = kCGBlendModePlusLighter;
|
||||||
cg_mode = kCGBlendModePlusLighter;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_SourceOver:
|
||||||
case QPainter::CompositionMode_SourceOver:
|
cg_mode = kCGBlendModeNormal;
|
||||||
cg_mode = kCGBlendModeNormal;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_DestinationOver:
|
||||||
case QPainter::CompositionMode_DestinationOver:
|
cg_mode = kCGBlendModeDestinationOver;
|
||||||
cg_mode = kCGBlendModeDestinationOver;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Clear:
|
||||||
case QPainter::CompositionMode_Clear:
|
cg_mode = kCGBlendModeClear;
|
||||||
cg_mode = kCGBlendModeClear;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Source:
|
||||||
case QPainter::CompositionMode_Source:
|
cg_mode = kCGBlendModeCopy;
|
||||||
cg_mode = kCGBlendModeCopy;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Destination:
|
||||||
case QPainter::CompositionMode_Destination:
|
cg_mode = -1;
|
||||||
cg_mode = -1;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_SourceIn:
|
||||||
case QPainter::CompositionMode_SourceIn:
|
cg_mode = kCGBlendModeSourceIn;
|
||||||
cg_mode = kCGBlendModeSourceIn;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_DestinationIn:
|
||||||
case QPainter::CompositionMode_DestinationIn:
|
cg_mode = kCGCompositeModeDestinationIn;
|
||||||
cg_mode = kCGCompositeModeDestinationIn;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_SourceOut:
|
||||||
case QPainter::CompositionMode_SourceOut:
|
cg_mode = kCGBlendModeSourceOut;
|
||||||
cg_mode = kCGBlendModeSourceOut;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_DestinationOut:
|
||||||
case QPainter::CompositionMode_DestinationOut:
|
cg_mode = kCGBlendModeDestinationOver;
|
||||||
cg_mode = kCGBlendModeDestinationOver;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_SourceAtop:
|
||||||
case QPainter::CompositionMode_SourceAtop:
|
cg_mode = kCGBlendModeSourceAtop;
|
||||||
cg_mode = kCGBlendModeSourceAtop;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_DestinationAtop:
|
||||||
case QPainter::CompositionMode_DestinationAtop:
|
cg_mode = kCGBlendModeDestinationAtop;
|
||||||
cg_mode = kCGBlendModeDestinationAtop;
|
break;
|
||||||
break;
|
case QPainter::CompositionMode_Xor:
|
||||||
case QPainter::CompositionMode_Xor:
|
cg_mode = kCGBlendModeXOR;
|
||||||
cg_mode = kCGBlendModeXOR;
|
break;
|
||||||
break;
|
default:
|
||||||
default:
|
break;
|
||||||
break;
|
}
|
||||||
}
|
if (cg_mode > -1) {
|
||||||
if (cg_mode > -1) {
|
CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
|
||||||
CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
|
|
||||||
}
|
|
||||||
} else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_3
|
|
||||||
&& mode <= QPainter::CompositionMode_Xor) {
|
|
||||||
// The standard porter duff ops.
|
|
||||||
int cg_mode = kCGCompositeModeCopy;
|
|
||||||
switch (mode) {
|
|
||||||
case QPainter::CompositionMode_SourceOver:
|
|
||||||
cg_mode = kCGCompositeModeSourceOver;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_DestinationOver:
|
|
||||||
cg_mode = kCGCompositeModeDestinationOver;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Clear:
|
|
||||||
cg_mode = kCGCompositeModeClear;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
qWarning("QCoreGraphicsPaintEngine: Unhandled composition mode %d", (int)mode);
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Source:
|
|
||||||
cg_mode = kCGCompositeModeCopy;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Destination:
|
|
||||||
cg_mode = CGCompositeMode(-1);
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_SourceIn:
|
|
||||||
cg_mode = kCGCompositeModeSourceIn;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_DestinationIn:
|
|
||||||
cg_mode = kCGCompositeModeDestinationIn;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_SourceOut:
|
|
||||||
cg_mode = kCGCompositeModeSourceOut;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_DestinationOut:
|
|
||||||
cg_mode = kCGCompositeModeDestinationOut;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_SourceAtop:
|
|
||||||
cg_mode = kCGCompositeModeSourceAtop;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_DestinationAtop:
|
|
||||||
cg_mode = kCGCompositeModeDestinationAtop;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Xor:
|
|
||||||
cg_mode = kCGCompositeModeXOR;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (cg_mode > -1)
|
|
||||||
CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
|
|
||||||
} else {
|
|
||||||
bool needPrivateAPI = false;
|
|
||||||
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_4) {
|
|
||||||
int cg_mode = kCGBlendModeNormal;
|
|
||||||
switch (mode) {
|
|
||||||
case QPainter::CompositionMode_Multiply:
|
|
||||||
cg_mode = kCGBlendModeMultiply;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Screen:
|
|
||||||
cg_mode = kCGBlendModeScreen;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Overlay:
|
|
||||||
cg_mode = kCGBlendModeOverlay;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Darken:
|
|
||||||
cg_mode = kCGBlendModeDarken;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Lighten:
|
|
||||||
cg_mode = kCGBlendModeLighten;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_ColorDodge:
|
|
||||||
cg_mode = kCGBlendModeColorDodge;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_ColorBurn:
|
|
||||||
cg_mode = kCGBlendModeColorBurn;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_HardLight:
|
|
||||||
cg_mode = kCGBlendModeHardLight;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_SoftLight:
|
|
||||||
cg_mode = kCGBlendModeSoftLight;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Difference:
|
|
||||||
cg_mode = kCGBlendModeDifference;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Exclusion:
|
|
||||||
cg_mode = kCGBlendModeExclusion;
|
|
||||||
break;
|
|
||||||
case QPainter::CompositionMode_Plus:
|
|
||||||
needPrivateAPI = true;
|
|
||||||
cg_mode = kCGCompositeModePlusLighter;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!needPrivateAPI)
|
|
||||||
CGContextSetBlendMode(d_func()->hd, CGBlendMode(cg_mode));
|
|
||||||
else
|
|
||||||
CGContextSetCompositeOperation(d_func()->hd, CGCompositeMode(cg_mode));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1645,8 +1539,6 @@ void QCoreGraphicsPaintEnginePrivate::drawPath(uchar ops, CGMutablePathRef path)
|
|||||||
if (!(q->state->renderHints() & QPainter::Antialiasing)) {
|
if (!(q->state->renderHints() & QPainter::Antialiasing)) {
|
||||||
if (current.pen.style() == Qt::SolidLine || current.pen.width() >= 3)
|
if (current.pen.style() == Qt::SolidLine || current.pen.width() >= 3)
|
||||||
CGContextTranslateCTM(hd, double(pixelSize.x()) * 0.25, double(pixelSize.y()) * 0.25);
|
CGContextTranslateCTM(hd, double(pixelSize.x()) * 0.25, double(pixelSize.y()) * 0.25);
|
||||||
else if (current.pen.style() == Qt::DotLine && QSysInfo::MacintoshVersion == QSysInfo::MV_10_3)
|
|
||||||
; // Do nothing.
|
|
||||||
else
|
else
|
||||||
CGContextTranslateCTM(hd, 0, double(pixelSize.y()) * 0.1);
|
CGContextTranslateCTM(hd, 0, double(pixelSize.y()) * 0.1);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user