From 05ddae12d18a348afd942fd85a8d8773698da3a1 Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Thu, 15 Aug 2013 10:45:51 +0200 Subject: Android: Fix orientation change on Android 4.3 In Android 4.3, we will get a new native window pointer for the same surface (the old surface has not been destroyed), whereas before we would get the same pointer, thus hitting the "sameNativeWindow" branch. This revealed some bugs in the surfaceChanged code path when the old surface had not been destroyed. This path is now taken both when there's no old surface (the app has been suspended in the mean time) and when the orientation changes. To handle the second case, we need to make sure: 1. We update the static pointer 2. We update the pointers in the platform windows 3. We don't add a second reference to the static data for windows 4. We schedule an update of the window size Task-number: QTBUG-32878 Change-Id: I47257615f9ba820315fc98d7a804e52223f430bf Reviewed-by: Christian Stromme Reviewed-by: Frederik Gladhorn --- .../platforms/android/src/androidjnimain.cpp | 40 ++++++++++++---------- .../src/opengl/qandroidopenglplatformwindow.cpp | 21 ++++++++++-- .../src/opengl/qandroidopenglplatformwindow.h | 2 ++ .../android/src/qandroidplatformintegration.cpp | 1 + 4 files changed, 43 insertions(+), 21 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/android/src/androidjnimain.cpp b/src/plugins/platforms/android/src/androidjnimain.cpp index 162a8aa977..74183b3107 100644 --- a/src/plugins/platforms/android/src/androidjnimain.cpp +++ b/src/plugins/platforms/android/src/androidjnimain.cpp @@ -555,33 +555,37 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jobject jSurface) m_nativeWindow = nativeWindow; if (m_waitForWindow) m_waitForWindowSemaphore.release(); - if (m_androidPlatformIntegration && !sameNativeWindow) { - m_surfaceMutex.unlock(); - m_androidPlatformIntegration->surfaceChanged(); - } else if (m_androidPlatformIntegration && sameNativeWindow) { - QPlatformScreen *screen = m_androidPlatformIntegration->screen(); + + if (m_androidPlatformIntegration) { QSize size = QtAndroid::nativeWindowSize(); + QPlatformScreen *screen = m_androidPlatformIntegration->screen(); QRect geometry(QPoint(0, 0), size); QWindowSystemInterface::handleScreenAvailableGeometryChange(screen->screen(), geometry); QWindowSystemInterface::handleScreenGeometryChange(screen->screen(), geometry); - // Resize all top level windows, since they share the same surface - foreach (QWindow *w, QGuiApplication::topLevelWindows()) { - QAndroidOpenGLPlatformWindow *window = - static_cast(w->handle()); - - if (window != 0) { - window->lock(); - window->scheduleResize(size); - - QWindowSystemInterface::handleExposeEvent(window->window(), - QRegion(window->window()->geometry())); - window->unlock(); + if (!sameNativeWindow) { + m_surfaceMutex.unlock(); + m_androidPlatformIntegration->surfaceChanged(); + } else { + // Resize all top level windows, since they share the same surface + foreach (QWindow *w, QGuiApplication::topLevelWindows()) { + QAndroidOpenGLPlatformWindow *window = + static_cast(w->handle()); + + if (window != 0) { + window->lock(); + window->scheduleResize(size); + + QWindowSystemInterface::handleExposeEvent(window->window(), + QRegion(window->window()->geometry())); + window->unlock(); + } } + + m_surfaceMutex.unlock(); } - m_surfaceMutex.unlock(); } else { m_surfaceMutex.unlock(); } diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp index 5362906e0e..b1a2231ff5 100644 --- a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp +++ b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.cpp @@ -85,9 +85,19 @@ void QAndroidOpenGLPlatformWindow::invalidateSurface() } } +void QAndroidOpenGLPlatformWindow::updateStaticNativeWindow() +{ + QWriteLocker locker(&m_staticSurfaceLock); + m_staticNativeWindow = QtAndroid::nativeWindow(false); +} + void QAndroidOpenGLPlatformWindow::resetSurface() { - m_referenceCount.ref(); + // Only add a reference if we're not already holding one, otherwise we're just updating + // the native window pointer + if (m_window == 0) + m_referenceCount.ref(); + if (m_staticSurface == 0) { QWriteLocker locker(&m_staticSurfaceLock); QEglFSWindow::resetSurface(); @@ -95,12 +105,17 @@ void QAndroidOpenGLPlatformWindow::resetSurface() m_staticNativeWindow = m_window; } else { QReadLocker locker(&m_staticSurfaceLock); - Q_ASSERT(m_staticSurface != m_surface); m_window = m_staticNativeWindow; m_surface = m_staticSurface; } - QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); // Expose event + { + lock(); + scheduleResize(QtAndroid::nativeWindowSize()); + QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); // Expose event + unlock(); + } + QWindowSystemInterface::flushWindowSystemEvents(); } diff --git a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.h b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.h index 36a110e1a8..9a25957ccd 100644 --- a/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.h +++ b/src/plugins/platforms/android/src/opengl/qandroidopenglplatformwindow.h @@ -71,6 +71,8 @@ public: void destroy(); + static void updateStaticNativeWindow(); + private: QSize m_scheduledResize; QMutex m_lock; diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index 91ad2b368f..636a2b3853 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -162,6 +162,7 @@ void QAndroidPlatformIntegration::invalidateNativeSurface() void QAndroidPlatformIntegration::surfaceChanged() { + QAndroidOpenGLPlatformWindow::updateStaticNativeWindow(); foreach (QWindow *w, QGuiApplication::topLevelWindows()) { QAndroidOpenGLPlatformWindow *window = static_cast(w->handle()); -- cgit v1.2.3 From 99362fb7f25a88829c2d824ebfe6da61d4d7b35f Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 30 Aug 2013 12:08:47 +0200 Subject: Windows XP file dialog: Fix appending the selected filter suffix. The mechanism is triggered by always setting lpstrDefExt, Task-number: QTBUG-33156 Change-Id: Ib3a49410a1ad78fb433a4e0803a0751ec8c2a51e Reviewed-by: Joerg Bornemann --- src/plugins/platforms/windows/qwindowsdialoghelpers.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 27a7044868..9a7d03c0c2 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -1818,8 +1818,8 @@ void QWindowsXpNativeFileDialog::populateOpenFileName(OPENFILENAME *ofn, HWND ow QString defaultSuffix = m_options->defaultSuffix(); if (defaultSuffix.startsWith(QLatin1Char('.'))) defaultSuffix.remove(0, 1); - if (!defaultSuffix.isEmpty()) - ofn->lpstrDefExt = qStringToWCharArray(defaultSuffix); + // QTBUG-33156, also create empty strings to trigger the appending mechanism. + ofn->lpstrDefExt = qStringToWCharArray(defaultSuffix); } // Flags. ofn->Flags = (OFN_NOCHANGEDIR | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_PATHMUSTEXIST); -- cgit v1.2.3 From 0ed30cbf09db591b46370888fa2f687310bf5cff Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 2 Sep 2013 10:20:37 +0200 Subject: Fix compilation with latest Mingw-w64 headers Fix compilation with e.g. mingw-builds 4.8.1-rev4 package. The Mingw-W64 headers define SHSTOCKICONINFO only for vista and newer. Task-number: QTBUG-33225 Change-Id: I30a62c642ae017c7eafb99b1efb06578fd61a12e Reviewed-by: Friedemann Kleint --- src/plugins/platforms/windows/qwindowstheme.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 0fcd20f7bb..9f6e6b18e7 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -39,6 +39,12 @@ ** ****************************************************************************/ +// SHSTOCKICONINFO is only available since Vista +#if _WIN32_WINNT < 0x0600 +# undef _WIN32_WINNT +# define _WIN32_WINNT 0x0600 +#endif + #include "qwindowstheme.h" #include "qwindowsdialoghelpers.h" #include "qwindowscontext.h" -- cgit v1.2.3 From 86f8bee96b658d1712733477e26e70a1fd723102 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 3 Sep 2013 16:25:53 +0200 Subject: OSX: clicking outside a popup: don't propagate the event elsewhere If you click outside a popup window, it only closes the popup; any other widget that was under the cursor at that time should not get the event. The bug was about the popup list on a combobox, but this patch assumes that this rule is universal; can't think of any exceptions at this time. (E.g. a tooltip is not a popup) Clicking on the application menubar still does not close the popup though. Task-number: QTBUG-33241 Change-Id: I2444b7cfd40cf75ff7b70e3fecfeceb2fd4623bf Reviewed-by: Gabriel de Dietrich --- src/plugins/platforms/cocoa/qnsview.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 4505f8b8cf..c6dce8b6f6 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -600,6 +600,7 @@ static QTouchDevice *touchDevice = 0; QWindowSystemInterface::handleCloseEvent(m_platformWindow->m_activePopupWindow); QWindowSystemInterface::flushWindowSystemEvents(); m_platformWindow->m_activePopupWindow = 0; + return; } if ([self hasMarkedText]) { NSInputManager* inputManager = [NSInputManager currentInputManager]; -- cgit v1.2.3 From a2bdda8e3ba324a51620d9e758e444d02c4fd061 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20Johan=20S=C3=B8rvig?= Date: Fri, 30 Aug 2013 14:20:21 +0200 Subject: Fix event delivery for apps with native widgets. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Native widgets, which have a NSView but not a NSWindow, must be created in the hidden state to prevent Cocoa from selecting them for event delivery. Change-Id: I741e52729047ad4e03959f2244abe5b14b5df46b Reviewed-by: Gabriel de Dietrich Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 1 + 1 file changed, 1 insertion(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 86f12e0e5f..a3797682a3 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -792,6 +792,7 @@ void QCocoaWindow::recreateWindow(const QPlatformWindow *parentWindow) QRect rect = window()->geometry(); NSRect frame = NSMakeRect(rect.x(), rect.y(), rect.width(), rect.height()); [m_contentView setFrame:frame]; + [m_contentView setHidden: YES]; } const qreal opacity = qt_window_private(window())->opacity; -- cgit v1.2.3 From 8fd71914b43350a21c0c05051c1a6e24e9d8cb85 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 20 Aug 2013 16:55:17 +0200 Subject: Cocoa: Unregister view from window's notifications only MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Otherwise the view will miss its own frame change notifications. And we must unregister from all the notifications during dealloc. This would also reveal a bug where we would expose an NSView before its super view is visible, leading to those "invalid drawable" warnings when using QQuickViews. Therefore, we add this extra check in QCocoaWindow::exposeWindow(). Task-number: QTBUG-32826 Change-Id: I69018cb6f199b242768d114b2aa34c7f2d243196 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 5 +++-- src/plugins/platforms/cocoa/qnsview.mm | 9 +++------ 2 files changed, 6 insertions(+), 8 deletions(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index a3797682a3..c239aedb05 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -911,7 +911,8 @@ void QCocoaWindow::clearNSWindow(NSWindow *window) [window setContentView:nil]; [window setDelegate:nil]; [window clearPlatformWindow]; - [[NSNotificationCenter defaultCenter] removeObserver:m_contentView]; + [[NSNotificationCenter defaultCenter] removeObserver:m_contentView + name:nil object:window]; } // Returns the current global screen geometry for the nswindow associated with this window. @@ -1023,7 +1024,7 @@ qreal QCocoaWindow::devicePixelRatio() const void QCocoaWindow::exposeWindow() { - if (!m_isExposed) { + if (!m_isExposed && ![[m_contentView superview] isHidden]) { m_isExposed = true; QWindowSystemInterface::handleExposeEvent(window(), QRegion(geometry())); } diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index c6dce8b6f6..c2ffe96f8c 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -107,12 +107,9 @@ static QTouchDevice *touchDevice = 0; m_maskImage = 0; m_maskData = 0; m_window = 0; - if (m_subscribesForGlobalFrameNotifications) { - m_subscribesForGlobalFrameNotifications = false; - [[NSNotificationCenter defaultCenter] removeObserver:self - name:NSViewGlobalFrameDidChangeNotification - object:self]; -} + m_subscribesForGlobalFrameNotifications = false; + [[NSNotificationCenter defaultCenter] removeObserver:self]; + delete currentCustomDragTypes; [super dealloc]; -- cgit v1.2.3 From 9554088557571d5c6b96c710424e591ab8db4e0d Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Tue, 3 Sep 2013 14:23:33 +0200 Subject: Cocoa: Fix NSMenu popup coordinates MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Those should be in window coordinates (or rather, its content view) not view coordinates. Task-number: QTBUG-32826 Change-Id: I52dddeccf17b359163ad477ce4299b934633b4fa Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoamenu.mm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/plugins') diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index f9e033d21b..2e53000596 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -455,7 +455,9 @@ void QCocoaMenu::showPopup(const QWindow *parentWindow, QPoint pos, const QPlatf // Else, we need to transform 'pos' to window or screen coordinates. NSPoint nsPos = NSMakePoint(pos.x() - 1, pos.y()); if (view) { + // Flip y-coordinate first, the convert to content view space. nsPos.y = view.frame.size.height - nsPos.y; + nsPos = [view convertPoint:nsPos toView:view.window.contentView]; } else if (!QGuiApplication::screens().isEmpty()) { QScreen *screen = QGuiApplication::screens().at(0); nsPos.y = screen->availableVirtualSize().height() - nsPos.y; -- cgit v1.2.3 From ac327aa3af8d934abb1d605541d9b6f8d1cfdc27 Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 29 Aug 2013 20:45:26 +0200 Subject: the condition for building the x11 offscreen plugin is ... having xlib Task-number: QTBUG-33240 Change-Id: Idc96239b0bcbe98d1519c239600aebcda42e8818 Reviewed-by: Giuseppe D'Angelo --- src/plugins/platforms/offscreen/offscreen.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins') diff --git a/src/plugins/platforms/offscreen/offscreen.pro b/src/plugins/platforms/offscreen/offscreen.pro index 270e3ce228..9f10eaad94 100644 --- a/src/plugins/platforms/offscreen/offscreen.pro +++ b/src/plugins/platforms/offscreen/offscreen.pro @@ -16,7 +16,7 @@ HEADERS = qoffscreenintegration.h \ OTHER_FILES += offscreen.json -contains(QT_CONFIG, xcb):contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2) { +contains(QT_CONFIG, xlib):contains(QT_CONFIG, opengl):!contains(QT_CONFIG, opengles2) { SOURCES += qoffscreenintegration_x11.cpp HEADERS += qoffscreenintegration_x11.h system(echo "Using X11 offscreen integration with GLX") -- cgit v1.2.3