diff options
author | Liang Qi <liang.qi@qt.io> | 2017-04-04 16:11:41 +0000 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2017-04-04 16:15:55 +0000 |
commit | aeb3f9d168580efb8ab2df4003c53cbe8045ed80 (patch) | |
tree | 7f98aec853b447f078083fe1fca2d49f2c66a04a /src/plugins/platforms | |
parent | 5eb74ad4f59cb3ce212c3673005b512fdecd7ec1 (diff) | |
parent | 9419dfe8ee45d08f09c09d3cbece511d721546f0 (diff) |
Merge "Merge remote-tracking branch 'origin/5.9' into dev" into refs/staging/dev
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/android/androidjnimain.cpp | 7 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qcocoawindow.mm | 29 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.h | 1 | ||||
-rw-r--r-- | src/plugins/platforms/cocoa/qnsview.mm | 8 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowscontext.cpp | 3 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowsmime.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/windows/qwindowstheme.cpp | 4 | ||||
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtscreen.cpp | 23 | ||||
-rw-r--r-- | src/plugins/platforms/winrt/qwinrtscreen.h | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbintegration.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbmime.cpp | 2 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbwindow.cpp | 4 |
12 files changed, 56 insertions, 31 deletions
diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 0fabb25233..17c197ea38 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -533,6 +533,12 @@ static jboolean startQtApplication(JNIEnv *env, jobject /*object*/, jstring para return pthread_create(&m_qtAppThread, nullptr, startMainMethod, nullptr) == 0; } +static void quitQtCoreApplication(JNIEnv *env, jclass /*clazz*/) +{ + Q_UNUSED(env); + QCoreApplication::quit(); +} + static void quitQtAndroidPlugin(JNIEnv *env, jclass /*clazz*/) { Q_UNUSED(env); @@ -733,6 +739,7 @@ static JNINativeMethod methods[] = { {"startQtAndroidPlugin", "()Z", (void *)startQtAndroidPlugin}, {"startQtApplication", "(Ljava/lang/String;Ljava/lang/String;)V", (void *)startQtApplication}, {"quitQtAndroidPlugin", "()V", (void *)quitQtAndroidPlugin}, + {"quitQtCoreApplication", "()V", (void *)quitQtCoreApplication}, {"terminateQt", "()V", (void *)terminateQt}, {"setDisplayMetrics", "(IIIIDDDD)V", (void *)setDisplayMetrics}, {"setSurface", "(ILjava/lang/Object;II)V", (void *)setSurface}, diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index 6478365d07..602cea97a7 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -58,6 +58,8 @@ #include <QDebug> +#include <vector> + enum { defaultWindowWidth = 160, defaultWindowHeight = 160 @@ -1613,6 +1615,13 @@ void QCocoaWindow::recreateWindowIfNeeded() [m_nsWindow closeAndRelease]; if (isChildNSWindow()) [m_view.window.parentWindow removeChildWindow:m_view.window]; + if (isContentView()) { + // We explicitly disassociate m_view from the window's contentView, + // as AppKit does not automatically do this in response to removing + // the view from the NSThemeFrame subview list, so we might end up + // with a NSWindow contentView pointing to a deallocated NSView. + m_view.window.contentView = nil; + } m_nsWindow = 0; } @@ -1636,13 +1645,6 @@ void QCocoaWindow::recreateWindowIfNeeded() [m_nsWindow setContentView:m_view]; [m_view release]; [m_view setPostsFrameChangedNotifications:YES]; - // QTBUG-58963 - // viewDidChangeFrame() should be called for each window automatically at this point because it is - // registered with Q_NOTIFICATION_HANDLER(NSViewFrameDidChangeNotification); - // The corner case when it's not called and we need to make a manual geometry update is when window's - // size is not specified explicitly but minimumSize is set and matches to the size NSView was created with. - if (QSizeF::fromCGSize(m_view.frame.size) == [QNSView defaultViewSize]) - viewDidChangeFrame(); } } @@ -1862,8 +1864,7 @@ void QCocoaWindow::applyWindowState(Qt::WindowStates requestedState) // the new state. return; } - default: - Q_FALLTHROUGH(); + default:; } // Then we apply the new state if needed @@ -1881,12 +1882,8 @@ void QCocoaWindow::applyWindowState(Qt::WindowStates requestedState) [m_nsWindow miniaturize:sender]; break; case Qt::WindowNoState: - switch (windowState()) { - case Qt::WindowMaximized: + if (windowState() == Qt::WindowMaximized) toggleMaximized(); - default: - Q_FALLTHROUGH(); - } break; default: Q_UNREACHABLE(); @@ -2068,10 +2065,10 @@ void QCocoaWindow::applyContentBorderThickness(NSWindow *window) } // Find consecutive registered border areas, starting from the top. - QList<BorderRange> ranges = m_contentBorderAreas.values(); + std::vector<BorderRange> ranges(m_contentBorderAreas.cbegin(), m_contentBorderAreas.cend()); std::sort(ranges.begin(), ranges.end()); int effectiveTopContentBorderThickness = m_topContentBorderThickness; - foreach (BorderRange range, ranges) { + for (BorderRange range : ranges) { // Skip disiabled ranges (typically hidden tool bars) if (!m_enabledContentBorderAreas.value(range.identifier, false)) continue; diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index a05bd66890..75a508370f 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -88,7 +88,6 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QSet<quint32> m_acceptedKeyDowns; } -+ (QSizeF)defaultViewSize; - (id)init; - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow; #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index e16915273a..bbdf9ad44f 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -140,8 +140,7 @@ static bool _q_dontOverrideCtrlLMB = false; - (id) init { - self = [super initWithFrame : NSMakeRect(0, 0, [[self class] defaultViewSize].width(), [[self class] defaultViewSize].height())]; - if (self) { + if (self = [super initWithFrame:NSZeroRect]) { m_backingStore = 0; m_maskImage = 0; m_shouldInvalidateWindowShadow = false; @@ -189,11 +188,6 @@ static bool _q_dontOverrideCtrlLMB = false; [super dealloc]; } -+ (QSizeF)defaultViewSize -{ - return QSizeF(300.0, 300.0); -} - - (id)initWithCocoaWindow:(QCocoaWindow *)platformWindow { self = [self init]; diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 5f65f8e958..f017929148 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -1088,6 +1088,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message, #endif } break; case QtWindows::DpiChangedEvent: { + if (GetWindowLongPtr(hwnd, GWL_STYLE) & WS_DLGFRAME) + return false; // Fixed-size window should not be resized + platformWindow->setFlag(QWindowsWindow::WithinDpiChanged); const RECT *prcNewWindow = reinterpret_cast<RECT *>(lParam); SetWindowPos(hwnd, NULL, prcNewWindow->left, prcNewWindow->top, diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 71fd12d71b..bd4822c664 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -717,7 +717,7 @@ QVariant QWindowsMimeText::convertToMime(const QString &mime, LPDATAOBJECT pData if (preferredType == QVariant::String) ret = str; else - ret = str.toUtf8(); + ret = std::move(str).toUtf8(); } qCDebug(lcQpaMime) << __FUNCTION__ << ret; return ret; diff --git a/src/plugins/platforms/windows/qwindowstheme.cpp b/src/plugins/platforms/windows/qwindowstheme.cpp index 4ae1a751e9..3e2cb5e9e9 100644 --- a/src/plugins/platforms/windows/qwindowstheme.cpp +++ b/src/plugins/platforms/windows/qwindowstheme.cpp @@ -815,14 +815,14 @@ QString QWindowsFileIconEngine::cacheKey() const // Return "" for .exe, .lnk and .ico extensions. // It is faster to just look at the file extensions; // avoiding slow QFileInfo::isExecutable() (QTBUG-13182) - const QString &suffix = fileInfo().suffix(); + QString suffix = fileInfo().suffix(); if (!suffix.compare(QLatin1String("exe"), Qt::CaseInsensitive) || !suffix.compare(QLatin1String("lnk"), Qt::CaseInsensitive) || !suffix.compare(QLatin1String("ico"), Qt::CaseInsensitive)) { return QString(); } return QLatin1String("qt_.") - + (suffix.isEmpty() ? fileInfo().fileName() : suffix.toUpper()); // handle "Makefile" ;) + + (suffix.isEmpty() ? fileInfo().fileName() : std::move(suffix).toUpper()); // handle "Makefile" ;) } QPixmap QWindowsFileIconEngine::filePixmap(const QSize &size, QIcon::Mode, QIcon::State) diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 150fc8a25e..edfcf038d7 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -91,6 +91,7 @@ typedef ITypedEventHandler<CoreWindow*, PointerEventArgs*> PointerHandler; typedef ITypedEventHandler<CoreWindow*, WindowSizeChangedEventArgs*> SizeChangedHandler; typedef ITypedEventHandler<CoreWindow*, VisibilityChangedEventArgs*> VisibilityChangedHandler; typedef ITypedEventHandler<DisplayInformation*, IInspectable*> DisplayInformationHandler; +typedef ITypedEventHandler<ICorePointerRedirector*, PointerEventArgs*> RedirectHandler; #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) typedef ITypedEventHandler<ApplicationView*, IInspectable*> VisibleBoundsChangedHandler; #endif // WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) @@ -454,6 +455,8 @@ typedef HRESULT (__stdcall ICoreWindow::*CoreWindowCallbackRemover)(EventRegistr uint qHash(CoreWindowCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } typedef HRESULT (__stdcall IDisplayInformation::*DisplayCallbackRemover)(EventRegistrationToken); uint qHash(DisplayCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } +typedef HRESULT (__stdcall ICorePointerRedirector::*RedirectorCallbackRemover)(EventRegistrationToken); +uint qHash(RedirectorCallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) typedef HRESULT (__stdcall IApplicationView2::*ApplicationView2CallbackRemover)(EventRegistrationToken); uint qHash(ApplicationView2CallbackRemover key) { void *ptr = *(void **)(&key); return qHash(ptr); } @@ -464,6 +467,7 @@ class QWinRTScreenPrivate public: QTouchDevice *touchDevice; ComPtr<ICoreWindow> coreWindow; + ComPtr<ICorePointerRedirector> redirect; ComPtr<Xaml::IDependencyObject> canvas; ComPtr<IApplicationView> view; ComPtr<IDisplayInformation> displayInformation; @@ -482,6 +486,7 @@ public: QHash<Qt::Key, KeyInfo> activeKeys; QHash<CoreWindowCallbackRemover, EventRegistrationToken> windowTokens; QHash<DisplayCallbackRemover, EventRegistrationToken> displayTokens; + QHash<RedirectorCallbackRemover, EventRegistrationToken> redirectTokens; #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) QHash<ApplicationView2CallbackRemover, EventRegistrationToken> view2Tokens; ComPtr<IApplicationView2> view2; @@ -513,6 +518,10 @@ QWinRTScreen::QWinRTScreen() hr = window->get_CoreWindow(&d->coreWindow); Q_ASSERT_SUCCEEDED(hr); + + hr = d->coreWindow.As(&d->redirect); + Q_ASSERT_SUCCEEDED(hr); + hr = d->coreWindow->Activate(); Q_ASSERT_SUCCEEDED(hr); @@ -595,6 +604,10 @@ QWinRTScreen::~QWinRTScreen() hr = (d->displayInformation.Get()->*i.key())(i.value()); Q_ASSERT_SUCCEEDED(hr); } + for (QHash<RedirectorCallbackRemover, EventRegistrationToken>::const_iterator i = d->redirectTokens.begin(); i != d->redirectTokens.end(); ++i) { + hr = (d->redirect.Get()->*i.key())(i.value()); + Q_ASSERT_SUCCEEDED(hr); + } #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) for (QHash<ApplicationView2CallbackRemover, EventRegistrationToken>::const_iterator i = d->view2Tokens.begin(); i != d->view2Tokens.end(); ++i) { hr = (d->view2.Get()->*i.key())(i.value()); @@ -754,6 +767,9 @@ void QWinRTScreen::initialize() Q_ASSERT_SUCCEEDED(hr); onOrientationChanged(Q_NULLPTR, Q_NULLPTR); onVisibilityChanged(nullptr, nullptr); + + hr = d->redirect->add_PointerRoutedReleased(Callback<RedirectHandler>(this, &QWinRTScreen::onRedirectReleased).Get(), &d->redirectTokens[&ICorePointerRedirector::remove_PointerRoutedReleased]); + Q_ASSERT_SUCCEEDED(hr); } void QWinRTScreen::setCursorRect(const QRectF &cursorRect) @@ -1378,6 +1394,13 @@ HRESULT QWinRTScreen::onDpiChanged(IDisplayInformation *, IInspectable *) return S_OK; } +HRESULT QWinRTScreen::onRedirectReleased(ICorePointerRedirector *, IPointerEventArgs *args) +{ + // When dragging ends with a non-mouse input device then onRedirectRelease is invoked. + // QTBUG-58781 + return onPointerUpdated(nullptr, args); +} + #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) HRESULT QWinRTScreen::onWindowSizeChanged(IApplicationView *, IInspectable *) #else diff --git a/src/plugins/platforms/winrt/qwinrtscreen.h b/src/plugins/platforms/winrt/qwinrtscreen.h index 7dcdb98ead..fd6499c2b9 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.h +++ b/src/plugins/platforms/winrt/qwinrtscreen.h @@ -52,6 +52,7 @@ namespace ABI { namespace Core { struct IAutomationProviderRequestedEventArgs; struct ICharacterReceivedEventArgs; + struct ICorePointerRedirector; struct ICoreWindow; struct ICoreWindowEventArgs; struct IKeyEventArgs; @@ -149,6 +150,7 @@ private: #else HRESULT onWindowSizeChanged(ABI::Windows::UI::Core::ICoreWindow *, ABI::Windows::UI::Core::IWindowSizeChangedEventArgs *); #endif + HRESULT onRedirectReleased(ABI::Windows::UI::Core::ICorePointerRedirector *, ABI::Windows::UI::Core::IPointerEventArgs *); QScopedPointer<QWinRTScreenPrivate> d_ptr; QRectF mCursorRect; diff --git a/src/plugins/platforms/xcb/qxcbintegration.cpp b/src/plugins/platforms/xcb/qxcbintegration.cpp index 7f1cff1299..396d8837e9 100644 --- a/src/plugins/platforms/xcb/qxcbintegration.cpp +++ b/src/plugins/platforms/xcb/qxcbintegration.cpp @@ -479,7 +479,7 @@ QByteArray QXcbIntegration::wmClass() const } if (!name.isEmpty() && !className.isEmpty()) - m_wmClass = name.toLocal8Bit() + '\0' + className.toLocal8Bit() + '\0'; + m_wmClass = std::move(name).toLocal8Bit() + '\0' + std::move(className).toLocal8Bit() + '\0'; } return m_wmClass; } diff --git a/src/plugins/platforms/xcb/qxcbmime.cpp b/src/plugins/platforms/xcb/qxcbmime.cpp index 7592eb2887..186f31e08a 100644 --- a/src/plugins/platforms/xcb/qxcbmime.cpp +++ b/src/plugins/platforms/xcb/qxcbmime.cpp @@ -305,7 +305,7 @@ xcb_atom_t QXcbMime::mimeAtomForFormat(QXcbConnection *connection, const QString QString formatWithCharset = format; formatWithCharset.append(QLatin1String(";charset=utf-8")); - xcb_atom_t a = connection->internAtom(formatWithCharset.toLatin1()); + xcb_atom_t a = connection->internAtom(std::move(formatWithCharset).toLatin1()); if (a && atoms.contains(a)) { *requestedEncoding = "utf-8"; return a; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 3d8c6de72f..db6ade5662 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -1472,8 +1472,8 @@ void QXcbWindow::setParent(const QPlatformWindow *parent) void QXcbWindow::setWindowTitle(const QString &title) { - const QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH - const QByteArray ba = fullTitle.toUtf8(); + QString fullTitle = formatWindowTitle(title, QString::fromUtf8(" \xe2\x80\x94 ")); // unicode character U+2014, EM DASH + const QByteArray ba = std::move(fullTitle).toUtf8(); xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, |