diff options
author | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-17 20:01:21 +0200 |
---|---|---|
committer | Tor Arne Vestbø <tor.arne.vestbo@qt.io> | 2020-07-20 17:47:29 +0200 |
commit | 3a475d48ee03d1953292a8fe4ef8ab7e3b1e6c37 (patch) | |
tree | 2d8e5b5491067b3166e87c80abc7cbda151f29cf | |
parent | 6e5694b63b0275fe180da7b892b03a865d218d99 (diff) |
Add QXcbScreen platform interface
Task-number: QTBUG-84220
Change-Id: I6c166409fbaf50627dea65a6256764e08ab36a59
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
-rw-r--r-- | src/gui/kernel/qplatformscreen_p.h | 16 | ||||
-rw-r--r-- | src/gui/platform/unix/qunixplatforminterface.cpp | 5 | ||||
-rw-r--r-- | src/platformheaders/.prev_CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/platformheaders/CMakeLists.txt | 2 | ||||
-rw-r--r-- | src/platformheaders/xcbfunctions/qxcbscreenfunctions_p.h | 73 | ||||
-rw-r--r-- | src/platformheaders/xcbfunctions/xcbfunctions.pri | 3 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbnativeinterface.cpp | 4 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.cpp | 8 | ||||
-rw-r--r-- | src/plugins/platforms/xcb/qxcbscreen.h | 4 |
9 files changed, 25 insertions, 92 deletions
diff --git a/src/gui/kernel/qplatformscreen_p.h b/src/gui/kernel/qplatformscreen_p.h index d5dc7b471a..2ae91196ed 100644 --- a/src/gui/kernel/qplatformscreen_p.h +++ b/src/gui/kernel/qplatformscreen_p.h @@ -53,6 +53,8 @@ #include <QtGui/private/qtguiglobal_p.h> +#include <QtCore/qpointer.h> + QT_BEGIN_NAMESPACE class QScreen; @@ -63,6 +65,20 @@ public: QPointer<QScreen> screen; }; +// ----------------- QPlatformInterface ----------------- + +namespace QPlatformInterface::Private { + +#if QT_CONFIG(xcb) +struct Q_GUI_EXPORT QXcbScreen +{ + QT_DECLARE_PLATFORM_INTERFACE(QXcbScreen) + virtual int virtualDesktopNumber() const = 0; +}; +#endif + +} // QPlatformInterface::Private + QT_END_NAMESPACE #endif // QPLATFORMSCREEN_P_H diff --git a/src/gui/platform/unix/qunixplatforminterface.cpp b/src/gui/platform/unix/qunixplatforminterface.cpp index 2584a9b91b..23862f881e 100644 --- a/src/gui/platform/unix/qunixplatforminterface.cpp +++ b/src/gui/platform/unix/qunixplatforminterface.cpp @@ -44,6 +44,7 @@ #include <qpa/qplatformopenglcontext.h> #include <qpa/qplatformintegration.h> +#include <qpa/qplatformscreen_p.h> QT_BEGIN_NAMESPACE @@ -79,6 +80,10 @@ QOpenGLContext *QPlatformInterface::QEGLContext::fromNative(EGLContext context, } #endif +#if QT_CONFIG(xcb) +QT_DEFINE_PRIVATE_PLATFORM_INTERFACE(QXcbScreen); +#endif + #endif // QT_NO_OPENGL QT_END_NAMESPACE diff --git a/src/platformheaders/.prev_CMakeLists.txt b/src/platformheaders/.prev_CMakeLists.txt index d752381fb7..e5bf127123 100644 --- a/src/platformheaders/.prev_CMakeLists.txt +++ b/src/platformheaders/.prev_CMakeLists.txt @@ -7,13 +7,11 @@ qt_add_module(PlatformHeaders HEADER_MODULE SOURCES - cocoafunctions/qcocoawindowfunctions_p.h eglfsfunctions/qeglfsfunctions_p.h helper/qplatformheaderhelper_p.h linuxfbfunctions/qlinuxfbfunctions_p.h waylandfunctions/qwaylandwindowfunctions_p.h windowsfunctions/qwindowswindowfunctions_p.h - xcbfunctions/qxcbscreenfunctions_p.h xcbfunctions/qxcbwindowfunctions_p.h PUBLIC_LIBRARIES Qt::Core diff --git a/src/platformheaders/CMakeLists.txt b/src/platformheaders/CMakeLists.txt index 63bb60576f..a56e0b1348 100644 --- a/src/platformheaders/CMakeLists.txt +++ b/src/platformheaders/CMakeLists.txt @@ -8,13 +8,11 @@ qt_add_module(PlatformHeaders HEADER_MODULE # special case begin # SOURCES - # cocoafunctions/qcocoawindowfunctions_p.h # eglfsfunctions/qeglfsfunctions_p.h # helper/qplatformheaderhelper_p.h # linuxfbfunctions/qlinuxfbfunctions_p.h # waylandfunctions/qwaylandwindowfunctions_p.h # windowsfunctions/qwindowswindowfunctions_p.h - # xcbfunctions/qxcbscreenfunctions_p.h # xcbfunctions/qxcbwindowfunctions_p.h # special case end PUBLIC_LIBRARIES diff --git a/src/platformheaders/xcbfunctions/qxcbscreenfunctions_p.h b/src/platformheaders/xcbfunctions/qxcbscreenfunctions_p.h deleted file mode 100644 index f040701941..0000000000 --- a/src/platformheaders/xcbfunctions/qxcbscreenfunctions_p.h +++ /dev/null @@ -1,73 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the plugins of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QXCBSCREENFUNCTIONS_H -#define QXCBSCREENFUNCTIONS_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include <QtPlatformHeaders/private/qplatformheaderhelper_p.h> - -QT_BEGIN_NAMESPACE - -class QScreen; - -class QXcbScreenFunctions -{ -public: - typedef bool (*VirtualDesktopNumber)(const QScreen *screen); - static const QByteArray virtualDesktopNumberIdentifier() { return QByteArrayLiteral("XcbVirtualDesktopNumber"); } - static int virtualDesktopNumber(const QScreen *screen) - { - return QPlatformHeaderHelper::callPlatformFunction<int, VirtualDesktopNumber, const QScreen *>(virtualDesktopNumberIdentifier(), screen); - } -}; - -QT_END_NAMESPACE - -#endif /*QXCBSCREENFUNCTIONS_H*/ diff --git a/src/platformheaders/xcbfunctions/xcbfunctions.pri b/src/platformheaders/xcbfunctions/xcbfunctions.pri index 5ca2721506..f3fdfe605e 100644 --- a/src/platformheaders/xcbfunctions/xcbfunctions.pri +++ b/src/platformheaders/xcbfunctions/xcbfunctions.pri @@ -1,3 +1,2 @@ HEADERS += \ - $$PWD/qxcbwindowfunctions_p.h \ - $$PWD/qxcbscreenfunctions_p.h + $$PWD/qxcbwindowfunctions_p.h diff --git a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp index 52b4ffa7a9..d725d49082 100644 --- a/src/plugins/platforms/xcb/qxcbnativeinterface.cpp +++ b/src/plugins/platforms/xcb/qxcbnativeinterface.cpp @@ -54,7 +54,6 @@ #include <QtGui/qscreen.h> #include <QtPlatformHeaders/private/qxcbwindowfunctions_p.h> -#include <QtPlatformHeaders/private/qxcbscreenfunctions_p.h> #include <stdio.h> @@ -329,9 +328,6 @@ QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &functio return QFunctionPointer(QXcbWindowFunctions::VisualId(QXcbWindow::visualIdStatic)); } - if (function == QXcbScreenFunctions::virtualDesktopNumberIdentifier()) - return QFunctionPointer(QXcbScreenFunctions::VirtualDesktopNumber(reinterpret_cast<void *>(QXcbScreen::virtualDesktopNumberStatic))); - return nullptr; } diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 505f7343ce..9dc7c97eab 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -702,14 +702,6 @@ void QXcbScreen::setOutput(xcb_randr_output_t outputId, // TODO: Send an event to the QScreen instance that the screen changed its name } -int QXcbScreen::virtualDesktopNumberStatic(const QScreen *screen) -{ - if (screen && screen->handle()) - return static_cast<const QXcbScreen *>(screen->handle())->screenNumber(); - - return 0; -} - void QXcbScreen::updateGeometry(xcb_timestamp_t timestamp) { if (!connection()->hasXRandr()) diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 8a90d61b98..60ef82bae3 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -41,6 +41,7 @@ #define QXCBSCREEN_H #include <qpa/qplatformscreen.h> +#include <qpa/qplatformscreen_p.h> #include <QtCore/QString> #include <xcb/xcb.h> @@ -137,6 +138,7 @@ private: }; class Q_XCB_EXPORT QXcbScreen : public QXcbObject, public QPlatformScreen + , public QPlatformInterface::Private::QXcbScreen { public: QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDesktop, @@ -171,7 +173,7 @@ public: bool isPrimary() const { return m_primary; } int screenNumber() const { return m_virtualDesktop->number(); } - static int virtualDesktopNumberStatic(const QScreen *screen); + int virtualDesktopNumber() const override { return screenNumber(); } xcb_screen_t *screen() const { return m_virtualDesktop->screen(); } xcb_window_t root() const { return screen()->root; } |