diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-12-05 17:42:33 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2013-12-05 17:42:33 +0100 |
commit | 733ace5a7ad5b9e9f93ac87667d7d37fa5f894d5 (patch) | |
tree | a88031a8e1ac30986567070728e29ed1366d0962 /src/plugins/platforms | |
parent | eaff48d3622bbb0e18e79f79aac6d1ac1b7e2760 (diff) | |
parent | 835b8213905b315645bc60ff5f2ab99340d075a2 (diff) |
Merge remote-tracking branch 'origin/release' into stable
Conflicts:
configure
mkspecs/macx-ios-clang/features/default_post.prf
tests/auto/widgets/widgets/qmenu/tst_qmenu.cpp
Change-Id: Iaba97eed2272bccf54289640b8197d40e22f7bf5
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoaglcontext.mm | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.h | 4 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 42 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 6 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindowdelegate.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnswindowdelegate.mm | 11 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qioseventdispatcher.mm | 7 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosglobal.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosglobal.mm | 7 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosinputcontext.mm | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosintegration.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiosviewcontroller.mm | 9 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qioswindow.mm | 24 |
15 files changed, 91 insertions, 31 deletions
diff --git a/src/plugins/platforms/cocoa/qcocoaglcontext.mm b/src/plugins/platforms/cocoa/qcocoaglcontext.mm index 777d4a871b..8f74a71b1e 100644 --- a/src/plugins/platforms/cocoa/qcocoaglcontext.mm +++ b/src/plugins/platforms/cocoa/qcocoaglcontext.mm @@ -192,8 +192,6 @@ 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; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.h b/src/plugins/platforms/cocoa/qcocoawindow.h index 4f5a208f43..c7ec315f04 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.h +++ b/src/plugins/platforms/cocoa/qcocoawindow.h @@ -159,8 +159,10 @@ public: void registerTouch(bool enable); qreal devicePixelRatio() const; + bool isWindowExposable(); void exposeWindow(); void obscureWindow(); + void updateExposedGeometry(); QWindow *childWindowAt(QPoint windowPoint); protected: // NSWindow handling. The QCocoaWindow/QNSView can either be displayed @@ -202,7 +204,9 @@ public: // for QNSView bool m_hasModalSession; bool m_frameStrutEventsEnabled; + bool m_geometryUpdateExposeAllowed; bool m_isExposed; + QRect m_exposedGeometry; int m_registerTouchCount; bool m_resizableTransientParent; bool m_overrideBecomeKey; diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 1aace958ed..a2ef43db67 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -213,6 +213,7 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw) , m_windowCursor(0) , m_hasModalSession(false) , m_frameStrutEventsEnabled(false) + , m_geometryUpdateExposeAllowed(false) , m_isExposed(false) , m_registerTouchCount(0) , m_resizableTransientParent(false) @@ -1084,22 +1085,61 @@ qreal QCocoaWindow::devicePixelRatio() const } } +// Returns whether the window can be expose, which it can +// if it is on screen and has a valid geometry. +bool QCocoaWindow::isWindowExposable() +{ + QSize size = geometry().size(); + bool validGeometry = (size.width() > 0 && size.height() > 0); + bool validScreen = ([[m_contentView window] screen] != 0); + bool nonHiddenSuperView = ![[m_contentView superview] isHidden]; + return (validGeometry && validScreen && nonHiddenSuperView); +} + +// Exposes the window by posting an expose event to QWindowSystemInterface void QCocoaWindow::exposeWindow() { - if (!m_isExposed && ![[m_contentView superview] isHidden]) { + m_geometryUpdateExposeAllowed = true; + + if (!isWindowExposable()) + return; + + if (!m_isExposed) { m_isExposed = true; + m_exposedGeometry = geometry(); QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); } } +// Obscures the window by posting an empty expose event to QWindowSystemInterface void QCocoaWindow::obscureWindow() { if (m_isExposed) { + m_geometryUpdateExposeAllowed = false; m_isExposed = false; QWindowSystemInterface::handleExposeEvent(window(), QRegion()); } } +// Updates window geometry by posting an expose event to QWindowSystemInterface +void QCocoaWindow::updateExposedGeometry() +{ + // updateExposedGeometry is not allowed to send the initial expose. If you want + // that call exposeWindow(); + if (!m_geometryUpdateExposeAllowed) + return; + + if (!isWindowExposable()) + return; + + if (m_exposedGeometry == geometry()) + return; + + m_isExposed = true; + m_exposedGeometry = geometry(); + QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); +} + QWindow *QCocoaWindow::childWindowAt(QPoint windowPoint) { QWindow *targetWindow = window(); diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index ca2a15a1cc..403f8dc78a 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -93,6 +93,8 @@ QT_END_NAMESPACE - (BOOL)hasMask; - (BOOL)isOpaque; +- (void)convertFromScreen:(NSPoint)mouseLocation toWindowPoint:(QPointF *)qtWindowPoint andScreenPoint:(QPointF *)qtScreenPoint; + - (void)resetMouseButtons; - (void)handleMouseEvent:(NSEvent *)theEvent; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 71c4de3b69..1c15c3b561 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -175,7 +175,7 @@ static QTouchDevice *touchDevice = 0; - (void) globalFrameChanged:(NSNotification*)notification { Q_UNUSED(notification); - QWindowSystemInterface::handleExposeEvent(m_window, m_window->geometry()); + m_platformWindow->updateExposedGeometry(); } - (void)viewDidMoveToSuperview @@ -186,7 +186,7 @@ static QTouchDevice *touchDevice = 0; if ([self superview]) { m_platformWindow->m_contentViewIsEmbedded = true; QWindowSystemInterface::handleGeometryChange(m_window, m_platformWindow->geometry()); - QWindowSystemInterface::handleExposeEvent(m_window, m_platformWindow->geometry()); + m_platformWindow->updateExposedGeometry(); QWindowSystemInterface::flushWindowSystemEvents(); } else { m_platformWindow->m_contentViewIsEmbedded = false; @@ -261,7 +261,7 @@ static QTouchDevice *touchDevice = 0; // Send a geometry change event to Qt, if it's ready to handle events if (!m_platformWindow->m_inConstructor) { QWindowSystemInterface::handleGeometryChange(m_window, geometry); - QWindowSystemInterface::handleExposeEvent(m_window, geometry); + m_platformWindow->updateExposedGeometry(); QWindowSystemInterface::flushWindowSystemEvents(); } } diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.h b/src/plugins/platforms/cocoa/qnswindowdelegate.h index 06e11fffbb..5717551cc3 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.h +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.h @@ -53,6 +53,7 @@ - (id)initWithQCocoaWindow: (QCocoaWindow *) cocoaWindow; +- (void)windowDidBecomeKey:(NSNotification *)notification; - (void)windowDidResize:(NSNotification *)notification; - (void)windowDidMove:(NSNotification *)notification; - (void)windowWillMove:(NSNotification *)notification; diff --git a/src/plugins/platforms/cocoa/qnswindowdelegate.mm b/src/plugins/platforms/cocoa/qnswindowdelegate.mm index 10536bd5f4..c9b3d69381 100644 --- a/src/plugins/platforms/cocoa/qnswindowdelegate.mm +++ b/src/plugins/platforms/cocoa/qnswindowdelegate.mm @@ -56,6 +56,17 @@ return self; } +- (void)windowDidBecomeKey:(NSNotification *)notification +{ + Q_UNUSED(notification); + if (m_cocoaWindow->m_windowUnderMouse) { + QPointF windowPoint; + QPointF screenPoint; + [m_cocoaWindow->m_qtView convertFromScreen:[NSEvent mouseLocation] toWindowPoint:&windowPoint andScreenPoint:&screenPoint]; + QWindowSystemInterface::handleEnterEvent(m_cocoaWindow->m_enterLeaveTargetWindow, windowPoint, screenPoint); + } +} + - (void)windowDidResize:(NSNotification *)notification { Q_UNUSED(notification); diff --git a/src/plugins/platforms/ios/qioseventdispatcher.mm b/src/plugins/platforms/ios/qioseventdispatcher.mm index 51eb10d385..f93c6cc3a7 100644 --- a/src/plugins/platforms/ios/qioseventdispatcher.mm +++ b/src/plugins/platforms/ios/qioseventdispatcher.mm @@ -206,13 +206,6 @@ namespace bool debugStackUsage = false; } -static int infoPlistValue(NSString* key, int defaultValue) -{ - static NSBundle *bundle = [NSBundle mainBundle]; - NSNumber* value = [bundle objectForInfoDictionaryKey:key]; - return value ? [value intValue] : defaultValue; -} - extern "C" int __attribute__((weak)) main(int argc, char *argv[]) { @autoreleasepool { diff --git a/src/plugins/platforms/ios/qiosglobal.h b/src/plugins/platforms/ios/qiosglobal.h index 1c76d29389..17184dc21d 100644 --- a/src/plugins/platforms/ios/qiosglobal.h +++ b/src/plugins/platforms/ios/qiosglobal.h @@ -61,6 +61,7 @@ QPointF fromCGPoint(const CGPoint &point); Qt::ScreenOrientation toQtScreenOrientation(UIDeviceOrientation uiDeviceOrientation); UIDeviceOrientation fromQtScreenOrientation(Qt::ScreenOrientation qtOrientation); QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen); +int infoPlistValue(NSString* key, int defaultValue); QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosglobal.mm b/src/plugins/platforms/ios/qiosglobal.mm index d749b8f514..8dd690f301 100644 --- a/src/plugins/platforms/ios/qiosglobal.mm +++ b/src/plugins/platforms/ios/qiosglobal.mm @@ -134,5 +134,12 @@ QRect fromPortraitToPrimary(const QRect &rect, QPlatformScreen *screen) : QRect(rect.y(), geometry.height() - rect.width() - rect.x(), rect.height(), rect.width()); } +int infoPlistValue(NSString* key, int defaultValue) +{ + static NSBundle *bundle = [NSBundle mainBundle]; + NSNumber* value = [bundle objectForInfoDictionaryKey:key]; + return value ? [value intValue] : defaultValue; +} + QT_END_NAMESPACE diff --git a/src/plugins/platforms/ios/qiosinputcontext.mm b/src/plugins/platforms/ios/qiosinputcontext.mm index 0e43429015..ea6a0bd4a6 100644 --- a/src/plugins/platforms/ios/qiosinputcontext.mm +++ b/src/plugins/platforms/ios/qiosinputcontext.mm @@ -270,7 +270,7 @@ void QIOSInputContext::scrollRootView() && m_keyboardListener->m_keyboardVisibleAndDocked && m_focusView.window == view.window) { QRectF cursorRect = qGuiApp->inputMethod()->cursorRectangle(); - cursorRect.translate(qGuiApp->focusWindow()->geometry().topLeft()); + cursorRect.translate(m_focusView.qwindow->geometry().topLeft()); qreal keyboardY = m_keyboardListener->m_keyboardEndRect.y(); int statusBarY = qGuiApp->primaryScreen()->availableGeometry().y(); const int margin = 20; diff --git a/src/plugins/platforms/ios/qiosintegration.h b/src/plugins/platforms/ios/qiosintegration.h index c655d8d3bf..fdecf70725 100644 --- a/src/plugins/platforms/ios/qiosintegration.h +++ b/src/plugins/platforms/ios/qiosintegration.h @@ -74,6 +74,8 @@ public: QStringList themeNames() const; QPlatformTheme *createPlatformTheme(const QString &name) const; + QPlatformDrag *drag() const Q_DECL_OVERRIDE { return 0; } + QAbstractEventDispatcher *createEventDispatcher() const; QPlatformNativeInterface *nativeInterface() const; diff --git a/src/plugins/platforms/ios/qiosviewcontroller.mm b/src/plugins/platforms/ios/qiosviewcontroller.mm index 2e7e44d32c..0a6a00b753 100644 --- a/src/plugins/platforms/ios/qiosviewcontroller.mm +++ b/src/plugins/platforms/ios/qiosviewcontroller.mm @@ -101,12 +101,15 @@ - (BOOL)prefersStatusBarHidden { + static bool hiddenFromPlist = infoPlistValue(@"UIStatusBarHidden", false); + if (hiddenFromPlist) + return YES; QWindow *focusWindow = QGuiApplication::focusWindow(); - if (!focusWindow) + if (!focusWindow || !focusWindow->handle()) return [UIApplication sharedApplication].statusBarHidden; - QIOSWindow *topLevel = static_cast<QIOSWindow *>(focusWindow->handle())->topLevelWindow(); - return topLevel->window()->windowState() == Qt::WindowFullScreen; + QWindow *topLevel = static_cast<QIOSWindow *>(focusWindow->handle())->topLevelWindow(); + return topLevel->windowState() == Qt::WindowFullScreen; } @end diff --git a/src/plugins/platforms/ios/qioswindow.h b/src/plugins/platforms/ios/qioswindow.h index d36a81180c..8a5eb589d2 100644 --- a/src/plugins/platforms/ios/qioswindow.h +++ b/src/plugins/platforms/ios/qioswindow.h @@ -87,7 +87,7 @@ public: WId winId() const { return WId(m_view); }; - QIOSWindow *topLevelWindow() const; + QWindow *topLevelWindow() const; private: void applyGeometry(const QRect &rect); diff --git a/src/plugins/platforms/ios/qioswindow.mm b/src/plugins/platforms/ios/qioswindow.mm index 7ab136e8b9..1acd9ee354 100644 --- a/src/plugins/platforms/ios/qioswindow.mm +++ b/src/plugins/platforms/ios/qioswindow.mm @@ -108,8 +108,6 @@ [NSNumber numberWithBool:YES], kEAGLDrawablePropertyRetainedBacking, kEAGLColorFormatRGBA8, kEAGLDrawablePropertyColorFormat, nil]; - [self updateTextInputTraits]; - if (isQtApplication()) self.hidden = YES; @@ -330,13 +328,9 @@ - (BOOL)becomeFirstResponder { - // On iOS, a QWindow should only have input focus when the input panel is - // open. This is to stop cursors and focus rects from being drawn when the - // user cannot type. And since the keyboard will open when a view becomes - // the first responder, it's now a good time to inform QPA that the QWindow - // this view backs became active: + // Note: QIOSInputContext controls our first responder status based on + // whether or not the keyboard should be open or closed. [self updateTextInputTraits]; - QWindowSystemInterface::handleWindowActivated(m_qioswindow->window()); return [super becomeFirstResponder]; } @@ -345,7 +339,8 @@ // Resigning first responed status means that the virtual keyboard was closed, or // some other view became first responder. In either case we clear the focus object to // avoid blinking cursors in line edits etc: - static_cast<QWindowPrivate *>(QObjectPrivate::get(m_qioswindow->window()))->clearFocusObject(); + if (m_qioswindow) + static_cast<QWindowPrivate *>(QObjectPrivate::get(m_qioswindow->window()))->clearFocusObject(); return [super resignFirstResponder]; } @@ -427,8 +422,10 @@ - (QWindow *)qwindow { - if ([self isKindOfClass:[QUIView class]]) - return static_cast<QUIView *>(self)->m_qioswindow->window(); + if ([self isKindOfClass:[QUIView class]]) { + if (QIOSWindow *w = static_cast<QUIView *>(self)->m_qioswindow) + return w->window(); + } return nil; } @@ -473,6 +470,7 @@ QIOSWindow::~QIOSWindow() // cancellation of all touch events. [m_view touchesCancelled:0 withEvent:0]; + m_view->m_qioswindow = 0; [m_view removeFromSuperview]; [m_view release]; } @@ -637,7 +635,7 @@ void QIOSWindow::setParent(const QPlatformWindow *parentWindow) } } -QIOSWindow *QIOSWindow::topLevelWindow() const +QWindow *QIOSWindow::topLevelWindow() const { QWindow *window = this->window(); while (window) { @@ -651,7 +649,7 @@ QIOSWindow *QIOSWindow::topLevelWindow() const window = parent; } - return static_cast<QIOSWindow *>(window->handle()); + return window; } void QIOSWindow::requestActivateWindow() |