From 45862976b7566d416aff887b74eb60cb039a3dd6 Mon Sep 17 00:00:00 2001 From: Maurice Kalinowski Date: Fri, 7 Apr 2017 11:00:54 +0200 Subject: winrt: Fix build for Windows 10 Creators Update Phone specific UI colors have been removed from the windows headers. Continue to use the enum values does not gain anything as the native calls return errors for those. Actually they did that already with 14393. Change-Id: I4b04d3af319766216ae7c550af704aab488c1d15 Reviewed-by: Friedemann Kleint Reviewed-by: Oliver Wolff --- src/plugins/platforms/winrt/qwinrttheme.cpp | 3 +++ src/plugins/platforms/winrt/winrt.pro | 1 + 2 files changed, 4 insertions(+) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/winrt/qwinrttheme.cpp b/src/plugins/platforms/winrt/qwinrttheme.cpp index 6b35bde83e..5696ae7a10 100644 --- a/src/plugins/platforms/winrt/qwinrttheme.cpp +++ b/src/plugins/platforms/winrt/qwinrttheme.cpp @@ -146,6 +146,8 @@ static void nativeColorSettings(QPalette &p) if (uiColorSettings(L"Hotlight", UIElementType_Hotlight, &color)) p.setColor(QPalette::BrightText, fromColor(color)); + // Starting with SDK 15063 those have been removed. +#ifndef QT_WINRT_DISABLE_PHONE_COLORS //Phone related if (uiColorSettings(L"PopupBackground", UIElementType_PopupBackground, &color)) { p.setColor(QPalette::ToolTipBase, fromColor(color)); @@ -186,6 +188,7 @@ static void nativeColorSettings(QPalette &p) if (uiColorSettings(L"TextContrastWithHigh", UIElementType_TextContrastWithHigh, &color)) p.setColor(QPalette::BrightText, fromColor(color)); +#endif // QT_WINRT_DISABLE_PHONE_COLORS } QWinRTTheme::QWinRTTheme() diff --git a/src/plugins/platforms/winrt/winrt.pro b/src/plugins/platforms/winrt/winrt.pro index 35801fdacc..02a848b03f 100644 --- a/src/plugins/platforms/winrt/winrt.pro +++ b/src/plugins/platforms/winrt/winrt.pro @@ -51,6 +51,7 @@ OTHER_FILES += winrt.json WINRT_SDK_VERSION_STRING = $$(UCRTVersion) WINRT_SDK_VERSION = $$member($$list($$split(WINRT_SDK_VERSION_STRING, .)), 2) lessThan(WINRT_SDK_VERSION, 14322): DEFINES += QT_WINRT_LIMITED_DRAGANDDROP +greaterThan(WINRT_SDK_VERSION, 14393): DEFINES += QT_WINRT_DISABLE_PHONE_COLORS contains(DEFINES, QT_NO_DRAGANDDROP) { SOURCES -= qwinrtdrag.cpp -- cgit v1.2.3 From 2099709a721e2bc72350a02757099df6629475ca Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 10 Apr 2017 09:52:16 +0300 Subject: Fix build: Remove unused variable Change-Id: Ib5e7782e23eb1ff976caedd167d3df8b857d9883 Reviewed-by: Eskil Abrahamsen Blomfeldt --- src/plugins/platforms/android/qandroidplatformopenglcontext.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp index 6f979f614c..bef6bb9d42 100644 --- a/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp +++ b/src/plugins/platforms/android/qandroidplatformopenglcontext.cpp @@ -67,10 +67,7 @@ void QAndroidPlatformOpenGLContext::swapBuffers(QPlatformSurface *surface) bool QAndroidPlatformOpenGLContext::makeCurrent(QPlatformSurface *surface) { - bool ret = QEGLPlatformContext::makeCurrent(surface); - QOpenGLContextPrivate *ctx_d = QOpenGLContextPrivate::get(context()); - - return ret; + return QEGLPlatformContext::makeCurrent(surface); } EGLSurface QAndroidPlatformOpenGLContext::eglSurfaceForPlatformSurface(QPlatformSurface *surface) -- cgit v1.2.3 From db29042588ac406b46ec431badc2c12a5d3a8d56 Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Sun, 9 Apr 2017 15:57:45 +0200 Subject: QQnxWindow: replace QUuid::toString().toLatin1() with QUuid::toByteArray() UUIDs are always US-ASCII. Change-Id: I335882a2df179204d8eca1cf9f02bc6473bac700 Reviewed-by: Edward Welbourne --- src/plugins/platforms/qnx/qqnxwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/qnx/qqnxwindow.cpp b/src/plugins/platforms/qnx/qqnxwindow.cpp index 6fd0191e43..30288ccb20 100644 --- a/src/plugins/platforms/qnx/qqnxwindow.cpp +++ b/src/plugins/platforms/qnx/qqnxwindow.cpp @@ -694,7 +694,7 @@ void QQnxWindow::initWindow() void QQnxWindow::createWindowGroup() { // Generate a random window group name - m_windowGroupName = QUuid::createUuid().toString().toLatin1(); + m_windowGroupName = QUuid::createUuid().toByteArray(); // Create window group so child windows can be parented by container window Q_SCREEN_CHECKERROR(screen_create_window_group(m_window, m_windowGroupName.constData()), -- cgit v1.2.3 From 6c4cbd4122edf8b78f34778400d485b11da98404 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 10 Apr 2017 14:19:12 +0300 Subject: Android: Fix crash at exit We need to remove and release the surface imediately, otherwise setSurface might be called after the object is deleted. Task-number: QTBUG-59818 Change-Id: I3a09e3de1ceecc22d8d7a48e2fc1cfe40cf09f0a Reviewed-by: Laszlo Agocs Reviewed-by: Mathias Hasselmann Reviewed-by: Christian Stromme --- src/plugins/platforms/android/androidjnimain.cpp | 27 +++++++++++----------- .../platforms/android/qandroidplatformscreen.cpp | 3 +++ 2 files changed, 16 insertions(+), 14 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index 17c197ea38..bde7457c0b 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -402,11 +402,16 @@ namespace QtAndroid if (surfaceId == -1) return; - QJNIEnvironmentPrivate env; - if (!env) - return; + { + QMutexLocker lock(&m_surfacesMutex); + const auto &it = m_surfaces.find(surfaceId); + if (it != m_surfaces.end()) + m_surfaces.erase(it); + } - env->CallStaticVoidMethod(m_applicationClass, + QJNIEnvironmentPrivate env; + if (env) + env->CallStaticVoidMethod(m_applicationClass, m_destroySurfaceMethodID, surfaceId); } @@ -584,18 +589,12 @@ static void setSurface(JNIEnv *env, jobject /*thiz*/, jint id, jobject jSurface, { QMutexLocker lock(&m_surfacesMutex); const auto &it = m_surfaces.find(id); - if (it == m_surfaces.end()) { - qWarning()<<"Can't find surface" << id; - return; - } - auto surfaceClient = it.value(); - if (!surfaceClient) // This should never happen... + if (it == m_surfaces.end()) return; - surfaceClient->surfaceChanged(env, jSurface, w, h); - - if (!jSurface) - m_surfaces.erase(it); + auto surfaceClient = it.value(); + if (surfaceClient) + surfaceClient->surfaceChanged(env, jSurface, w, h); } static void setDisplayMetrics(JNIEnv */*env*/, jclass /*clazz*/, diff --git a/src/plugins/platforms/android/qandroidplatformscreen.cpp b/src/plugins/platforms/android/qandroidplatformscreen.cpp index 155d6bfb8d..3b59b293a5 100644 --- a/src/plugins/platforms/android/qandroidplatformscreen.cpp +++ b/src/plugins/platforms/android/qandroidplatformscreen.cpp @@ -311,10 +311,13 @@ void QAndroidPlatformScreen::doRedraw() } } if (!hasVisibleRasterWindows) { + lockSurface(); if (m_id != -1) { QtAndroid::destroySurface(m_id); + releaseSurface(); m_id = -1; } + unlockSurface(); return; } QMutexLocker lock(&m_surfaceMutex); -- cgit v1.2.3 From 9091a058bc61e297abea03edca322edcd658cc1f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Str=C3=B8mme?= Date: Tue, 28 Mar 2017 15:53:42 +0200 Subject: Android: Fix application state tracking - Make sure we don't process state changes before the platform plugin is completely created and registered. - Protect shared data with mutexes. - Don't update the application state from different threads. This was causing issues when testing run-time permission checks, when the application quickly switches state due to permission dialog being shown. In this case the states would be incorrectly delivered when the application was made active again. Change-Id: I3446eab9414ee5437cd788c27d65f808d1314aa5 Reviewed-by: BogDan Vatra --- src/plugins/platforms/android/androidjnimain.cpp | 42 ++++++++++++++-------- src/plugins/platforms/android/androidjnimain.h | 2 -- .../android/qandroidplatformintegration.cpp | 13 ++++--- .../android/qandroidplatformintegration.h | 7 ++-- .../platforms/android/qandroidplatformwindow.cpp | 5 --- 5 files changed, 40 insertions(+), 29 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/android/androidjnimain.cpp b/src/plugins/platforms/android/androidjnimain.cpp index bde7457c0b..e47dd91a3e 100644 --- a/src/plugins/platforms/android/androidjnimain.cpp +++ b/src/plugins/platforms/android/androidjnimain.cpp @@ -82,8 +82,8 @@ static jobject m_serviceObject = nullptr; static jmethodID m_setSurfaceGeometryMethodID = nullptr; static jmethodID m_destroySurfaceMethodID = nullptr; -static bool m_activityActive = true; // defaults to true because when the platform plugin is - // initialized, QtActivity::onResume() has already been called +static int m_pendingApplicationState = -1; +static QBasicMutex m_pendingAppStateMtx; static jclass m_bitmapClass = nullptr; static jmethodID m_createBitmapMethodID = nullptr; @@ -130,13 +130,22 @@ static const char m_qtTag[] = "Qt"; static const char m_classErrorMsg[] = "Can't find class \"%s\""; static const char m_methodErrorMsg[] = "Can't find method \"%s%s\""; +static void flushPendingApplicationState(); + namespace QtAndroid { void setAndroidPlatformIntegration(QAndroidPlatformIntegration *androidPlatformIntegration) { - m_surfacesMutex.lock(); + QMutexLocker lock(&m_surfacesMutex); m_androidPlatformIntegration = androidPlatformIntegration; - m_surfacesMutex.unlock(); + + // flush the pending state if necessary. + if (m_androidPlatformIntegration) { + flushPendingApplicationState(); + } else { + QMutexLocker locker(&m_pendingAppStateMtx); + m_pendingApplicationState = -1; + } } QAndroidPlatformIntegration *androidPlatformIntegration() @@ -215,12 +224,6 @@ namespace QtAndroid m_statusBarShowing = false; } - void setApplicationActive() - { - if (m_activityActive) - QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationActive); - } - jobject createBitmap(QImage img, JNIEnv *env) { if (!m_bitmapClass) @@ -446,6 +449,16 @@ namespace QtAndroid } // namespace QtAndroid +// Force an update of the pending application state (state set before the platform plugin was created) +static void flushPendingApplicationState() +{ + QMutexLocker locker(&m_pendingAppStateMtx); + if (m_pendingApplicationState == -1) + return; + + QWindowSystemInterface::handleApplicationStateChanged(Qt::ApplicationState(m_pendingApplicationState)); + m_pendingApplicationState = -1; +} static jboolean startQtAndroidPlugin(JNIEnv* /*env*/, jobject /*object*//*, jobject applicationAssetManager*/) { @@ -655,13 +668,14 @@ static void updateWindow(JNIEnv */*env*/, jobject /*thiz*/) static void updateApplicationState(JNIEnv */*env*/, jobject /*thiz*/, jint state) { - m_activityActive = (state == Qt::ApplicationActive); - - if (!m_main || !m_androidPlatformIntegration || !QGuiApplicationPrivate::platformIntegration()) { - QAndroidPlatformIntegration::setDefaultApplicationState(Qt::ApplicationState(state)); + if (!m_main || !QtAndroid::androidPlatformIntegration()) { + QMutexLocker locker(&m_pendingAppStateMtx); + m_pendingApplicationState = Qt::ApplicationState(state); return; } + flushPendingApplicationState(); + if (state == Qt::ApplicationActive) QtAndroidPrivate::handleResume(); else if (state == Qt::ApplicationInactive) diff --git a/src/plugins/platforms/android/androidjnimain.h b/src/plugins/platforms/android/androidjnimain.h index 218e52ccc1..170596082d 100644 --- a/src/plugins/platforms/android/androidjnimain.h +++ b/src/plugins/platforms/android/androidjnimain.h @@ -85,8 +85,6 @@ namespace QtAndroid jobject activity(); jobject service(); - void setApplicationActive(); - void showStatusBar(); void hideStatusBar(); diff --git a/src/plugins/platforms/android/qandroidplatformintegration.cpp b/src/plugins/platforms/android/qandroidplatformintegration.cpp index de9e27e595..44b4668585 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/qandroidplatformintegration.cpp @@ -80,8 +80,6 @@ int QAndroidPlatformIntegration::m_defaultPhysicalSizeHeight = 71; Qt::ScreenOrientation QAndroidPlatformIntegration::m_orientation = Qt::PrimaryOrientation; Qt::ScreenOrientation QAndroidPlatformIntegration::m_nativeOrientation = Qt::PrimaryOrientation; -Qt::ApplicationState QAndroidPlatformIntegration::m_defaultApplicationState = Qt::ApplicationActive; - bool QAndroidPlatformIntegration::m_showPasswordEnabled = false; void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteArray &resource) @@ -120,6 +118,12 @@ void *QAndroidPlatformNativeInterface::nativeResourceForIntegration(const QByteA return 0; } +void QAndroidPlatformNativeInterface::customEvent(QEvent *event) +{ + if (event->type() == QEvent::User) + QtAndroid::setAndroidPlatformIntegration(static_cast(QGuiApplicationPrivate::platformIntegration())); +} + QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶mList) : m_touchDevice(nullptr) #ifndef QT_NO_ACCESSIBILITY @@ -147,7 +151,6 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ m_primaryScreen->setAvailableGeometry(QRect(0, 0, m_defaultGeometryWidth, m_defaultGeometryHeight)); m_mainThread = QThread::currentThread(); - QtAndroid::setAndroidPlatformIntegration(this); m_androidFDB = new QAndroidPlatformFontDatabase(); m_androidPlatformServices = new QAndroidPlatformServices(); @@ -210,7 +213,9 @@ QAndroidPlatformIntegration::QAndroidPlatformIntegration(const QStringList ¶ } } - QGuiApplicationPrivate::instance()->setApplicationState(m_defaultApplicationState); + // We can't safely notify the jni bridge that we're up and running just yet, so let's postpone + // it for now. + QCoreApplication::postEvent(m_androidPlatformNativeInterface, new QEvent(QEvent::User)); } static bool needsBasicRenderloopWorkaround() diff --git a/src/plugins/platforms/android/qandroidplatformintegration.h b/src/plugins/platforms/android/qandroidplatformintegration.h index 2337801250..208bb705b7 100644 --- a/src/plugins/platforms/android/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/qandroidplatformintegration.h @@ -65,6 +65,9 @@ class QAndroidPlatformNativeInterface: public QPlatformNativeInterface public: void *nativeResourceForIntegration(const QByteArray &resource) override; std::shared_ptr m_androidStyle; + +protected: + void customEvent(QEvent *event) override; }; class QAndroidPlatformIntegration : public QPlatformIntegration @@ -121,7 +124,6 @@ public: QTouchDevice *touchDevice() const { return m_touchDevice; } void setTouchDevice(QTouchDevice *touchDevice) { m_touchDevice = touchDevice; } - static void setDefaultApplicationState(Qt::ApplicationState applicationState) { m_defaultApplicationState = applicationState; } private: EGLDisplay m_eglDisplay; @@ -140,9 +142,6 @@ private: static Qt::ScreenOrientation m_orientation; static Qt::ScreenOrientation m_nativeOrientation; - - static Qt::ApplicationState m_defaultApplicationState; - static bool m_showPasswordEnabled; QPlatformFontDatabase *m_androidFDB; diff --git a/src/plugins/platforms/android/qandroidplatformwindow.cpp b/src/plugins/platforms/android/qandroidplatformwindow.cpp index 97a1f30a35..424cfefc6c 100644 --- a/src/plugins/platforms/android/qandroidplatformwindow.cpp +++ b/src/plugins/platforms/android/qandroidplatformwindow.cpp @@ -96,11 +96,6 @@ void QAndroidPlatformWindow::setVisible(bool visible) QRect availableGeometry = screen()->availableGeometry(); if (geometry().width() > 0 && geometry().height() > 0 && availableGeometry.width() > 0 && availableGeometry.height() > 0) QPlatformWindow::setVisible(visible); - - // The Android Activity is activated before Qt is initialized, causing the application state to - // never be set to 'active'. We explicitly set this state when the first window becomes visible. - if (visible) - QtAndroid::setApplicationActive(); } void QAndroidPlatformWindow::setWindowState(Qt::WindowState state) -- cgit v1.2.3 From eca6f5492c4f32ad4e1df25ab923401dc5980c76 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 12 Apr 2017 09:47:20 +0200 Subject: Windows QPA: Move initialization of resources out of the Qt namespace Q_INIT_RESOURCE() should not be within the Qt namespace; the namespace is appended to the resource function. Task-number: QTBUG-60118 Change-Id: I05203c3196ccdcffaf27658bcd7f3ec1c25f22d9 Reviewed-by: Oliver Wolff --- src/plugins/platforms/windows/qwindowsintegration.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 316f93e3ac..31062b681d 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -88,6 +88,11 @@ #include "qwindowsopengltester.h" +static inline void initOpenGlBlacklistResources() +{ + Q_INIT_RESOURCE(openglblacklists); +} + QT_BEGIN_NAMESPACE /*! @@ -210,7 +215,7 @@ static inline unsigned parseOptions(const QStringList ¶mList, QWindowsIntegrationPrivate::QWindowsIntegrationPrivate(const QStringList ¶mList) { - Q_INIT_RESOURCE(openglblacklists); + initOpenGlBlacklistResources(); static bool dpiAwarenessSet = false; int tabletAbsoluteRange = -1; -- cgit v1.2.3 From 34d2fd14979198dc0fcc07f73581ece9540c4b72 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Sun, 16 Apr 2017 15:28:59 -0700 Subject: Fix build with libdrm >= 2.4.78 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit drmEventContext has grown by one pointer, so the build fails with an error about a member without initialization. qeglfskmsgbmdevice.cpp:147:5: error: missing initializer for member ‘_drmEventContext::page_flip_handler2’ [-Werror=missing-field-initializers] Change-Id: I0e1a09998253489388abfffd14b6014b1ddc90e1 Reviewed-by: Simon Hausmann --- .../eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp | 10 +++++----- src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp | 10 +++++----- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp index 2040d6bc0e..5f85e4b0b0 100644 --- a/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp +++ b/src/plugins/platforms/eglfs/deviceintegration/eglfs_kms/qeglfskmsgbmdevice.cpp @@ -140,11 +140,11 @@ void QEglFSKmsGbmDevice::destroyGlobalCursor() void QEglFSKmsGbmDevice::handleDrmEvent() { - drmEventContext drmEvent = { - DRM_EVENT_CONTEXT_VERSION, - Q_NULLPTR, // vblank handler - pageFlipHandler // page flip handler - }; + drmEventContext drmEvent; + memset(&drmEvent, 0, sizeof(drmEvent)); + drmEvent.version = DRM_EVENT_CONTEXT_VERSION; + drmEvent.vblank_handler = nullptr; + drmEvent.page_flip_handler = pageFlipHandler; drmHandleEvent(fd(), &drmEvent); } diff --git a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp index 2ca251c4af..c9fbb8281c 100644 --- a/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp +++ b/src/plugins/platforms/linuxfb/qlinuxfbdrmscreen.cpp @@ -312,11 +312,11 @@ void QLinuxFbDevice::swapBuffers(Output *output) const int fbIdx = output->backFb; while (output->backFb == fbIdx) { - drmEventContext drmEvent = { - DRM_EVENT_CONTEXT_VERSION, - nullptr, - pageFlipHandler - }; + drmEventContext drmEvent; + memset(&drmEvent, 0, sizeof(drmEvent)); + drmEvent.version = DRM_EVENT_CONTEXT_VERSION; + drmEvent.vblank_handler = nullptr; + drmEvent.page_flip_handler = pageFlipHandler; // Blocks until there is something to read on the drm fd // and calls back pageFlipHandler once the flip completes. drmHandleEvent(fd(), &drmEvent); -- cgit v1.2.3 From ad0249cc793772a342bf6ced40fb44cd52b2b0e6 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Tue, 18 Apr 2017 12:47:21 +0200 Subject: winrt: Fix QKeyEvent::isAutoRepeat CorePhysicalKeyStatus::KeyStatus does not give the information we are after so we have to keep track of "auto repeat" state of the keys ourself. Task-number: QTBUG-59232 Change-Id: I22aa185780e5fa1f7f3c23c2deb2a0dde0c4a582 Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index edfcf038d7..3a4c3b871c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -101,22 +101,26 @@ QT_BEGIN_NAMESPACE struct KeyInfo { KeyInfo() : virtualKey(0) + , isAutoRepeat(false) { } KeyInfo(const QString &text, quint32 virtualKey) : text(text) , virtualKey(virtualKey) + , isAutoRepeat(false) { } KeyInfo(quint32 virtualKey) : virtualKey(virtualKey) + , isAutoRepeat(false) { } QString text; quint32 virtualKey; + bool isAutoRepeat; }; static inline Qt::ScreenOrientations qtOrientationsFromNative(DisplayOrientations native) @@ -971,6 +975,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind if (!shouldAutoRepeat(key)) return S_OK; + d->activeKeys[key].isAutoRepeat = true; // If the key was pressed before trigger a key release before the next key press QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), @@ -981,7 +986,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind virtualKey, 0, QString(), - status.WasKeyDown, + d->activeKeys.value(key).isAutoRepeat, !status.RepeatCount ? 1 : status.RepeatCount, false); } else { @@ -1001,7 +1006,7 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind virtualKey, 0, QString(), - status.WasKeyDown, + d->activeKeys.value(key).isAutoRepeat, !status.RepeatCount ? 1 : status.RepeatCount, false); return S_OK; @@ -1051,20 +1056,19 @@ HRESULT QWinRTScreen::onCharacterReceived(ICoreWindow *, ICharacterReceivedEvent const Qt::KeyboardModifiers modifiers = keyboardModifiers(); const Qt::Key key = qKeyFromCode(keyCode, modifiers); const QString text = QChar(keyCode); - const quint32 virtualKey = d->activeKeys.value(key).virtualKey; + const KeyInfo info = d->activeKeys.value(key); QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), QEvent::KeyPress, key, modifiers, !status.ScanCode ? -1 : status.ScanCode, - virtualKey, + info.virtualKey, 0, text, - status.WasKeyDown, + info.isAutoRepeat, !status.RepeatCount ? 1 : status.RepeatCount, false); - d->activeKeys.insert(key, KeyInfo(text, virtualKey)); return S_OK; } -- cgit v1.2.3 From 32b92b9e21a7a684fa9c23b881cda5b913699574 Mon Sep 17 00:00:00 2001 From: Oliver Wolff Date: Wed, 19 Apr 2017 08:29:36 +0200 Subject: winrt: Fix keyboard modifier states CoreWindow::GetAsyncKeyState returns flags and not enums so checking equality does not give the needed result. As seen in qwindowskeymapper.cpp key events that only contain a modifier key should not have the key itself as a modifier when calling handleExtendedKeyEvent. With the current approach the modifier states are the same as on desktop Windows. Task-number: QTBUG-58750 Change-Id: Ie0f3e1d3e8294e1a6b41c9223a7a5153306579f6 Reviewed-by: Maurice Kalinowski --- src/plugins/platforms/winrt/qwinrtscreen.cpp | 37 +++++++++++++++++++--------- 1 file changed, 26 insertions(+), 11 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 3a4c3b871c..7ac4bdac6c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -685,21 +685,26 @@ Qt::KeyboardModifiers QWinRTScreen::keyboardModifiers() const Qt::KeyboardModifiers mods; CoreVirtualKeyStates mod; - d->coreWindow->GetAsyncKeyState(VirtualKey_Shift, &mod); - if (mod == CoreVirtualKeyStates_Down) + HRESULT hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Shift, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::ShiftModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_Menu, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Menu, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::AltModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_Control, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_Control, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::ControlModifier; - d->coreWindow->GetAsyncKeyState(VirtualKey_LeftWindows, &mod); - if (mod == CoreVirtualKeyStates_Down) { + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_LeftWindows, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) { mods |= Qt::MetaModifier; } else { - d->coreWindow->GetAsyncKeyState(VirtualKey_RightWindows, &mod); - if (mod == CoreVirtualKeyStates_Down) + hr = d->coreWindow->GetAsyncKeyState(VirtualKey_RightWindows, &mod); + Q_ASSERT_SUCCEEDED(hr); + if (mod & CoreVirtualKeyStates_Down) mods |= Qt::MetaModifier; } return mods; @@ -997,11 +1002,21 @@ HRESULT QWinRTScreen::onKeyDown(ABI::Windows::UI::Core::ICoreWindow *, ABI::Wind if (key == Qt::Key_unknown || (key >= Qt::Key_Space && key <= Qt::Key_ydiaeresis)) return S_OK; + Qt::KeyboardModifiers modifiers = keyboardModifiers(); + // If the key actually pressed is a modifier key, then we remove its modifier key from the + // state, since a modifier-key can't have itself as a modifier (see qwindowskeymapper.cpp) + if (key == Qt::Key_Control) + modifiers = modifiers ^ Qt::ControlModifier; + else if (key == Qt::Key_Shift) + modifiers = modifiers ^ Qt::ShiftModifier; + else if (key == Qt::Key_Alt) + modifiers = modifiers ^ Qt::AltModifier; + QWindowSystemInterface::handleExtendedKeyEvent( topWindow(), QEvent::KeyPress, key, - keyboardModifiers(), + modifiers, !status.ScanCode ? -1 : status.ScanCode, virtualKey, 0, -- cgit v1.2.3 From f368cd88687643d565763602721cae6e9602e34d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 27 Mar 2017 18:49:10 +0200 Subject: macOS: Initialize window geometry early on, instead of when creating NSWindow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We don't need to defer to NSWindow creation before determining the initial window geometry, and we don't need to redetermine each time we re-create an NSWindow for a QCocoaWindow. Change-Id: Ie13380830b44e96670ff16513f29deef5f5ae313 Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoawindow.mm | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src/plugins/platforms') diff --git a/src/plugins/platforms/cocoa/qcocoawindow.mm b/src/plugins/platforms/cocoa/qcocoawindow.mm index e9bcaa8f41..b453da818f 100644 --- a/src/plugins/platforms/cocoa/qcocoawindow.mm +++ b/src/plugins/platforms/cocoa/qcocoawindow.mm @@ -491,7 +491,9 @@ QCocoaWindow::QCocoaWindow(QWindow *tlw, WId nativeHandle) "QT_MAC_WANTS_LAYER"); [m_view setWantsLayer:enable]; } - setGeometry(tlw->geometry()); + + setGeometry(initialGeometry(window(), windowGeometry(), defaultWindowWidth, defaultWindowHeight)); + recreateWindowIfNeeded(); tlw->setGeometry(geometry()); if (tlw->isTopLevel()) @@ -1721,7 +1723,7 @@ QCocoaNSWindow *QCocoaWindow::createNSWindow(bool shouldBeChildNSWindow, bool sh { QMacAutoReleasePool pool; - QRect rect = initialGeometry(window(), windowGeometry(), defaultWindowWidth, defaultWindowHeight); + QRect rect = geometry(); QScreen *targetScreen = nullptr; for (QScreen *screen : QGuiApplication::screens()) { -- cgit v1.2.3