Add QXcbWindow platform interface

Task-number: QTBUG-84220
Change-Id: I8bb4288f1ac06d77fb4f43ae091fa1712f694eeb
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
bb10
Tor Arne Vestbø 2020-07-17 22:15:07 +02:00
parent 6034494070
commit 9166abcd99
17 changed files with 136 additions and 565 deletions

View File

@ -77,6 +77,38 @@ struct Q_GUI_EXPORT QCocoaWindow
};
#endif
#if QT_CONFIG(xcb)
struct Q_GUI_EXPORT QXcbWindow
{
QT_DECLARE_PLATFORM_INTERFACE(QXcbWindow)
enum WindowType {
None = 0x000000,
Normal = 0x000001,
Desktop = 0x000002,
Dock = 0x000004,
Toolbar = 0x000008,
Menu = 0x000010,
Utility = 0x000020,
Splash = 0x000040,
Dialog = 0x000080,
DropDownMenu = 0x000100,
PopupMenu = 0x000200,
Tooltip = 0x000400,
Notification = 0x000800,
Combo = 0x001000,
Dnd = 0x002000,
KdeOverride = 0x004000
};
Q_DECLARE_FLAGS(WindowTypes, WindowType)
virtual void setWindowType(WindowTypes type) = 0;
virtual void setWindowRole(const QString &role) = 0;
virtual void setWindowIconText(const QString &text) = 0;
virtual uint visualId() const = 0;
};
#endif
} // QPlatformInterface::Private
QT_END_NAMESPACE

View File

