summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/cocoa/qcocoawindow.mm
diff options
context:
space:
mode:
authorGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2014-10-17 15:16:12 +0200
committerGabriel de Dietrich <gabriel.dedietrich@theqtcompany.com>2014-10-27 15:30:38 +0100
commita198ce8d8fe9b418d631d033d481ec38f0373fa4 (patch)
tree55713362a0e0ea27a786b879cd9ee5a22472ec88 /src/plugins/platforms/cocoa/qcocoawindow.mm
parentfc11798e8f5997dd350a9baf39e9a3124b04fdd1 (diff)
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>
Diffstat (limited to 'src/plugins/platforms/cocoa/qcocoawindow.mm')
-rw-r--r--src/plugins/platforms/cocoa/qcocoawindow.mm126
1 files changed, 34 insertions, 92 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm
index 60c772702c..ad6390788a 100644
--- a/src/plugins/platforms/cocoa/qcocoawindow.mm
+++ b/src/plugins/platforms/cocoa/qcocoawindow.mm
@@ -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
**
** 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
@synthesize window = _window;
@@ -197,7 +177,7 @@ static void selectNextKeyWindow(NSWindow *currentKeyWindow)
if (pw && pw->frameStrutEventsEnabled() && isMouseEvent(theEvent)) {
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];
if (NSMouseInRect(loc, windowFrame, NO) &&
!NSMouseInRect(loc, contentFrame, NO))
@@ -432,19 +412,16 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw)
} else {
m_qtView = [[QNSView alloc] initWithQWindow:tlw platformWindow:this];
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
// effect that Cocoa will start calling glViewport(0, 0, width, height),
// overriding any glViewport calls in application code. This is usually not a
// problem, except if the appilcation wants to have a "custom" viewport.
// (like the hellogl example)
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
- && tlw->supportsOpenGL()) {
+ if (tlw->supportsOpenGL()) {
BOOL enable = qt_mac_resolveOption(YES, tlw, "_q_mac_wantsBestResolutionOpenGLSurface",
"QT_MAC_WANTS_BEST_RESOLUTION_OPENGL_SURFACE");
[m_contentView setWantsBestResolutionOpenGLSurface:enable];
}
-#endif
BOOL enable = qt_mac_resolveOption(NO, tlw, "_q_mac_wantsLayer",
"QT_MAC_WANTS_LAYER");
[m_contentView setWantsLayer:enable];
@@ -516,7 +493,8 @@ QRect QCocoaWindow::geometry() const
// of view. Embedded QWindows get global (screen) geometry.
if (m_contentViewIsEmbedded) {
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();
QSize size = qt_mac_toQRect([m_contentView bounds]).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
NSUInteger parentStyleMask = [parentCocoaWindow->m_nsWindow styleMask];
if ((m_resizableTransientParent = (parentStyleMask & NSResizableWindowMask))
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
- && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)
-#endif
- )
+ && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask))
[parentCocoaWindow->m_nsWindow setStyleMask:parentStyleMask & ~NSResizableWindowMask];
}
@@ -784,11 +758,7 @@ void QCocoaWindow::setVisible(bool visible)
if (parentCocoaWindow && window()->type() == Qt::Popup) {
parentCocoaWindow->m_activePopupWindow = 0;
if (m_resizableTransientParent
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- && QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7
- && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask)
-#endif
- )
+ && !([parentCocoaWindow->m_nsWindow styleMask] & NSFullScreenWindowMask))
// QTBUG-30266: a window should not be resizable while a transient popup is open
[parentCocoaWindow->m_nsWindow setStyleMask:[parentCocoaWindow->m_nsWindow styleMask] | NSResizableWindowMask];
}
@@ -903,19 +873,15 @@ void QCocoaWindow::setWindowFlags(Qt::WindowFlags flags)
setWindowTitle(window()->title());
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- Qt::WindowType type = window()->type();
- if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
- NSWindowCollectionBehavior behavior = [m_nsWindow collectionBehavior];
- if (flags & Qt::WindowFullscreenButtonHint)
- behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
- else
- behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
- [m_nsWindow setCollectionBehavior:behavior];
- }
+ Qt::WindowType type = window()->type();
+ if ((type & Qt::Popup) != Qt::Popup && (type & Qt::Dialog) != Qt::Dialog) {
+ NSWindowCollectionBehavior behavior = [m_nsWindow collectionBehavior];
+ if (flags & Qt::WindowFullscreenButtonHint)
+ behavior |= NSWindowCollectionBehaviorFullScreenPrimary;
+ else
+ behavior &= ~NSWindowCollectionBehaviorFullScreenPrimary;
+ [m_nsWindow setCollectionBehavior:behavior];
}
-#endif
setWindowZoomButton(flags);
}
@@ -1340,13 +1306,9 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow)
m_nsWindow.hasShadow = NO;
m_nsWindow.level = NSNormalWindowLevel;
NSWindowCollectionBehavior collectionBehavior =
- NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorIgnoresCycle;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- collectionBehavior |= NSWindowCollectionBehaviorFullScreenAuxiliary;
- m_nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
- }
-#endif
+ NSWindowCollectionBehaviorManaged | NSWindowCollectionBehaviorIgnoresCycle
+ | NSWindowCollectionBehaviorFullScreenAuxiliary;
+ m_nsWindow.animationBehavior = NSWindowAnimationBehaviorNone;
m_nsWindow.collectionBehavior = collectionBehavior;
setCocoaGeometry(window()->geometry());
@@ -1440,15 +1402,11 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
[window setHidesOnDeactivate:(type & Qt::Tool) == Qt::Tool];
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- // Make popup winows show on the same desktop as the parent full-screen window.
- [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+ // Make popup windows show on the same desktop as the parent full-screen window.
+ [window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenAuxiliary];
+ if ((type & Qt::Popup) == Qt::Popup)
+ [window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
- if ((type & Qt::Popup) == Qt::Popup)
- [window setAnimationBehavior:NSWindowAnimationBehaviorUtilityWindow];
- }
-#endif
createdWindow = window;
} else {
QNSWindow *window;
@@ -1458,10 +1416,8 @@ QCocoaNSWindow * QCocoaWindow::createNSWindow()
createdWindow = window;
}
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
if ([createdWindow respondsToSelector:@selector(setRestorable:)])
[createdWindow setRestorable: NO];
-#endif
NSInteger level = windowLevel(flags);
[createdWindow setLevel:level];
@@ -1562,18 +1518,11 @@ void QCocoaWindow::syncWindowState(Qt::WindowState newState)
}
if ((m_synchedWindowState & Qt::WindowFullScreen) != (newState & Qt::WindowFullScreen)) {
- bool fakeFullScreen = true;
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- if (window()->flags() & Qt::WindowFullscreenButtonHint) {
- fakeFullScreen = false;
- if (m_effectivelyMaximized && m_synchedWindowState == Qt::WindowFullScreen)
- predictedState = Qt::WindowMaximized;
- [m_nsWindow toggleFullScreen : m_nsWindow];
- }
- }
-#endif
- if (fakeFullScreen) {
+ if (window()->flags() & Qt::WindowFullscreenButtonHint) {
+ if (m_effectivelyMaximized && m_synchedWindowState == Qt::WindowFullScreen)
+ predictedState = Qt::WindowMaximized;
+ [m_nsWindow toggleFullScreen : m_nsWindow];
+ } else {
if (newState & Qt::WindowFullScreen) {
QScreen *screen = window()->screen();
if (screen) {
@@ -1747,20 +1696,13 @@ bool QCocoaWindow::testContentBorderAreaPosition(int position) const
qreal QCocoaWindow::devicePixelRatio() const
{
-#if MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_7
- if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_7) {
- // The documented way to observe the relationship between device-independent
- // and device pixels is to use one for the convertToBacking functions. Other
- // methods such as [NSWindow backingScaleFacor] might not give the correct
- // result, for example if setWantsBestResolutionOpenGLSurface is not set or
- // or ignored by the OpenGL driver.
- NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
- return backingSize.height;
- } else
-#endif
- {
- return 1.0;
- }
+ // The documented way to observe the relationship between device-independent
+ // and device pixels is to use one for the convertToBacking functions. Other
+ // methods such as [NSWindow backingScaleFacor] might not give the correct
+ // result, for example if setWantsBestResolutionOpenGLSurface is not set or
+ // or ignored by the OpenGL driver.
+ NSSize backingSize = [m_contentView convertSizeToBacking:NSMakeSize(1.0, 1.0)];
+ return backingSize.height;
}
// Returns whether the window can be expose, which it can