diff options
Diffstat (limited to 'src/plugins/platforms')
29 files changed, 274 insertions, 407 deletions
diff --git a/src/plugins/platforms/cocoa/qnsview.h b/src/plugins/platforms/cocoa/qnsview.h index be7602a815..e754855e7f 100644 --- a/src/plugins/platforms/cocoa/qnsview.h +++ b/src/plugins/platforms/cocoa/qnsview.h @@ -75,6 +75,7 @@ Q_FORWARD_DECLARE_OBJC_CLASS(QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper)); QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) *m_mouseMoveHelper; bool m_resendKeyEvent; bool m_scrolling; + bool m_updatingDrag; bool m_exposedOnMoveToWindow; NSEvent *m_currentlyInterpretedKeyEvent; bool m_isMenuView; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index faa048874f..f414193bdb 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -153,6 +153,7 @@ static NSString *_q_NSWindowDidChangeOcclusionStateNotification = nil; m_mouseMoveHelper = [[QT_MANGLE_NAMESPACE(QNSViewMouseMoveHelper) alloc] initWithView:self]; m_resendKeyEvent = false; m_scrolling = false; + m_updatingDrag = false; m_currentlyInterpretedKeyEvent = 0; if (!touchDevice) { @@ -1464,8 +1465,10 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) // Popups implicitly grab key events; forward to the active popup if there is one. // This allows popups to e.g. intercept shortcuts and close the popup in response. - if (QCocoaWindow *popup = QCocoaIntegration::instance()->activePopupWindow()) - window = popup->window(); + if (QCocoaWindow *popup = QCocoaIntegration::instance()->activePopupWindow()) { + if (!popup->m_windowFlags.testFlag(Qt::ToolTip)) + window = popup->window(); + } if (eventType == QEvent::KeyPress) { @@ -1917,6 +1920,9 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin // Make sure the cursor is updated correctly if the mouse does not move and window is under cursor // by creating a fake move event + if (m_updatingDrag) + return; + const QPoint mousePos(QCursor::pos()); CGEventRef moveEvent(CGEventCreateMouseEvent( NULL, kCGEventMouseMoved, @@ -1934,7 +1940,11 @@ static QPoint mapWindowCoordinates(QWindow *source, QWindow *target, QPoint poin - (NSDragOperation)draggingUpdated:(id <NSDraggingInfo>)sender { - return [self handleDrag : sender]; + m_updatingDrag = true; + const NSDragOperation ret([self handleDrag : sender]); + m_updatingDrag = false; + + return ret; } // Sends drag update to Qt, return the action diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp index 20dde476c1..b86dfa3546 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.cpp @@ -219,12 +219,11 @@ QWindowsDirect2DIntegration::~QWindowsDirect2DIntegration() return static_cast<QWindowsDirect2DIntegration *>(QWindowsIntegration::instance()); } - QPlatformWindow *QWindowsDirect2DIntegration::createPlatformWindow(QWindow *window) const - { - QWindowsWindowData data = createWindowData(window); - return data.hwnd ? new QWindowsDirect2DWindow(window, data) - : Q_NULLPTR; - } + +QWindowsWindow *QWindowsDirect2DIntegration::createPlatformWindowHelper(QWindow *window, const QWindowsWindowData &data) const +{ + return new QWindowsDirect2DWindow(window, data); +} QPlatformNativeInterface *QWindowsDirect2DIntegration::nativeInterface() const { diff --git a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h index 6b7b3fbea2..64042cab0a 100644 --- a/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h +++ b/src/plugins/platforms/direct2d/qwindowsdirect2dintegration.h @@ -52,7 +52,6 @@ public: static QWindowsDirect2DIntegration *instance(); - QPlatformWindow *createPlatformWindow(QWindow *window) const Q_DECL_OVERRIDE; QPlatformNativeInterface *nativeInterface() const Q_DECL_OVERRIDE; QPlatformPixmap *createPlatformPixmap(QPlatformPixmap::PixelType type) const Q_DECL_OVERRIDE; QPlatformBackingStore *createPlatformBackingStore(QWindow *window) const Q_DECL_OVERRIDE; @@ -60,6 +59,9 @@ public: QWindowsDirect2DContext *direct2DContext() const; +protected: + QWindowsWindow *createPlatformWindowHelper(QWindow *window, const QWindowsWindowData &) const Q_DECL_OVERRIDE; + private: explicit QWindowsDirect2DIntegration(const QStringList ¶mList); bool init(); diff --git a/src/plugins/platforms/eglfs/eglfs_device_lib.pro b/src/plugins/platforms/eglfs/eglfs_device_lib.pro index 22a32663c7..4fe2ce4897 100644 --- a/src/plugins/platforms/eglfs/eglfs_device_lib.pro +++ b/src/plugins/platforms/eglfs/eglfs_device_lib.pro @@ -6,13 +6,6 @@ TARGET = QtEglDeviceIntegration CONFIG += no_module_headers internal_module -MODULE_INCLUDES = \ - \$\$QT_MODULE_INCLUDE_BASE \ - \$\$QT_MODULE_INCLUDE_BASE/QtQGui -MODULE_PRIVATE_INCLUDES = \ - \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION \ - \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION/QtGui - load(qt_module) QT += core-private gui-private platformsupport-private diff --git a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm index 761a89c989..bb12c164d6 100644 --- a/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm +++ b/src/plugins/platforms/ios/qiosfileengineassetslibrary.mm @@ -48,20 +48,29 @@ static QThreadStorage<QPointer<QIOSAssetData> > g_assetDataCache; static const int kBufferSize = 10; static ALAsset *kNoAsset = 0; -static void ensureAuthorizationDialogNotBlocked() +static bool ensureAuthorizationDialogNotBlocked() { if ([ALAssetsLibrary authorizationStatus] != ALAuthorizationStatusNotDetermined) - return; + return true; + if (static_cast<QCoreApplicationPrivate *>(QObjectPrivate::get(qApp))->in_exec) - return; - - // Since authorization status has not been determined, the user will be asked - // to authorize the app. But since main has not finished, the dialog will be held - // back until the launch completes. To avoid a dead-lock below, we start an event - // loop to complete the launch. - QEventLoop loop; - QTimer::singleShot(1, &loop, &QEventLoop::quit); - loop.exec(); + return true; + + if ([NSThread isMainThread]) { + // The dialog is about to show, but since main has not finished, the dialog will be held + // back until the launch completes. This is problematic since we cannot successfully return + // back to the caller before the asset is ready, which also includes showing the dialog. To + // work around this, we create an event loop to that will complete the launch (return from the + // applicationDidFinishLaunching callback). But this will only work if we're on the main thread. + QEventLoop loop; + QTimer::singleShot(1, &loop, &QEventLoop::quit); + loop.exec(); + } else { + NSLog(@"QIOSFileEngine: unable to show assets authorization dialog from non-gui thread before QApplication is executing."); + return false; + } + + return true; } // ------------------------------------------------------------------------- @@ -80,8 +89,10 @@ public: , m_writeIndex(0) , m_nextAssetReady(false) { - ensureAuthorizationDialogNotBlocked(); - startEnumerate(); + if (!ensureAuthorizationDialogNotBlocked()) + writeAsset(kNoAsset); + else + startEnumerate(); } ~QIOSAssetEnumerator() @@ -186,7 +197,8 @@ public: , m_assetUrl(assetUrl) , m_assetLibrary(0) { - ensureAuthorizationDialogNotBlocked(); + if (!ensureAuthorizationDialogNotBlocked()) + return; if (QIOSAssetData *assetData = g_assetDataCache.localData()) { // It's a common pattern that QFiles pointing to the same path are created and destroyed diff --git a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp index ef96985f1a..1bcb22618e 100644 --- a/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp +++ b/src/plugins/platforms/minimalegl/qminimaleglintegration.cpp @@ -37,7 +37,15 @@ #include "qminimaleglbackingstore.h" #include <QtPlatformSupport/private/qgenericunixfontdatabase_p.h> -#include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> + +#if defined(Q_OS_UNIX) +# include <QtPlatformSupport/private/qgenericunixeventdispatcher_p.h> +#elif defined(Q_OS_WINRT) +# include <QtCore/private/qeventdispatcher_winrt_p.h> +# include <QtGui/qpa/qwindowsysteminterface.h> +#elif defined(Q_OS_WIN) +# include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h> +#endif #include <qpa/qplatformwindow.h> #include <QtGui/QSurfaceFormat> @@ -48,6 +56,29 @@ QT_BEGIN_NAMESPACE +#ifdef Q_OS_WINRT +namespace { +class QWinRTEventDispatcher : public QEventDispatcherWinRT { +public: + QWinRTEventDispatcher() {} + +protected: + bool hasPendingEvents() Q_DECL_OVERRIDE + { + return QEventDispatcherWinRT::hasPendingEvents() || QWindowSystemInterface::windowSystemEventsQueued(); + } + + bool sendPostedEvents(QEventLoop::ProcessEventsFlags flags) + { + bool didProcess = QEventDispatcherWinRT::sendPostedEvents(flags); + if (!(flags & QEventLoop::ExcludeUserInputEvents)) + didProcess |= QWindowSystemInterface::sendWindowSystemEvents(flags); + return didProcess; + } +}; +} // anonymous namespace +#endif // Q_OS_WINRT + QMinimalEglIntegration::QMinimalEglIntegration() : mFontDb(new QGenericUnixFontDatabase()), mScreen(new QMinimalEglScreen(EGL_DEFAULT_DISPLAY)) { @@ -104,7 +135,15 @@ QPlatformFontDatabase *QMinimalEglIntegration::fontDatabase() const QAbstractEventDispatcher *QMinimalEglIntegration::createEventDispatcher() const { +#if defined(Q_OS_UNIX) return createUnixEventDispatcher(); +#elif defined(Q_OS_WINRT) + return new QWinRTEventDispatcher; +#elif defined(Q_OS_WIN) + return new QWindowsGuiEventDispatcher; +#else + return Q_NULLPTR; +#endif } QVariant QMinimalEglIntegration::styleHint(QPlatformIntegration::StyleHint hint) const diff --git a/src/plugins/platforms/windows/openglblacklists/default.json b/src/plugins/platforms/windows/openglblacklists/default.json index 5d8bd56a1e..a5d42719a9 100644 --- a/src/plugins/platforms/windows/openglblacklists/default.json +++ b/src/plugins/platforms/windows/openglblacklists/default.json @@ -47,7 +47,7 @@ "id": 4, "description": "Intel HD Graphics 3000 crashes when initializing the OpenGL driver (QTBUG-42240)", "vendor_id": "0x8086", - "device_id": [ "0x0102", "0x0116" ], + "device_id": [ "0x0102", "0x0106", "0x010A", "0x0112", "0x0116", "0x0122", "0x0126" ], "os": { "type": "win" }, diff --git a/src/plugins/platforms/windows/qwindowsclipboard.cpp b/src/plugins/platforms/windows/qwindowsclipboard.cpp index 8936b96b1f..25cfd12b44 100644 --- a/src/plugins/platforms/windows/qwindowsclipboard.cpp +++ b/src/plugins/platforms/windows/qwindowsclipboard.cpp @@ -35,7 +35,6 @@ #include "qwindowscontext.h" #include "qwindowsole.h" #include "qwindowsmime.h" -#include "qwindowsguieventdispatcher.h" #include <QtGui/QGuiApplication> #include <QtGui/QClipboard> @@ -48,6 +47,8 @@ #include <QtCore/QVariant> #include <QtCore/QUrl> +#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h> + QT_BEGIN_NAMESPACE static const char formatTextPlainC[] = "text/plain"; diff --git a/src/plugins/platforms/windows/qwindowscontext.cpp b/src/plugins/platforms/windows/qwindowscontext.cpp index 02accfae01..5cda6379de 100644 --- a/src/plugins/platforms/windows/qwindowscontext.cpp +++ b/src/plugins/platforms/windows/qwindowscontext.cpp @@ -36,7 +36,6 @@ #include "qwindowsintegration.h" #include "qwindowswindow.h" #include "qwindowskeymapper.h" -#include "qwindowsguieventdispatcher.h" #include "qwindowsmousehandler.h" #include "qtwindowsglobal.h" #include "qwindowsmime.h" @@ -66,6 +65,8 @@ #include <QtCore/QScopedArrayPointer> #include <QtCore/private/qsystemlibrary_p.h> +#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h> + #include <stdlib.h> #include <stdio.h> #include <windowsx.h> diff --git a/src/plugins/platforms/windows/qwindowseglcontext.cpp b/src/plugins/platforms/windows/qwindowseglcontext.cpp index 02073f5098..21eba6da7e 100644 --- a/src/plugins/platforms/windows/qwindowseglcontext.cpp +++ b/src/plugins/platforms/windows/qwindowseglcontext.cpp @@ -39,7 +39,7 @@ #include <QtGui/QOpenGLContext> #if defined(QT_OPENGL_ES_2_ANGLE) || defined(QT_OPENGL_DYNAMIC) -# include <QtANGLE/EGL/eglext.h> +# include <EGL/eglext.h> #endif QT_BEGIN_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp b/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp deleted file mode 100644 index 0bfa0239aa..0000000000 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Samuel Gaist <samuel.gaist@edeltech.ch> -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qwindowsguieventdispatcher.h" -#include "qwindowscontext.h" - -#include <qpa/qwindowsysteminterface.h> - -#include <QtCore/QCoreApplication> -#include <QtCore/QStack> -#include <QtCore/QDebug> - -#include <windowsx.h> - -QT_BEGIN_NAMESPACE - -/*! - \class QWindowsGuiEventDispatcher - \brief Event dispatcher for Windows - - Maintains a global stack storing the current event dispatcher and - its processing flags for access from the Windows procedure - qWindowsWndProc. Handling the Lighthouse gui events should be done - from within the qWindowsWndProc to ensure correct processing of messages. - - \internal - \ingroup qt-lighthouse-win -*/ - -QWindowsGuiEventDispatcher::QWindowsGuiEventDispatcher(QObject *parent) : - QEventDispatcherWin32(parent), m_flags(0) -{ - setObjectName(QStringLiteral("QWindowsGuiEventDispatcher")); - createInternalHwnd(); // QTBUG-40881: Do not delay registering timers, etc. for QtMfc. -} - -bool QWindowsGuiEventDispatcher::processEvents(QEventLoop::ProcessEventsFlags flags) -{ - const QEventLoop::ProcessEventsFlags oldFlags = m_flags; - m_flags = flags; - if (QWindowsContext::verbose > 2 && lcQpaEvents().isDebugEnabled()) - qCDebug(lcQpaEvents) << '>' << __FUNCTION__ << objectName() << flags; - const bool rc = QEventDispatcherWin32::processEvents(flags); - if (QWindowsContext::verbose > 2 && lcQpaEvents().isDebugEnabled()) - qCDebug(lcQpaEvents) << '<' << __FUNCTION__ << "returns" << rc; - m_flags = oldFlags; - return rc; -} - -void QWindowsGuiEventDispatcher::sendPostedEvents() -{ - QEventDispatcherWin32::sendPostedEvents(); - QWindowSystemInterface::sendWindowSystemEvents(m_flags); -} - -// Helpers for printing debug output for WM_* messages. -struct MessageDebugEntry -{ - UINT message; - const char *description; - bool interesting; -}; - -static const MessageDebugEntry -messageDebugEntries[] = { - {WM_CREATE, "WM_CREATE", true}, - {WM_PAINT, "WM_PAINT", true}, - {WM_CLOSE, "WM_CLOSE", true}, - {WM_DESTROY, "WM_DESTROY", true}, - {WM_MOVE, "WM_MOVE", true}, - {WM_SIZE, "WM_SIZE", true}, - {WM_MOUSEACTIVATE,"WM_MOUSEACTIVATE", true}, - {WM_CHILDACTIVATE, "WM_CHILDACTIVATE", true}, - {WM_PARENTNOTIFY, "WM_PARENTNOTIFY", true}, - {WM_ENTERIDLE, "WM_ENTERIDLE", false}, - {WM_GETICON, "WM_GETICON", false}, - {WM_KEYDOWN, "WM_KEYDOWN", true}, - {WM_SYSKEYDOWN, "WM_SYSKEYDOWN", true}, - {WM_SYSCOMMAND, "WM_SYSCOMMAND", true}, - {WM_KEYUP, "WM_KEYUP", true}, - {WM_SYSKEYUP, "WM_SYSKEYUP", true}, -#if defined(WM_APPCOMMAND) - {WM_APPCOMMAND, "WM_APPCOMMAND", true}, -#endif - {WM_IME_CHAR, "WM_IMECHAR", true}, - {WM_IME_KEYDOWN, "WM_IMECHAR", true}, - {WM_CANCELMODE, "WM_CANCELMODE", true}, - {WM_CHAR, "WM_CHAR", true}, - {WM_DEADCHAR, "WM_DEADCHAR", true}, - {WM_ACTIVATE, "WM_ACTIVATE", true}, - {WM_GETMINMAXINFO, "WM_GETMINMAXINFO", true}, - {WM_SETFOCUS, "WM_SETFOCUS", true}, - {WM_KILLFOCUS, "WM_KILLFOCUS", true}, - {WM_ENABLE, "WM_ENABLE", true}, - {WM_SHOWWINDOW, "WM_SHOWWINDOW", true}, - {WM_WINDOWPOSCHANGING, "WM_WINDOWPOSCHANGING", true}, - {WM_WINDOWPOSCHANGED, "WM_WINDOWPOSCHANGED", true}, - {WM_SETCURSOR, "WM_SETCURSOR", false}, - {WM_GETFONT, "WM_GETFONT", true}, - {WM_NCMOUSEMOVE, "WM_NCMOUSEMOVE", true}, - {WM_LBUTTONDOWN, "WM_LBUTTONDOWN", true}, - {WM_LBUTTONUP, "WM_LBUTTONUP", true}, - {WM_LBUTTONDBLCLK, "WM_LBUTTONDBLCLK", true}, - {WM_RBUTTONDOWN, "WM_RBUTTONDOWN", true}, - {WM_RBUTTONUP, "WM_RBUTTONUP", true}, - {WM_RBUTTONDBLCLK, "WM_RBUTTONDBLCLK", true}, - {WM_MBUTTONDOWN, "WM_MBUTTONDOWN", true}, - {WM_MBUTTONUP, "WM_MBUTTONUP", true}, - {WM_MBUTTONDBLCLK, "WM_MBUTTONDBLCLK", true}, - {WM_MOUSEWHEEL, "WM_MOUSEWHEEL", true}, - {WM_XBUTTONDOWN, "WM_XBUTTONDOWN", true}, - {WM_XBUTTONUP, "WM_XBUTTONUP", true}, - {WM_XBUTTONDBLCLK, "WM_XBUTTONDBLCLK", true}, - {WM_MOUSEHWHEEL, "WM_MOUSEHWHEEL", true}, - {WM_NCCREATE, "WM_NCCREATE", true}, - {WM_NCCALCSIZE, "WM_NCCALCSIZE", true}, - {WM_NCACTIVATE, "WM_NCACTIVATE", true}, - {WM_NCMOUSELEAVE, "WM_NCMOUSELEAVE", true}, - {WM_NCLBUTTONDOWN, "WM_NCLBUTTONDOWN", true}, - {WM_NCLBUTTONUP, "WM_NCLBUTTONUP", true}, - {WM_ACTIVATEAPP, "WM_ACTIVATEAPP", true}, - {WM_NCPAINT, "WM_NCPAINT", true}, - {WM_ERASEBKGND, "WM_ERASEBKGND", true}, - {WM_MOUSEMOVE, "WM_MOUSEMOVE", true}, - {WM_MOUSELEAVE, "WM_MOUSELEAVE", true}, - {WM_NCHITTEST, "WM_NCHITTEST", false}, - {WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true}, - {WM_INPUTLANGCHANGE, "WM_INPUTLANGCHANGE", true}, - {WM_IME_NOTIFY, "WM_IME_NOTIFY", true}, -#if defined(WM_DWMNCRENDERINGCHANGED) - {WM_DWMNCRENDERINGCHANGED, "WM_DWMNCRENDERINGCHANGED", true}, -#endif - {WM_IME_SETCONTEXT, "WM_IME_SETCONTEXT", true}, - {WM_IME_NOTIFY, "WM_IME_NOTIFY", true}, - {WM_TOUCH, "WM_TOUCH", true}, - {WM_CHANGECBCHAIN, "WM_CHANGECBCHAIN", true}, - {WM_DRAWCLIPBOARD, "WM_DRAWCLIPBOARD", true}, - {WM_RENDERFORMAT, "WM_RENDERFORMAT", true}, - {WM_RENDERALLFORMATS, "WM_RENDERALLFORMATS", true}, - {WM_DESTROYCLIPBOARD, "WM_DESTROYCLIPBOARD", true}, - {WM_CAPTURECHANGED, "WM_CAPTURECHANGED", true}, - {WM_IME_STARTCOMPOSITION, "WM_IME_STARTCOMPOSITION", true}, - {WM_IME_COMPOSITION, "WM_IME_COMPOSITION", true}, - {WM_IME_ENDCOMPOSITION, "WM_IME_ENDCOMPOSITION", true}, - {WM_IME_NOTIFY, "WM_IME_NOTIFY", true}, - {WM_IME_REQUEST, "WM_IME_REQUEST", true}, -#if !defined(Q_OS_WINCE) && !defined(QT_NO_SESSIONMANAGER) - {WM_QUERYENDSESSION, "WM_QUERYENDSESSION", true}, - {WM_ENDSESSION, "WM_ENDSESSION", true}, -#endif - {WM_DISPLAYCHANGE, "WM_DISPLAYCHANGE", true}, - {WM_THEMECHANGED, "WM_THEMECHANGED", true} -}; - -static inline const MessageDebugEntry *messageDebugEntry(UINT msg) -{ - for (size_t i = 0; i < sizeof(messageDebugEntries)/sizeof(MessageDebugEntry); i++) - if (messageDebugEntries[i].message == msg) - return messageDebugEntries + i; - return 0; -} - -const char *QWindowsGuiEventDispatcher::windowsMessageName(UINT msg) -{ - if (const MessageDebugEntry *e = messageDebugEntry(msg)) - return e->description; - return "Unknown"; -} - -QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowsguieventdispatcher.h b/src/plugins/platforms/windows/qwindowsguieventdispatcher.h deleted file mode 100644 index 3389139461..0000000000 --- a/src/plugins/platforms/windows/qwindowsguieventdispatcher.h +++ /dev/null @@ -1,60 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL21$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 or version 3 as published by the Free -** Software Foundation and appearing in the file LICENSE.LGPLv21 and -** LICENSE.LGPLv3 included in the packaging of this file. Please review the -** following information to ensure the GNU Lesser General Public License -** requirements will be met: https://www.gnu.org/licenses/lgpl.html and -** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** As a special exception, The Qt Company gives you certain additional -** rights. These rights are described in The Qt Company LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QWINDOWSGUIEVENTDISPATCHER_H -#define QWINDOWSGUIEVENTDISPATCHER_H - -#include "qtwindows_additional.h" - -#include <QtCore/private/qeventdispatcher_win_p.h> - -QT_BEGIN_NAMESPACE - -class QWindowsGuiEventDispatcher : public QEventDispatcherWin32 -{ - Q_OBJECT -public: - explicit QWindowsGuiEventDispatcher(QObject *parent = 0); - - static const char *windowsMessageName(UINT msg); - - bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) Q_DECL_OVERRIDE; - void sendPostedEvents() Q_DECL_OVERRIDE; - -private: - QEventLoop::ProcessEventsFlags m_flags; -}; - -QT_END_NAMESPACE - -#endif // QWINDOWSGUIEVENTDISPATCHER_H diff --git a/src/plugins/platforms/windows/qwindowsintegration.cpp b/src/plugins/platforms/windows/qwindowsintegration.cpp index 2f61baa8a1..81525775c6 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.cpp +++ b/src/plugins/platforms/windows/qwindowsintegration.cpp @@ -44,7 +44,6 @@ # include "qwindowsfontdatabase_ft.h" #endif #include "qwindowsfontdatabase.h" -#include "qwindowsguieventdispatcher.h" #ifndef QT_NO_CLIPBOARD # include "qwindowsclipboard.h" # ifndef QT_NO_DRAGANDDROP @@ -67,7 +66,8 @@ #include <QtGui/private/qhighdpiscaling_p.h> #include <QtGui/qpa/qplatforminputcontextfactory_p.h> -#include <QtCore/private/qeventdispatcher_win_p.h> +#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h> + #include <QtCore/QDebug> #include <QtCore/QVariant> @@ -291,7 +291,7 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co return false; } -QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const +QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const { QWindowsWindowData requested; requested.flags = window->flags(); @@ -310,22 +310,30 @@ QWindowsWindowData QWindowsIntegration::createWindowData(QWindow *window) const << "\n Obtained : " << obtained.geometry << " margins=" << obtained.frame << " handle=" << obtained.hwnd << ' ' << obtained.flags << '\n'; - if (obtained.hwnd) { - if (requested.flags != obtained.flags) - window->setFlags(obtained.flags); - // Trigger geometry change signals of QWindow. - if ((obtained.flags & Qt::Desktop) != Qt::Desktop && requested.geometry != obtained.geometry) + if (Q_UNLIKELY(!obtained.hwnd)) + return Q_NULLPTR; + + QWindowsWindow *result = createPlatformWindowHelper(window, obtained); + Q_ASSERT(result); + + if (requested.flags != obtained.flags) + window->setFlags(obtained.flags); + // Trigger geometry/screen change signals of QWindow. + if ((obtained.flags & Qt::Desktop) != Qt::Desktop) { + if (requested.geometry != obtained.geometry) QWindowSystemInterface::handleGeometryChange(window, obtained.geometry); + QPlatformScreen *screen = result->screenForGeometry(obtained.geometry); + if (screen && result->screen() != screen) + QWindowSystemInterface::handleWindowScreenChanged(window, screen->screen()); } - return obtained; + return result; } -QPlatformWindow *QWindowsIntegration::createPlatformWindow(QWindow *window) const +// Overridden to return a QWindowsDirect2DWindow in Direct2D plugin. +QWindowsWindow *QWindowsIntegration::createPlatformWindowHelper(QWindow *window, const QWindowsWindowData &data) const { - QWindowsWindowData data = createWindowData(window); - return data.hwnd ? new QWindowsWindow(window, data) - : Q_NULLPTR; + return new QWindowsWindow(window, data); } #ifndef QT_NO_OPENGL diff --git a/src/plugins/platforms/windows/qwindowsintegration.h b/src/plugins/platforms/windows/qwindowsintegration.h index fa5192ba03..cb10bf08f5 100644 --- a/src/plugins/platforms/windows/qwindowsintegration.h +++ b/src/plugins/platforms/windows/qwindowsintegration.h @@ -62,7 +62,6 @@ public: bool hasCapability(QPlatformIntegration::Capability cap) const; - QWindowsWindowData createWindowData(QWindow *window) const; QPlatformWindow *createPlatformWindow(QWindow *window) const; #ifndef QT_NO_OPENGL QPlatformOpenGLContext *createPlatformOpenGLContext(QOpenGLContext *context) const Q_DECL_OVERRIDE; @@ -101,6 +100,9 @@ public: QPlatformSessionManager *createPlatformSessionManager(const QString &id, const QString &key) const Q_DECL_OVERRIDE; #endif +protected: + virtual QWindowsWindow *createPlatformWindowHelper(QWindow *window, const QWindowsWindowData &) const; + private: QScopedPointer<QWindowsIntegrationPrivate> d; diff --git a/src/plugins/platforms/windows/qwindowskeymapper.cpp b/src/plugins/platforms/windows/qwindowskeymapper.cpp index f8e2ded228..4c0b94e6e7 100644 --- a/src/plugins/platforms/windows/qwindowskeymapper.cpp +++ b/src/plugins/platforms/windows/qwindowskeymapper.cpp @@ -35,7 +35,6 @@ #include "qwindowscontext.h" #include "qwindowsintegration.h" #include "qwindowswindow.h" -#include "qwindowsguieventdispatcher.h" #include "qwindowsinputcontext.h" #include <QtGui/QWindow> @@ -43,6 +42,7 @@ #include <private/qguiapplication_p.h> #include <private/qhighdpiscaling_p.h> #include <QtGui/QKeyEvent> +#include <QtPlatformSupport/private/qwindowsguieventdispatcher_p.h> #if defined(WM_APPCOMMAND) # ifndef FAPPCOMMAND_MOUSE diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 583d3a4267..40d7a3f076 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -143,6 +143,8 @@ public: QWindowsWindow(QWindow *window, const QWindowsWindowData &data); ~QWindowsWindow(); + using QPlatformWindow::screenForGeometry; + QSurfaceFormat format() const Q_DECL_OVERRIDE { return m_format; } void setGeometry(const QRect &rect) Q_DECL_OVERRIDE; QRect geometry() const Q_DECL_OVERRIDE { return m_data.geometry; } diff --git a/src/plugins/platforms/windows/windows.pri b/src/plugins/platforms/windows/windows.pri index 6e5789a86e..29297116da 100644 --- a/src/plugins/platforms/windows/windows.pri +++ b/src/plugins/platforms/windows/windows.pri @@ -29,7 +29,6 @@ SOURCES += \ $$PWD/qwindowsfontengine.cpp \ $$PWD/qwindowsfontdatabase.cpp \ $$PWD/qwindowsmousehandler.cpp \ - $$PWD/qwindowsguieventdispatcher.cpp \ $$PWD/qwindowsole.cpp \ $$PWD/qwindowsmime.cpp \ $$PWD/qwindowsinternalmimedata.cpp \ @@ -51,7 +50,6 @@ HEADERS += \ $$PWD/qwindowsfontengine.h \ $$PWD/qwindowsfontdatabase.h \ $$PWD/qwindowsmousehandler.h \ - $$PWD/qwindowsguieventdispatcher.h \ $$PWD/qtwindowsglobal.h \ $$PWD/qtwindows_additional.h \ $$PWD/qwindowsole.h \ diff --git a/src/plugins/platforms/winrt/qwinrtcursor.cpp b/src/plugins/platforms/winrt/qwinrtcursor.cpp index 707f3bf0ba..1a511f103f 100644 --- a/src/plugins/platforms/winrt/qwinrtcursor.cpp +++ b/src/plugins/platforms/winrt/qwinrtcursor.cpp @@ -161,15 +161,19 @@ void QWinRTCursor::changeCursor(QCursor *windowCursor, QWindow *window) QPoint QWinRTCursor::pos() const { - ICoreWindow *coreWindow = - static_cast<QWinRTScreen *>(QGuiApplication::primaryScreen()->handle())->coreWindow(); - HRESULT hr; + const QWinRTScreen *screen = static_cast<QWinRTScreen *>(QGuiApplication::primaryScreen()->handle()); + Q_ASSERT(screen); + ICoreWindow *coreWindow = screen->coreWindow(); + Q_ASSERT(coreWindow); Point point; - hr = QEventDispatcherWinRT::runOnXamlThread([coreWindow, &point]() { + HRESULT hr = QEventDispatcherWinRT::runOnXamlThread([coreWindow, &point]() { return coreWindow->get_PointerPosition(&point); }); - RETURN_IF_FAILED("Failed to get native cursor position", QPoint()); - return QPoint(point.X, point.Y); + Q_ASSERT_SUCCEEDED(hr); + const QPoint position = QPoint(point.X, point.Y) * screen->scaleFactor(); + // If no cursor get_PointerPosition returns SHRT_MIN for x and y + return position.x() == SHRT_MIN && position.y() == SHRT_MIN || FAILED(hr) ? QPointF(Q_INFINITY, Q_INFINITY).toPoint() + : position; } QT_END_NAMESPACE diff --git a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp index 05b1fd76b1..b0f377147e 100644 --- a/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp +++ b/src/plugins/platforms/winrt/qwinrtfiledialoghelper.cpp @@ -239,20 +239,24 @@ static bool pickFiles(IFileOpenPicker *picker, QWinRTFileDialogHelper *helper, b eventDispatcher->installEventFilter(helper); return true; #else - if (singleFile) { - ComPtr<IAsyncOperation<StorageFile *>> op; - hr = picker->PickSingleFileAsync(&op); - RETURN_FALSE_IF_FAILED("Failed to open single file picker"); - hr = op->put_Completed(Callback<SingleFileHandler>(helper, &QWinRTFileDialogHelper::onSingleFilePicked).Get()); - RETURN_FALSE_IF_FAILED("Failed to attach file picker callback"); - } else { - ComPtr<IAsyncOperation<IVectorView<StorageFile *> *>> op; - hr = picker->PickMultipleFilesAsync(&op); - RETURN_FALSE_IF_FAILED("Failed to open multi file picker"); - hr = op->put_Completed(Callback<MultipleFileHandler>(helper, &QWinRTFileDialogHelper::onMultipleFilesPicked).Get()); - RETURN_FALSE_IF_FAILED("Failed to attach multi file callback"); - } - return true; + hr = QEventDispatcherWinRT::runOnXamlThread([picker, helper, singleFile]() { + HRESULT hr; + if (singleFile) { + ComPtr<IAsyncOperation<StorageFile *>> op; + hr = picker->PickSingleFileAsync(&op); + RETURN_HR_IF_FAILED("Failed to open single file picker"); + hr = op->put_Completed(Callback<SingleFileHandler>(helper, &QWinRTFileDialogHelper::onSingleFilePicked).Get()); + RETURN_HR_IF_FAILED("Failed to attach file picker callback"); + } else { + ComPtr<IAsyncOperation<IVectorView<StorageFile *> *>> op; + hr = picker->PickMultipleFilesAsync(&op); + RETURN_HR_IF_FAILED("Failed to open multi file picker"); + hr = op->put_Completed(Callback<MultipleFileHandler>(helper, &QWinRTFileDialogHelper::onMultipleFilesPicked).Get()); + RETURN_HR_IF_FAILED("Failed to attach multi file callback"); + } + return S_OK; + }); + return SUCCEEDED(hr); #endif } @@ -274,13 +278,17 @@ static bool pickFolder(IFolderPicker *picker, QWinRTFileDialogHelper *helper) Q_ASSERT(eventDispatcher); eventDispatcher->installEventFilter(helper); #else - ComPtr<IAsyncOperation<StorageFolder *>> op; - hr = picker->PickSingleFolderAsync(&op); - RETURN_FALSE_IF_FAILED("Failed to open folder picker"); - hr = op->put_Completed(Callback<SingleFolderHandler>(helper, &QWinRTFileDialogHelper::onSingleFolderPicked).Get()); - RETURN_FALSE_IF_FAILED("Failed to attach folder picker callback"); + hr = QEventDispatcherWinRT::runOnXamlThread([picker, helper]() { + HRESULT hr; + ComPtr<IAsyncOperation<StorageFolder *>> op; + hr = picker->PickSingleFolderAsync(&op); + RETURN_HR_IF_FAILED("Failed to open folder picker"); + hr = op->put_Completed(Callback<SingleFolderHandler>(helper, &QWinRTFileDialogHelper::onSingleFolderPicked).Get()); + RETURN_HR_IF_FAILED("Failed to attach folder picker callback"); + return S_OK; + }); #endif - return true; + return SUCCEEDED(hr); } static bool pickSaveFile(IFileSavePicker *picker, QWinRTFileDialogHelper *helper) @@ -301,13 +309,17 @@ static bool pickSaveFile(IFileSavePicker *picker, QWinRTFileDialogHelper *helper Q_ASSERT(eventDispatcher); eventDispatcher->installEventFilter(helper); #else - ComPtr<IAsyncOperation<StorageFile *>> op; - hr = picker->PickSaveFileAsync(&op); - RETURN_FALSE_IF_FAILED("Failed to open save file picker"); - hr = op->put_Completed(Callback<SingleFileHandler>(helper, &QWinRTFileDialogHelper::onSingleFilePicked).Get()); - RETURN_FALSE_IF_FAILED("Failed to attach save file picker callback"); + hr = QEventDispatcherWinRT::runOnXamlThread([picker, helper]() { + HRESULT hr; + ComPtr<IAsyncOperation<StorageFile *>> op; + hr = picker->PickSaveFileAsync(&op); + RETURN_HR_IF_FAILED("Failed to open save file picker"); + hr = op->put_Completed(Callback<SingleFileHandler>(helper, &QWinRTFileDialogHelper::onSingleFilePicked).Get()); + RETURN_HR_IF_FAILED("Failed to attach save file picker callback"); + return S_OK; + }); #endif - return true; + return SUCCEEDED(hr); } class QWinRTFileDialogHelperPrivate @@ -423,7 +435,12 @@ bool QWinRTFileDialogHelper::show(Qt::WindowFlags windowFlags, Qt::WindowModalit filterTitle.length()); boolean replaced; hr = choices->Insert(namedFilterRef.Get(), entry.Get(), &replaced); - RETURN_FALSE_IF_FAILED("Failed to insert file extension choice entry"); + // Only print a warning as * or *.* is not a valid choice on Windows 10 + // but used on a regular basis on all other platforms + if (FAILED(hr)) { + qWarning("Failed to insert file extension choice entry: %s: %s", + qPrintable(filterTitle), qPrintable(qt_error_string(hr))); + } } } diff --git a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp index 750233c94f..9d8792a6db 100644 --- a/src/plugins/platforms/winrt/qwinrtinputcontext.cpp +++ b/src/plugins/platforms/winrt/qwinrtinputcontext.cpp @@ -54,6 +54,14 @@ typedef ITypedEventHandler<InputPane*, InputPaneVisibilityEventArgs*> InputPaneV QT_BEGIN_NAMESPACE +inline QRectF getInputPaneRect(IInputPane *pane, qreal scaleFactor) +{ + Rect rect; + pane->get_OccludedRect(&rect); + return QRectF(qRound(rect.X * scaleFactor), qRound(rect.Y * scaleFactor), + qRound(rect.Width * scaleFactor), qRound(rect.Height * scaleFactor)); +} + /*! \class QWinRTInputContext \brief Manages Input Method visibility @@ -87,7 +95,7 @@ QWinRTInputContext::QWinRTInputContext(QWinRTScreen *screen) inputPane->add_Hiding(Callback<InputPaneVisibilityHandler>( this, &QWinRTInputContext::onHiding).Get(), &hideToken); - handleVisibilityChange(inputPane); + m_keyboardRect = getInputPaneRect(inputPane, m_screen->scaleFactor()); m_isInputPanelVisible = !m_keyboardRect.isEmpty(); } else { qWarning(Q_FUNC_INFO ": failed to retrieve InputPane."); @@ -120,10 +128,7 @@ HRESULT QWinRTInputContext::onHiding(IInputPane *pane, IInputPaneVisibilityEvent HRESULT QWinRTInputContext::handleVisibilityChange(IInputPane *pane) { - Rect rect; - pane->get_OccludedRect(&rect); - const QRectF keyboardRect = QRectF(qRound(rect.X * m_screen->scaleFactor()), qRound(rect.Y * m_screen->scaleFactor()), - qRound(rect.Width * m_screen->scaleFactor()), qRound(rect.Height * m_screen->scaleFactor())); + const QRectF keyboardRect = getInputPaneRect(pane, m_screen->scaleFactor()); if (m_keyboardRect != keyboardRect) { m_keyboardRect = keyboardRect; emitKeyboardRectChanged(); diff --git a/src/plugins/platforms/winrt/qwinrtscreen.cpp b/src/plugins/platforms/winrt/qwinrtscreen.cpp index 8ba71d88e7..158917184c 100644 --- a/src/plugins/platforms/winrt/qwinrtscreen.cpp +++ b/src/plugins/platforms/winrt/qwinrtscreen.cpp @@ -507,11 +507,7 @@ QWinRTScreen::QWinRTScreen() hr = d->displayInformation->get_NativeOrientation(&displayOrientation); Q_ASSERT_SUCCEEDED(hr); d->nativeOrientation = static_cast<Qt::ScreenOrientation>(static_cast<int>(qtOrientationsFromNative(displayOrientation))); - - // Set initial orientation & pixel density - onDpiChanged(Q_NULLPTR, Q_NULLPTR); d->orientation = d->nativeOrientation; - onOrientationChanged(Q_NULLPTR, Q_NULLPTR); ComPtr<IApplicationViewStatics2> applicationViewStatics; hr = RoGetActivationFactory(HString::MakeReference(RuntimeClass_Windows_UI_ViewManagement_ApplicationView).Get(), @@ -699,7 +695,8 @@ Xaml::IDependencyObject *QWinRTScreen::canvas() const void QWinRTScreen::setStatusBarVisibility(bool visible, QWindow *window) { Q_D(QWinRTScreen); - if (!window || (window->flags() & Qt::WindowType_Mask) != Qt::Window) + const Qt::WindowFlags windowType = window->flags() & Qt::WindowType_Mask; + if (!window || (windowType != Qt::Window && windowType != Qt::Dialog)) return; QEventDispatcherWinRT::runOnXamlThread([d, visible]() { @@ -756,6 +753,8 @@ void QWinRTScreen::initialize() Q_ASSERT_SUCCEEDED(hr); hr = d->displayInformation->add_DpiChanged(Callback<DisplayInformationHandler>(this, &QWinRTScreen::onDpiChanged).Get(), &d->displayTokens[&IDisplayInformation::remove_DpiChanged]); Q_ASSERT_SUCCEEDED(hr); + onDpiChanged(Q_NULLPTR, Q_NULLPTR); + onOrientationChanged(Q_NULLPTR, Q_NULLPTR); onVisibilityChanged(nullptr, nullptr); } diff --git a/src/plugins/platforms/winrt/qwinrtwindow.cpp b/src/plugins/platforms/winrt/qwinrtwindow.cpp index 0d43e76c1a..bec94c1e51 100644 --- a/src/plugins/platforms/winrt/qwinrtwindow.cpp +++ b/src/plugins/platforms/winrt/qwinrtwindow.cpp @@ -207,7 +207,8 @@ void QWinRTWindow::setGeometry(const QRect &rect) Q_D(QWinRTWindow); const Qt::WindowFlags windowFlags = window()->flags(); - if (window()->isTopLevel() && (windowFlags & Qt::WindowType_Mask) == Qt::Window) { + const Qt::WindowFlags windowType = windowFlags & Qt::WindowType_Mask; + if (window()->isTopLevel() && (windowType == Qt::Window || windowType == Qt::Dialog)) { QPlatformWindow::setGeometry(windowFlags & Qt::MaximizeUsingFullscreenGeometryHint ? d->screen->geometry() : d->screen->availableGeometry()); QWindowSystemInterface::handleGeometryChange(window(), geometry()); diff --git a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro index 57cd81ec3b..1c577e5dc9 100644 --- a/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro +++ b/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb_glx.pro @@ -17,6 +17,8 @@ contains(QT_CONFIG, xcb-glx) { LIBS += -lxcb-glx } +LIBS += $$QMAKE_LIBS_DYNLOAD + HEADERS += \ qxcbglxintegration.h \ qxcbglxwindow.h \ diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index a20d957138..901764bbf8 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -263,8 +263,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event) // Known screen removed -> delete it m_screens.removeOne(screen); - foreach (QXcbScreen *otherScreen, m_screens) - otherScreen->removeVirtualSibling((QPlatformScreen *) screen); + virtualDesktop->removeScreen(screen); QXcbIntegration::instance()->destroyScreen(screen); @@ -283,9 +282,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event) qCDebug(lcQpaScreen) << "output" << screen->name() << "is connected and enabled"; screen->setPrimary(checkOutputIsPrimary(output.window, output.output)); - foreach (QXcbScreen *otherScreen, m_screens) - if (otherScreen->root() == output.window) - otherScreen->addVirtualSibling(screen); + virtualDesktop->addScreen(screen); m_screens << screen; QXcbIntegration::instance()->screenAdded(screen, screen->isPrimary()); @@ -308,8 +305,7 @@ void QXcbConnection::updateScreens(const xcb_randr_notify_event_t *event) if (outputInfo->crtc == XCB_NONE) { qCDebug(lcQpaScreen) << "output" << screen->name() << "has been disabled"; m_screens.removeOne(screen); - foreach (QXcbScreen *otherScreen, m_screens) - otherScreen->removeVirtualSibling((QPlatformScreen *) screen); + virtualDesktop->removeScreen(screen); QXcbIntegration::instance()->destroyScreen(screen); } else { qCDebug(lcQpaScreen) << "output" << screen->name() << "has been temporarily disabled for the mode switch"; @@ -443,8 +439,7 @@ void QXcbConnection::initializeScreens() } } } - foreach (QPlatformScreen* s, siblings) - ((QXcbScreen*)s)->setVirtualSiblings(siblings); + virtualDesktop->setScreens(siblings); xcb_screen_next(&it); ++xcbScreenNumber; } // for each xcb screen @@ -460,7 +455,7 @@ void QXcbConnection::initializeScreens() QXcbVirtualDesktop *virtualDesktop = m_virtualDesktops.value(0); if (virtualDesktop && !hasOutputs && !virtualDesktop->size().isEmpty() && m_screens.isEmpty()) { QXcbScreen *screen = createScreen(virtualDesktop, 0, Q_NULLPTR); - screen->setVirtualSiblings(QList<QPlatformScreen *>() << screen); + virtualDesktop->setScreens(QList<QPlatformScreen *>() << screen); m_screens << screen; primaryScreen = screen; primaryScreen->setPrimary(true); @@ -1126,8 +1121,17 @@ void QXcbConnection::handleXcbEvent(xcb_generic_event_t *event) handled = false; break; case XCB_PROPERTY_NOTIFY: - HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent); + { + xcb_property_notify_event_t *pn = (xcb_property_notify_event_t *)event; + if (pn->atom == atom(QXcbAtom::_NET_WORKAREA)) { + QXcbVirtualDesktop *virtualDesktop = virtualDesktopForRootWindow(pn->window); + if (virtualDesktop) + virtualDesktop->updateWorkArea(); + } else { + HANDLE_PLATFORM_WINDOW_EVENT(xcb_property_notify_event_t, window, handlePropertyNotifyEvent); + } break; + } #if defined(XCB_USE_XINPUT2) case XCB_GE_GENERIC: // Here the windowEventListener is invoked from xi2HandleEvent() diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 4f71ac8693..55bae05523 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -58,6 +58,8 @@ QXcbVirtualDesktop::QXcbVirtualDesktop(QXcbConnection *connection, xcb_screen_t cmAtomName += QByteArray::number(m_number); m_net_wm_cm_atom = connection->internAtom(cmAtomName.constData()); m_compositingActive = connection->getSelectionOwner(m_net_wm_cm_atom); + + m_workArea = getWorkArea(); } QXcbVirtualDesktop::~QXcbVirtualDesktop() @@ -74,6 +76,11 @@ QXcbScreen *QXcbVirtualDesktop::screenAt(const QPoint &pos) const return Q_NULLPTR; } +void QXcbVirtualDesktop::addScreen(QPlatformScreen *s) +{ + ((QXcbScreen *) s)->isPrimary() ? m_screens.prepend(s) : m_screens.append(s); +} + QXcbXSettings *QXcbVirtualDesktop::xSettings() const { if (!m_xSettings) { @@ -107,6 +114,40 @@ void QXcbVirtualDesktop::subscribeToXFixesSelectionNotify() } } +QRect QXcbVirtualDesktop::getWorkArea() const +{ + QRect r; + xcb_get_property_reply_t * workArea = + xcb_get_property_reply(xcb_connection(), + xcb_get_property_unchecked(xcb_connection(), false, screen()->root, + atom(QXcbAtom::_NET_WORKAREA), + XCB_ATOM_CARDINAL, 0, 1024), NULL); + if (workArea && workArea->type == XCB_ATOM_CARDINAL && workArea->format == 32 && workArea->value_len >= 4) { + // If workArea->value_len > 4, the remaining ones seem to be for WM's virtual desktops + // (don't mess with QXcbVirtualDesktop which represents an X screen). + // But QScreen doesn't know about that concept. In reality there could be a + // "docked" panel (with _NET_WM_STRUT_PARTIAL atom set) on just one desktop. + // But for now just assume the first 4 values give us the geometry of the + // "work area", AKA "available geometry" + uint32_t *geom = (uint32_t*)xcb_get_property_value(workArea); + r = QRect(geom[0], geom[1], geom[2], geom[3]); + } else { + r = QRect(QPoint(), size()); + } + free(workArea); + return r; +} + +void QXcbVirtualDesktop::updateWorkArea() +{ + QRect workArea = getWorkArea(); + if (m_workArea != workArea) { + m_workArea = workArea; + foreach (QPlatformScreen *screen, m_screens) + ((QXcbScreen *)screen)->updateAvailableGeometry(); + } +} + QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDesktop, xcb_randr_output_t outputId, xcb_randr_get_output_info_reply_t *output, QString outputName) @@ -450,7 +491,6 @@ void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp) void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation) { QRect xGeometry = geom; - QRect xAvailableGeometry = xGeometry; switch (rotation) { case XCB_RANDR_ROTATION_ROTATE_0: // xrandr --rotate normal m_orientation = Qt::LandscapeOrientation; @@ -479,34 +519,23 @@ void QXcbScreen::updateGeometry(const QRect &geom, uint8_t rotation) Q_MM_PER_INCH * xGeometry.width() / dpi.second); } - xcb_get_property_reply_t * workArea = - xcb_get_property_reply(xcb_connection(), - xcb_get_property_unchecked(xcb_connection(), false, screen()->root, - atom(QXcbAtom::_NET_WORKAREA), - XCB_ATOM_CARDINAL, 0, 1024), NULL); - - if (workArea && workArea->type == XCB_ATOM_CARDINAL && workArea->format == 32 && workArea->value_len >= 4) { - // If workArea->value_len > 4, the remaining ones seem to be for virtual desktops. - // But QScreen doesn't know about that concept. In reality there could be a - // "docked" panel (with _NET_WM_STRUT_PARTIAL atom set) on just one desktop. - // But for now just assume the first 4 values give us the geometry of the - // "work area", AKA "available geometry" - uint32_t *geom = (uint32_t*)xcb_get_property_value(workArea); - QRect virtualAvailableGeometry(geom[0], geom[1], geom[2], geom[3]); - // Take the intersection of the desktop's available geometry with this screen's geometry - // to get the part of the available geometry which belongs to this screen. - xAvailableGeometry = xGeometry & virtualAvailableGeometry; - } - free(workArea); - qreal dpi = xGeometry.width() / physicalSize().width() * qreal(25.4); m_pixelDensity = qRound(dpi/96); m_geometry = QRect(xGeometry.topLeft(), xGeometry.size()); m_nativeGeometry = QRect(xGeometry.topLeft(), xGeometry.size()); - m_availableGeometry = QRect(xAvailableGeometry.topLeft(), xAvailableGeometry.size()); + m_availableGeometry = xGeometry & m_virtualDesktop->workArea(); QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); } +void QXcbScreen::updateAvailableGeometry() +{ + QRect availableGeometry = m_geometry & m_virtualDesktop->workArea(); + if (m_availableGeometry != availableGeometry) { + m_availableGeometry = availableGeometry; + QWindowSystemInterface::handleScreenGeometryChange(QPlatformScreen::screen(), m_geometry, m_availableGeometry); + } +} + void QXcbScreen::updateRefreshRate(xcb_randr_mode_t mode) { if (!connection()->hasXRandr()) diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 51c92a40ae..c68c290791 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -68,20 +68,33 @@ public: xcb_window_t root() const { return m_screen->root; } QXcbScreen *screenAt(const QPoint &pos) const; + QList<QPlatformScreen *> screens() const { return m_screens; } + void setScreens(QList<QPlatformScreen *> sl) { m_screens = sl; } + void removeScreen(QPlatformScreen *s) { m_screens.removeOne(s); } + void addScreen(QPlatformScreen *s); + QXcbXSettings *xSettings() const; bool compositingActive() const; + QRect workArea() const { return m_workArea; } + void updateWorkArea(); + void handleXFixesSelectionNotify(xcb_xfixes_selection_notify_event_t *notify_event); void subscribeToXFixesSelectionNotify(); private: + QRect getWorkArea() const; + xcb_screen_t *m_screen; int m_number; + QList<QPlatformScreen *> m_screens; QXcbXSettings *m_xSettings; xcb_atom_t m_net_wm_cm_atom; bool m_compositingActive; + + QRect m_workArea; }; class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen @@ -110,10 +123,7 @@ public: QPlatformCursor *cursor() const Q_DECL_OVERRIDE; qreal refreshRate() const Q_DECL_OVERRIDE { return m_refreshRate; } Qt::ScreenOrientation orientation() const Q_DECL_OVERRIDE { return m_orientation; } - QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_siblings; } - void setVirtualSiblings(QList<QPlatformScreen *> sl) { m_siblings = sl; } - void removeVirtualSibling(QPlatformScreen *s) { m_siblings.removeOne(s); } - void addVirtualSibling(QPlatformScreen *s) { ((QXcbScreen *) s)->isPrimary() ? m_siblings.prepend(s) : m_siblings.append(s); } + QList<QPlatformScreen *> virtualSiblings() const Q_DECL_OVERRIDE { return m_virtualDesktop->screens(); } QXcbVirtualDesktop *virtualDesktop() const { return m_virtualDesktop; } void setPrimary(bool primary) { m_primary = primary; } @@ -139,6 +149,7 @@ public: void handleScreenChange(xcb_randr_screen_change_notify_event_t *change_event); void updateGeometry(const QRect &geom, uint8_t rotation); void updateGeometry(xcb_timestamp_t timestamp = XCB_TIME_CURRENT_TIME); + void updateAvailableGeometry(); void updateRefreshRate(xcb_randr_mode_t mode); void readXResources(); @@ -171,7 +182,6 @@ private: QRect m_availableGeometry; QSize m_virtualSize; QSizeF m_virtualSizeMillimeters; - QList<QPlatformScreen *> m_siblings; Qt::ScreenOrientation m_orientation; QString m_windowManagerName; bool m_syncRequestSupported; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index b691c7550f..bcc571c3c8 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -2378,8 +2378,6 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev return; } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) { m_dirtyFrameMargins = true; - } else if (event->atom == atom(QXcbAtom::_NET_WORKAREA) && xcbScreen() && event->window == xcbScreen()->root()) { - xcbScreen()->updateGeometry(event->time); } } diff --git a/src/plugins/platforms/xcb/xcb_qpa_lib.pro b/src/plugins/platforms/xcb/xcb_qpa_lib.pro index 12987567ff..60eb8a02e3 100644 --- a/src/plugins/platforms/xcb/xcb_qpa_lib.pro +++ b/src/plugins/platforms/xcb/xcb_qpa_lib.pro @@ -1,13 +1,6 @@ TARGET = QtXcbQpa CONFIG += no_module_headers internal_module -MODULE_INCLUDES = \ - \$\$QT_MODULE_INCLUDE_BASE \ - \$\$QT_MODULE_INCLUDE_BASE/QtQGui -MODULE_PRIVATE_INCLUDES = \ - \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION \ - \$\$QT_MODULE_INCLUDE_BASE/QtGui/$$QT.gui.VERSION/QtGui - load(qt_module) QT += core-private gui-private platformsupport-private @@ -47,8 +40,6 @@ HEADERS = \ qxcbxsettings.h \ qxcbsystemtraytracker.h -LIBS += $$QMAKE_LIBS_DYNLOAD - DEFINES += QT_BUILD_XCB_PLUGIN # needed by Xcursor ... contains(QT_CONFIG, xcb-xlib) { |