@ -45,6 +45,7 @@
#include <qpa/qplatformopenglcontext.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformscreen_p.h>
#include <qpa/qplatformwindow_p.h>
QT_BEGIN_NAMESPACE
@ -82,6 +83,7 @@ QOpenGLContext *QPlatformInterface::QEGLContext::fromNative(EGLContext context,
#if QT_CONFIG(xcb)
QT_DEFINE_PRIVATE_PLATFORM_INTERFACE(QXcbScreen);
QT_DEFINE_PRIVATE_PLATFORM_INTERFACE(QXcbWindow);
#endif
#endif // QT_NO_OPENGL

View File

@ -12,7 +12,6 @@ qt_add_module(PlatformHeaders
linuxfbfunctions/qlinuxfbfunctions_p.h
waylandfunctions/qwaylandwindowfunctions_p.h
windowsfunctions/qwindowswindowfunctions_p.h
xcbfunctions/qxcbwindowfunctions_p.h
PUBLIC_LIBRARIES
Qt::Core
Qt::Gui

View File

@ -13,7 +13,6 @@ qt_add_module(PlatformHeaders
# linuxfbfunctions/qlinuxfbfunctions_p.h
# waylandfunctions/qwaylandwindowfunctions_p.h
# windowsfunctions/qwindowswindowfunctions_p.h
# xcbfunctions/qxcbwindowfunctions_p.h
# special case end
PUBLIC_LIBRARIES
Qt::Core

View File

@ -33,7 +33,6 @@ depends += \
headerdirs += ..
sourcedirs += ..
exampledirs += snippets
imagedirs += images
tagfile = qtplatformheaders.tags

View File

@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets>
#include <QtPlatformHeaders/private/qwindowswindowfunctions_p.h>
//! [0]
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QPushButton topLevelWidget("Hello World!");
topLevelWidget.winId(); //have to create the QWindow
QWindow *tlwWindow = topLevelWidget.windowHandle();
QWindowsWindowFunctions::setTouchWindowTouchType(tlwWindow, QWindowsWindowFunctions::WantPalmTouch);
topLevelWidget.show();
return app.exec();
}
//! [0]

View File

@ -1,71 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:BSD$
** 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.
**
** BSD License Usage
** Alternatively, you may use this file under the terms of the BSD license
** as follows:
**
** "Redistribution and use in source and binary forms, with or without
** modification, are permitted provided that the following conditions are
** met:
** * Redistributions of source code must retain the above copyright
** notice, this list of conditions and the following disclaimer.
** * Redistributions in binary form must reproduce the above copyright
** notice, this list of conditions and the following disclaimer in
** the documentation and/or other materials provided with the
** distribution.
** * Neither the name of The Qt Company Ltd nor the names of its
** contributors may be used to endorse or promote products derived
** from this software without specific prior written permission.
**
**
** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include <QtWidgets>
#include <QtPlatformHeaders/private/qxcbwindowfunctions_p.h>
//! [0]
int main(int argc, char **argv)
{
QApplication app(argc, argv);
QPushButton topLevelWidget("Hello World!");
topLevelWidget.winId(); //have to create the QWindow
QWindow *tlwWindow = topLevelWidget.windowHandle();
QXcbWindowFunctions::setWmWindowType(tlwWindow, QXcbWindowFunctions::Dock);
topLevelWidget.show();
return app.exec();
}
//! [0]

View File

@ -68,24 +68,20 @@
a platform plugin from QGuiApplication::platformFunction(). Headers in
QtPlatformHeaders can also implement wrapper functions for the function
pointer, giving a static function that can be called from any context after
the platform integration has been created. An implementation of this
pattern is QXcbWindowFunctions::setWmWindowType(). This function retrieves
a function pointer from QGuiApplication::platformFunction, and executes
that function if the requested function was returned.
the platform integration has been created.
\note Similar to the other QPA APIs, there are no binary compatibility
guarantees for these classes, meaning that an application using these
classes is only guaranteed to work with the Qt version it was developed
against. Unlike QPA however, source compatibility is guaranteed.
\sa QXcbWindowFunctions QWindowsWindowFunctions
\sa QWindowsWindowFunctions
\section1 Getting Started
To include the definitions of the module's functions and classes, use the following directives:
\code
#include <QtPlatformHeaders/QWindowsWindowFunctions>
#include <QtPlatformHeaders/QXcbWindowFunctions>
\endcode
As the module is header-only, no modifications to your build system are required.

View File

@ -1,7 +1,6 @@
TARGET = QtPlatformHeaders
CONFIG += header_module
include(xcbfunctions/xcbfunctions.pri)
include(eglfsfunctions/eglfsfunctions.pri)
include(windowsfunctions/windowsfunctions.pri)
include(helper/helper.pri)

View File

@ -1,165 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** 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 Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file. Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
** $QT_END_LICENSE$
**
****************************************************************************/
/*!
\class QXcbWindowFunctions
\inmodule QtPlatformHeaders
\brief The QXcbWindowFunctions class is an inline class containing
miscellaneous functionality for xcb window specific functionality.
A common usage pattern is as follows:
\snippet qxcbwindowfunctions/main.cpp 0
\note There is no binary compatibility guarantee for this class,
meaning that an application using it is only guaranteed to work with the Qt
version it was developed against.
*/
/*!
\enum QXcbWindowFunctions::WmWindowType
This enum represents the supported WM_WINDOW_TYPE atoms.
\value Normal
\value Desktop
\value Dock
\value Toolbar
\value Menu
\value Utility
\value Splash
\value Dialog
\value DropDownMenu
\value PopupMenu
\value Tooltip
\value Notification
\value Combo
\value Dnd
\value KdeOverride
*/
/*!
\typedef QXcbWindowFunctions::SetWmWindowType
This is the typedef for the function returned by
QGuiApplication::platformFunction when passed the
value returned by setWmWindowTypeIdentifier().
*/
/*!
\fn QByteArray QXcbWindowFunctions::setWmWindowTypeIdentifier()
This function returns the byte array that can be used to query
QGuiApplication::platformFunction to retrieve the SetWmWindowType function.
*/
/*!
\fn void QXcbWindowFunctions::setWmWindowType(QWindow *window, WmWindowType type)
This is a convenience function that can be used directly instead
of resolving the function pointer. \a window and \a type will be
relayed to the function retrieved by QGuiApplication.
*/
/*!
\typedef QXcbWindowFunctions::SetWmWindowRole
\since 5.6.2
This is the typedef for the function returned by
QGuiApplication::platformFunction when passed the
value returned by setWmWindowRoleIdentifier().
*/
/*!
\fn QByteArray QXcbWindowFunctions::setWmWindowRoleIdentifier()
\since 5.6.2
This function returns the byte array that can be used to query
QGuiApplication::platformFunction to retrieve the SetWmWindowRole function.
*/
/*!
\fn void QXcbWindowFunctions::setWmWindowRole(QWindow *window, const QByteArray &role)
\since 5.6.2
Sets the WM_WINDOW_ROLE property from \a role on the corresponding
X11 window.
This is a convenience function that can be used directly instead
of resolving the function pointer. \a window and \a role will be
relayed to the function retrieved by QGuiApplication.
*/
/*!
\typedef QXcbWindowFunctions::SetWmWindowIconText
This is the typedef for the function returned by
QGuiApplication::platformFunction when passed the
value returned by setWmWindowIconTextIdentifier().
*/
/*!
\fn const QByteArray QXcbWindowFunctions::setWmWindowIconTextIdentifier()
This function returns the byte array that can be used to query
QGuiApplication::platformFunction to retrieve the SetWmWindowIconText function.
*/
/*!
\fn void QXcbWindowFunctions::setWmWindowIconText(QWindow *window, const QString& text)
This is a convenience function that can be used directly instead
of resolving the function pointer. \a window and \a text will be
relayed to the function retrieved by QGuiApplication.
*/
/*!
\typedef QXcbWindowFunctions::VisualId
This is the typedef for the function returned by
QGuiApplication::platformFunction when passed the
value returned by visualIdIdentifier().
*/
/*!
\fn const QByteArray QXcbWindowFunctions::visualIdIdentifier()
This function returns the byte array that can be used to query
QGuiApplication::platformFunction to retrieve the VisualId function.
*/
/*!
\fn uint QXcbWindowFunctions::visualId(QWindow *window)
This is a convenience function that can be used directly instead
of resolving the function pointer. \a window will be
relayed to the function retrieved by QGuiApplication.
Returns the unsigned integer result of calling the function or
UINT_MAX if the function was not found.
*/

View File

@ -1,119 +0,0 @@
/****************************************************************************
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://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 QXCBWINDOWFUNCTIONS_H
#define QXCBWINDOWFUNCTIONS_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 QWindow;
class QXcbWindowFunctions {
public:
enum WmWindowType {
Normal = 0x000001,
Desktop = 0x000002,
Dock = 0x000004,
Toolbar = 0x000008,
Menu = 0x000010,
Utility = 0x000020,
Splash = 0x000040,
Dialog = 0x000080,
DropDownMenu = 0x000100,
PopupMenu = 0x000200,
Tooltip = 0x000400,
Notification = 0x000800,
Combo = 0x001000,
Dnd = 0x002000,
KdeOverride = 0x004000
};
Q_DECLARE_FLAGS(WmWindowTypes, WmWindowType)
typedef void (*SetWmWindowType)(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowType);
static const QByteArray setWmWindowTypeIdentifier() { return QByteArrayLiteral("XcbSetWmWindowType"); }
static void setWmWindowType(QWindow *window, WmWindowType type)
{
return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowType, QWindow *, WmWindowType>(setWmWindowTypeIdentifier(), window, type);
}
typedef void (*SetWmWindowRole)(QWindow *window, const QByteArray &role);
static const QByteArray setWmWindowRoleIdentifier() { return QByteArrayLiteral("XcbSetWmWindowRole"); }
static void setWmWindowRole(QWindow *window, const QByteArray &role)
{
return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowRole, QWindow *, const QByteArray &>(setWmWindowRoleIdentifier(), window, role);
}
typedef void (*SetWmWindowIconText)(QWindow *window, const QString &text);
static const QByteArray setWmWindowIconTextIdentifier() { return QByteArrayLiteral("XcbSetWmWindowIconText"); }
static void setWmWindowIconText(QWindow *window, const QString &text)
{
return QPlatformHeaderHelper::callPlatformFunction<void, SetWmWindowIconText, QWindow *, const QString &>(setWmWindowIconTextIdentifier(), window, text);
}
typedef uint (*VisualId)(QWindow *window);
static const QByteArray visualIdIdentifier() { return QByteArrayLiteral("XcbVisualId"); }
static uint visualId(QWindow *window)
{
QXcbWindowFunctions::VisualId func = reinterpret_cast<VisualId>(QGuiApplication::platformFunction(visualIdIdentifier()));
if (func)
return func(window);
return UINT_MAX;
}
};
QT_END_NAMESPACE
#endif // QXCBWINDOWFUNCTIONS_H

View File

@ -1,2 +0,0 @@
HEADERS += \
$$PWD/qxcbwindowfunctions_p.h

View File

@ -51,6 +51,7 @@
#if QT_CONFIG(regularexpression)
# include <QtCore/QRegularExpression>
#endif
#include <QtGui/qguiapplication.h>
#include <QtGui/QOpenGLContext>
#include <QtGui/QOffscreenSurface>

View File

@ -53,8 +53,6 @@
#include <QtGui/qopenglcontext.h>
#include <QtGui/qscreen.h>
#include <QtPlatformHeaders/private/qxcbwindowfunctions_p.h>
#include <stdio.h>
#include <algorithm>
@ -310,24 +308,9 @@ QPlatformNativeInterface::NativeResourceForBackingStoreFunction QXcbNativeInterf
QFunctionPointer QXcbNativeInterface::platformFunction(const QByteArray &function) const
{
const QByteArray lowerCaseFunction = function.toLower();
QFunctionPointer func = handlerPlatformFunction(lowerCaseFunction);
if (func)
if (QFunctionPointer func = handlerPlatformFunction(lowerCaseFunction))
return func;
//case sensitive
if (function == QXcbWindowFunctions::setWmWindowTypeIdentifier())
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowType(QXcbWindow::setWmWindowTypeStatic));
if (function == QXcbWindowFunctions::setWmWindowRoleIdentifier())
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowRole(QXcbWindow::setWmWindowRoleStatic));
if (function == QXcbWindowFunctions::setWmWindowIconTextIdentifier())
return QFunctionPointer(QXcbWindowFunctions::SetWmWindowIconText(QXcbWindow::setWindowIconTextStatic));
if (function == QXcbWindowFunctions::visualIdIdentifier()) {
return QFunctionPointer(QXcbWindowFunctions::VisualId(QXcbWindow::visualIdStatic));
}
return nullptr;
}

View File

@ -511,7 +511,7 @@ void QXcbWindow::create()
if (window()->dynamicPropertyNames().contains(wm_window_role_property_id)) {
QByteArray wmWindowRole = window()->property(wm_window_role_property_id).toByteArray();
setWmWindowRole(wmWindowRole);
setWindowRole(QString::fromLatin1(wmWindowRole));
}
if (m_trayIconWindow)
@ -919,9 +919,9 @@ void QXcbWindow::setWindowFlags(Qt::WindowFlags flags)
xcb_change_window_attributes(xcb_connection(), xcb_window(), mask, values);
QXcbWindowFunctions::WmWindowTypes wmWindowTypes;
WindowTypes wmWindowTypes;
if (window()->dynamicPropertyNames().contains(wm_window_type_property_id)) {
wmWindowTypes = static_cast<QXcbWindowFunctions::WmWindowTypes>(
wmWindowTypes = static_cast<WindowTypes>(
qvariant_cast<int>(window()->property(wm_window_type_property_id)));
}
@ -1445,38 +1445,9 @@ QSurfaceFormat QXcbWindow::format() const
return m_format;
}
void QXcbWindow::setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes)
QXcbWindow::WindowTypes QXcbWindow::wmWindowTypes() const
{
window->setProperty(wm_window_type_property_id, QVariant::fromValue(static_cast<int>(windowTypes)));
if (window->handle())
static_cast<QXcbWindow *>(window->handle())->setWmWindowType(windowTypes, window->flags());
}
void QXcbWindow::setWindowIconTextStatic(QWindow *window, const QString &text)
{
if (window->handle())
static_cast<QXcbWindow *>(window->handle())->setWindowIconText(text);
}
void QXcbWindow::setWmWindowRoleStatic(QWindow *window, const QByteArray &role)
{
if (window->handle())
static_cast<QXcbWindow *>(window->handle())->setWmWindowRole(role);
else
window->setProperty(wm_window_role_property_id, role);
}
uint QXcbWindow::visualIdStatic(QWindow *window)
{
if (window && window->handle())
return static_cast<QXcbWindow *>(window->handle())->visualId();
return UINT_MAX;
}
QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const
{
QXcbWindowFunctions::WmWindowTypes result;
WindowTypes result;
auto reply = Q_XCB_REPLY_UNCHECKED(xcb_get_property, xcb_connection(),
0, m_window, atom(QXcbAtom::_NET_WM_WINDOW_TYPE),
@ -1488,49 +1459,49 @@ QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const
QXcbAtom::Atom type = connection()->qatom(*types);
switch (type) {
case QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL:
result |= QXcbWindowFunctions::Normal;
result |= WindowType::Normal;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP:
result |= QXcbWindowFunctions::Desktop;
result |= WindowType::Desktop;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK:
result |= QXcbWindowFunctions::Dock;
result |= WindowType::Dock;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR:
result |= QXcbWindowFunctions::Toolbar;
result |= WindowType::Toolbar;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_MENU:
result |= QXcbWindowFunctions::Menu;
result |= WindowType::Menu;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY:
result |= QXcbWindowFunctions::Utility;
result |= WindowType::Utility;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH:
result |= QXcbWindowFunctions::Splash;
result |= WindowType::Splash;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG:
result |= QXcbWindowFunctions::Dialog;
result |= WindowType::Dialog;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU:
result |= QXcbWindowFunctions::DropDownMenu;
result |= WindowType::DropDownMenu;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU:
result |= QXcbWindowFunctions::PopupMenu;
result |= WindowType::PopupMenu;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP:
result |= QXcbWindowFunctions::Tooltip;
result |= WindowType::Tooltip;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION:
result |= QXcbWindowFunctions::Notification;
result |= WindowType::Notification;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO:
result |= QXcbWindowFunctions::Combo;
result |= WindowType::Combo;
break;
case QXcbAtom::_NET_WM_WINDOW_TYPE_DND:
result |= QXcbWindowFunctions::Dnd;
result |= WindowType::Dnd;
break;
case QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE:
result |= QXcbWindowFunctions::KdeOverride;
result |= WindowType::KdeOverride;
break;
default:
break;
@ -1540,46 +1511,46 @@ QXcbWindowFunctions::WmWindowTypes QXcbWindow::wmWindowTypes() const
return result;
}
void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags)
void QXcbWindow::setWmWindowType(WindowTypes types, Qt::WindowFlags flags)
{
QList<xcb_atom_t> atoms;
// manual selection 1 (these are never set by Qt and take precedence)
if (types & QXcbWindowFunctions::Normal)
if (types & WindowType::Normal)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NORMAL));
if (types & QXcbWindowFunctions::Desktop)
if (types & WindowType::Desktop)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DESKTOP));
if (types & QXcbWindowFunctions::Dock)
if (types & WindowType::Dock)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DOCK));
if (types & QXcbWindowFunctions::Notification)
if (types & WindowType::Notification)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_NOTIFICATION));
// manual selection 2 (Qt uses these during auto selection);
if (types & QXcbWindowFunctions::Utility)
if (types & WindowType::Utility)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY));
if (types & QXcbWindowFunctions::Splash)
if (types & WindowType::Splash)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH));
if (types & QXcbWindowFunctions::Dialog)
if (types & WindowType::Dialog)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG));
if (types & QXcbWindowFunctions::Tooltip)
if (types & WindowType::Tooltip)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP));
if (types & QXcbWindowFunctions::KdeOverride)
if (types & WindowType::KdeOverride)
atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
// manual selection 3 (these can be set by Qt, but don't have a
// corresponding Qt::WindowType). note that order of the *MENU
// atoms is important
if (types & QXcbWindowFunctions::Menu)
if (types & WindowType::Menu)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_MENU));
if (types & QXcbWindowFunctions::DropDownMenu)
if (types & WindowType::DropDownMenu)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DROPDOWN_MENU));
if (types & QXcbWindowFunctions::PopupMenu)
if (types & WindowType::PopupMenu)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_POPUP_MENU));
if (types & QXcbWindowFunctions::Toolbar)
if (types & WindowType::Toolbar)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLBAR));
if (types & QXcbWindowFunctions::Combo)
if (types & WindowType::Combo)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_COMBO));
if (types & QXcbWindowFunctions::Dnd)
if (types & WindowType::Dnd)
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DND));
// automatic selection
@ -1587,27 +1558,27 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
switch (type) {
case Qt::Dialog:
case Qt::Sheet:
if (!(types & QXcbWindowFunctions::Dialog))
if (!(types & WindowType::Dialog))
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_DIALOG));
break;
case Qt::Tool:
case Qt::Drawer:
if (!(types & QXcbWindowFunctions::Utility))
if (!(types & WindowType::Utility))
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_UTILITY));
break;
case Qt::ToolTip:
if (!(types & QXcbWindowFunctions::Tooltip))
if (!(types & WindowType::Tooltip))
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_TOOLTIP));
break;
case Qt::SplashScreen:
if (!(types & QXcbWindowFunctions::Splash))
if (!(types & WindowType::Splash))
atoms.append(atom(QXcbAtom::_NET_WM_WINDOW_TYPE_SPLASH));
break;
default:
break;
}
if ((flags & Qt::FramelessWindowHint) && !(type & QXcbWindowFunctions::KdeOverride)) {
if ((flags & Qt::FramelessWindowHint) && !(type & WindowType::KdeOverride)) {
// override netwm type - quick and easy for KDE noborder
atoms.append(atom(QXcbAtom::_KDE_NET_WM_WINDOW_TYPE_OVERRIDE));
}
@ -1627,11 +1598,12 @@ void QXcbWindow::setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::W
xcb_flush(xcb_connection());
}
void QXcbWindow::setWmWindowRole(const QByteArray &role)
void QXcbWindow::setWindowRole(const QString &role)
{
QByteArray roleData = role.toLatin1();
xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window,
atom(QXcbAtom::WM_WINDOW_ROLE), XCB_ATOM_STRING, 8,
role.size(), role.constData());
roleData.size(), roleData.constData());
}
void QXcbWindow::setParentRelativeBackPixmap()

View File

@ -41,6 +41,7 @@
#define QXCBWINDOW_H
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformwindow_p.h>
#include <QtGui/QSurfaceFormat>
#include <QtGui/QImage>
@ -49,8 +50,6 @@
#include "qxcbobject.h"
#include <QtPlatformHeaders/private/qxcbwindowfunctions_p.h>
QT_BEGIN_NAMESPACE
class QXcbScreen;
@ -58,6 +57,7 @@ class QXcbSyncWindowRequest;
class QIcon;
class Q_XCB_EXPORT QXcbWindow : public QXcbObject, public QXcbWindowEventListener, public QPlatformWindow
, public QPlatformInterface::Private::QXcbWindow
{
public:
enum NetWmState {
@ -93,7 +93,7 @@ public:
QPoint mapFromGlobal(const QPoint &pos) const override;
void setWindowTitle(const QString &title) override;
void setWindowIconText(const QString &title);
void setWindowIconText(const QString &title) override;
void setWindowIcon(const QIcon &icon) override;
void raise() override;
void lower() override;
@ -148,19 +148,14 @@ public:
void updateNetWmUserTime(xcb_timestamp_t timestamp);
static void setWmWindowTypeStatic(QWindow *window, QXcbWindowFunctions::WmWindowTypes windowTypes);
static void setWmWindowRoleStatic(QWindow *window, const QByteArray &role);
static uint visualIdStatic(QWindow *window);
QXcbWindowFunctions::WmWindowTypes wmWindowTypes() const;
void setWmWindowType(QXcbWindowFunctions::WmWindowTypes types, Qt::WindowFlags flags);
void setWmWindowRole(const QByteArray &role);
static void setWindowIconTextStatic(QWindow *window, const QString &text);
WindowTypes wmWindowTypes() const;
void setWmWindowType(WindowTypes types, Qt::WindowFlags flags);
void setWindowType(WindowTypes windowTypes) override { setWmWindowType(windowTypes, window()->flags()); }
void setWindowRole(const QString &role) override;
void setParentRelativeBackPixmap();
bool requestSystemTrayWindowDock();
uint visualId() const;
uint visualId() const override;
bool needsSync() const;

View File

@ -62,6 +62,7 @@
# include "qaccessible.h"
#endif
#include <qpa/qplatformwindow.h>
#include <qpa/qplatformwindow_p.h>
#include "private/qwidgetwindow_p.h"
#include "qpainter.h"
#if QT_CONFIG(tooltip)
@ -113,8 +114,6 @@
#include "qwindowcontainer_p.h"
#include <QtPlatformHeaders/private/qxcbwindowfunctions_p.h>
#include <private/qmemory_p.h>
// widget/widget data creation count
@ -123,6 +122,8 @@
QT_BEGIN_NAMESPACE
using namespace QPlatformInterface::Private;
Q_LOGGING_CATEGORY(lcWidgetPainting, "qt.widgets.painting", QtWarningMsg);
static inline bool qRectIntersects(const QRect &r1, const QRect &r2)
@ -1334,8 +1335,12 @@ void QWidgetPrivate::create()
if (!win->isTopLevel()) // In a Widget world foreign windows can only be top level
data.window_flags &= ~Qt::ForeignWindow;
if (!topData()->role.isNull())
QXcbWindowFunctions::setWmWindowRole(win, topData()->role.toLatin1());
#if QT_CONFIG(xcb)
if (!topData()->role.isNull()) {
if (auto *xcbWindow = dynamic_cast<QXcbWindow*>(win->handle()))
xcbWindow->setWindowRole(topData()->role);
}
#endif
QBackingStore *store = q->backingStore();
@ -5896,11 +5901,17 @@ void QWidgetPrivate::setWindowIconText_helper(const QString &title)
void QWidgetPrivate::setWindowIconText_sys(const QString &iconText)
{
#if QT_CONFIG(xcb)
Q_Q(QWidget);
// ### The QWidget property is deprecated, but the XCB window function is not.
// It should remain available for the rare application that needs it.
if (QWindow *window = q->windowHandle())
QXcbWindowFunctions::setWmWindowIconText(window, iconText);
if (QWindow *window = q->windowHandle()) {
if (auto *xcbWindow = dynamic_cast<QXcbWindow*>(window->handle()))
xcbWindow->setWindowIconText(iconText);
}
#else
Q_UNUSED(iconText);
#endif
}
/*!
@ -6140,11 +6151,17 @@ QString QWidget::windowRole() const
*/
void QWidget::setWindowRole(const QString &role)
{
#if QT_CONFIG(xcb)
Q_D(QWidget);
d->createTLExtra();
d->topData()->role = role;
if (windowHandle())
QXcbWindowFunctions::setWmWindowRole(windowHandle(), role.toLatin1());
if (windowHandle()) {
if (auto *xcbWindow = dynamic_cast<QXcbWindow*>(windowHandle()->handle()))
xcbWindow->setWindowRole(role);
}
#else
Q_UNUSED(role);
#endif
}
/*!
@ -12738,43 +12755,48 @@ void QWidgetPrivate::setWidgetParentHelper(QObject *widgetAsObject, QObject *new
void QWidgetPrivate::setNetWmWindowTypes(bool skipIfMissing)
{
#if QT_CONFIG(xcb)
Q_Q(QWidget);
if (!q->windowHandle())
return;
int wmWindowType = 0;
QXcbWindow::WindowTypes wmWindowType = QXcbWindow::None;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDesktop))
wmWindowType |= QXcbWindowFunctions::Desktop;
wmWindowType |= QXcbWindow::Desktop;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDock))
wmWindowType |= QXcbWindowFunctions::Dock;
wmWindowType |= QXcbWindow::Dock;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolBar))
wmWindowType |= QXcbWindowFunctions::Toolbar;
wmWindowType |= QXcbWindow::Toolbar;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeMenu))
wmWindowType |= QXcbWindowFunctions::Menu;
wmWindowType |= QXcbWindow::Menu;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeUtility))
wmWindowType |= QXcbWindowFunctions::Utility;
wmWindowType |= QXcbWindow::Utility;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeSplash))
wmWindowType |= QXcbWindowFunctions::Splash;
wmWindowType |= QXcbWindow::Splash;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDialog))
wmWindowType |= QXcbWindowFunctions::Dialog;
wmWindowType |= QXcbWindow::Dialog;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDropDownMenu))
wmWindowType |= QXcbWindowFunctions::DropDownMenu;
wmWindowType |= QXcbWindow::DropDownMenu;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypePopupMenu))
wmWindowType |= QXcbWindowFunctions::PopupMenu;
wmWindowType |= QXcbWindow::PopupMenu;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeToolTip))
wmWindowType |= QXcbWindowFunctions::Tooltip;
wmWindowType |= QXcbWindow::Tooltip;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeNotification))
wmWindowType |= QXcbWindowFunctions::Notification;
wmWindowType |= QXcbWindow::Notification;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeCombo))
wmWindowType |= QXcbWindowFunctions::Combo;
wmWindowType |= QXcbWindow::Combo;
if (q->testAttribute(Qt::WA_X11NetWmWindowTypeDND))
wmWindowType |= QXcbWindowFunctions::Dnd;
wmWindowType |= QXcbWindow::Dnd;
if (wmWindowType == 0 && skipIfMissing)
if (wmWindowType == QXcbWindow::None && skipIfMissing)
return;
QXcbWindowFunctions::setWmWindowType(q->windowHandle(), static_cast<QXcbWindowFunctions::WmWindowType>(wmWindowType));
if (auto *xcbWindow = dynamic_cast<QXcbWindow*>(q->windowHandle()->handle()))
xcbWindow->setWindowType(wmWindowType);
#else
Q_UNUSED(skipIfMissing);
#endif
}
#ifndef QT_NO_DEBUG_STREAM