diff options
Diffstat (limited to 'src/plugins/shellintegration/xdg-shell')
15 files changed, 927 insertions, 448 deletions
diff --git a/src/plugins/shellintegration/xdg-shell/CMakeLists.txt b/src/plugins/shellintegration/xdg-shell/CMakeLists.txt new file mode 100644 index 000000000..af5a97fee --- /dev/null +++ b/src/plugins/shellintegration/xdg-shell/CMakeLists.txt @@ -0,0 +1,47 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: BSD-3-Clause + +# Generated from xdg-shell.pro. + +##################################################################### +## QWaylandXdgShellIntegrationPlugin Plugin: +##################################################################### + +qt_internal_add_plugin(QWaylandXdgShellIntegrationPlugin + OUTPUT_NAME xdg-shell + PLUGIN_TYPE wayland-shell-integration + SOURCES + main.cpp + qwaylandxdgdecorationv1.cpp qwaylandxdgdecorationv1_p.h + qwaylandxdgactivationv1.cpp qwaylandxdgactivationv1_p.h + qwaylandxdgshell.cpp qwaylandxdgshell_p.h + qwaylandxdgshellintegration.cpp qwaylandxdgshellintegration_p.h + qwaylandxdgexporterv2.cpp qwaylandxdgexporterv2_p.h + qwaylandxdgdialogv1.cpp qwaylandxdgdialogv1_p.h + LIBRARIES + Qt::Core + Qt::Gui + Qt::GuiPrivate + Qt::WaylandClientPrivate + Wayland::Client +) + +qt6_generate_wayland_protocol_client_sources(QWaylandXdgShellIntegrationPlugin + FILES + ${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-decoration-unstable-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-shell.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-activation-v1.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-foreign-unstable-v2.xml + ${CMAKE_CURRENT_SOURCE_DIR}/../../../3rdparty/protocol/xdg-dialog-v1.xml +) + +#### Keys ignored in scope 1:.:.:xdg-shell.pro:<TRUE>: +# OTHER_FILES = "xdg-shell.json" + +## Scopes: +##################################################################### + +qt_internal_extend_target(QWaylandXdgShellIntegrationPlugin CONDITION QT_FEATURE_xkbcommon + LIBRARIES + XKB::XKB +) diff --git a/src/plugins/shellintegration/xdg-shell/main.cpp b/src/plugins/shellintegration/xdg-shell/main.cpp index a9ea4bc1e..bb40a564e 100644 --- a/src/plugins/shellintegration/xdg-shell/main.cpp +++ b/src/plugins/shellintegration/xdg-shell/main.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwaylandxdgshellintegration_p.h" diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp new file mode 100644 index 000000000..8540724d8 --- /dev/null +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1.cpp @@ -0,0 +1,54 @@ +// Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qwaylandxdgactivationv1_p.h" +#include <QtWaylandClient/private/qwaylanddisplay_p.h> +#include <QtWaylandClient/private/qwaylandinputdevice_p.h> + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +QWaylandXdgActivationV1::QWaylandXdgActivationV1(wl_registry *registry, uint32_t id, + uint32_t availableVersion) + : QtWayland::xdg_activation_v1(registry, id, qMin(availableVersion, 1u)) +{ +} + +QWaylandXdgActivationV1::~QWaylandXdgActivationV1() +{ + Q_ASSERT(isInitialized()); + destroy(); +} + +QWaylandXdgActivationTokenV1 * +QWaylandXdgActivationV1::requestXdgActivationToken(QWaylandDisplay *display, + struct ::wl_surface *surface, + std::optional<uint32_t> serial, + const QString &app_id) +{ + auto wl = get_activation_token(); + auto provider = new QWaylandXdgActivationTokenV1; + provider->init(wl); + + if (surface) + provider->set_surface(surface); + + if (!app_id.isEmpty()) + provider->set_app_id(app_id); + + if (serial && display->lastInputDevice()) + provider->set_serial(*serial, display->lastInputDevice()->wl_seat()); + provider->commit(); + return provider; +} + +QWaylandXdgActivationTokenV1::~QWaylandXdgActivationTokenV1() +{ + destroy(); +} +} + +QT_END_NAMESPACE + +#include "moc_qwaylandxdgactivationv1_p.cpp" diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h new file mode 100644 index 000000000..bddb5c614 --- /dev/null +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgactivationv1_p.h @@ -0,0 +1,59 @@ +// Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWAYLANDXDGACTIVATIONV1_P_H +#define QWAYLANDXDGACTIVATIONV1_P_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 <QObject> +#include "qwayland-xdg-activation-v1.h" + +#include <QtWaylandClient/qtwaylandclientglobal.h> + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class QWaylandDisplay; +class QWaylandSurface; + +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgActivationTokenV1 + : public QObject, + public QtWayland::xdg_activation_token_v1 +{ + Q_OBJECT +public: + ~QWaylandXdgActivationTokenV1() override; + void xdg_activation_token_v1_done(const QString &token) override { Q_EMIT done(token); } + +Q_SIGNALS: + void done(const QString &token); +}; + +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgActivationV1 : public QtWayland::xdg_activation_v1 +{ +public: + QWaylandXdgActivationV1(struct ::wl_registry *registry, uint32_t id, uint32_t availableVersion); + ~QWaylandXdgActivationV1() override; + + QWaylandXdgActivationTokenV1 *requestXdgActivationToken(QWaylandDisplay *display, + struct ::wl_surface *surface, + std::optional<uint32_t> serial, + const QString &app_id); +}; + +QT_END_NAMESPACE + +} + +#endif // QWAYLANDXDGACTIVATIONV1_P_H diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp index c6e1afabc..23b846439 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwaylandxdgdecorationv1_p.h" #include "qwaylandxdgshell_p.h" diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h index c3a13ce32..8a0cc9e79 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdecorationv1_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2018 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests 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$ -** -****************************************************************************/ +// Copyright (C) 2018 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWAYLANDXDGDECORATIONV1_P_H #define QWAYLANDXDGDECORATIONV1_P_H @@ -64,7 +28,7 @@ namespace QtWaylandClient { class QWaylandXdgToplevel; class QWaylandXdgToplevelDecorationV1; -class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgDecorationManagerV1 : public QtWayland::zxdg_decoration_manager_v1 +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgDecorationManagerV1 : public QtWayland::zxdg_decoration_manager_v1 { public: QWaylandXdgDecorationManagerV1(struct ::wl_registry *registry, uint32_t id, uint32_t availableVersion); @@ -72,7 +36,7 @@ public: QWaylandXdgToplevelDecorationV1 *createToplevelDecoration(::xdg_toplevel *toplevel); }; -class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgToplevelDecorationV1 : public QtWayland::zxdg_toplevel_decoration_v1 +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgToplevelDecorationV1 : public QtWayland::zxdg_toplevel_decoration_v1 { public: QWaylandXdgToplevelDecorationV1(::zxdg_toplevel_decoration_v1 *decoration); diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1.cpp new file mode 100644 index 000000000..abf674623 --- /dev/null +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1.cpp @@ -0,0 +1,33 @@ +// Copyright (C) 2023 David Reondo <kde@david-redondo.de> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qwaylandxdgdialogv1_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +QWaylandXdgDialogV1::QWaylandXdgDialogV1(::xdg_dialog_v1 *object) : xdg_dialog_v1(object) { } + +QWaylandXdgDialogV1::~QWaylandXdgDialogV1() +{ + xdg_dialog_v1_destroy(object()); +} + +QWaylandXdgDialogWmV1::QWaylandXdgDialogWmV1(wl_registry *registry, uint32_t id, int version) + : xdg_wm_dialog_v1(registry, id, version) +{ +} + +QWaylandXdgDialogWmV1::~QWaylandXdgDialogWmV1() +{ + destroy(); +} +QWaylandXdgDialogV1 *QWaylandXdgDialogWmV1::getDialog(xdg_toplevel *toplevel) +{ + return new QWaylandXdgDialogV1(get_xdg_dialog(toplevel)); +} + +} // namespace QtWaylandClient + +QT_END_NAMESPACE diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h new file mode 100644 index 000000000..f5465a63e --- /dev/null +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgdialogv1_p.h @@ -0,0 +1,32 @@ +// Copyright (C) 2022 David Reondo <kde@david-redondo.de> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWAYLANDDIALOGV1_P_H +#define QWAYLANDDIALOGV1_P_H + +#include <qwayland-xdg-dialog-v1.h> + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class QWaylandXdgDialogV1 : public QtWayland::xdg_dialog_v1 +{ +public: + QWaylandXdgDialogV1(::xdg_dialog_v1 *object); + ~QWaylandXdgDialogV1() override; +}; + +class QWaylandXdgDialogWmV1 : public QtWayland::xdg_wm_dialog_v1 +{ +public: + QWaylandXdgDialogWmV1(wl_registry *registry, uint32_t id, int version); + ~QWaylandXdgDialogWmV1() override; + QWaylandXdgDialogV1 *getDialog(xdg_toplevel *toplevel); +}; + +} // namespace QtWaylandClient + +QT_END_NAMESPACE + +#endif diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2.cpp new file mode 100644 index 000000000..5cbbecc53 --- /dev/null +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2.cpp @@ -0,0 +1,41 @@ +// Copyright (C) 2022 David Reondo <kde@david-redondo.de> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#include "qwaylandxdgexporterv2_p.h" + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +QWaylandXdgExportedV2::QWaylandXdgExportedV2(::zxdg_exported_v2 *object) + : QtWayland::zxdg_exported_v2(object) +{ +} + +QWaylandXdgExportedV2::~QWaylandXdgExportedV2() +{ + destroy(); +} + +void QWaylandXdgExportedV2::zxdg_exported_v2_handle(const QString &handle) +{ + mHandle = handle; +} + +QString QWaylandXdgExportedV2::handle() const +{ + return mHandle; +} + +QWaylandXdgExporterV2::QWaylandXdgExporterV2(wl_registry *registry, uint32_t id, int version) + : QtWayland::zxdg_exporter_v2(registry, id, qMin(version, 1)) +{ +} + +QWaylandXdgExporterV2::~QWaylandXdgExporterV2() +{ + destroy(); +} +} + +QT_END_NAMESPACE diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h new file mode 100644 index 000000000..c993e390a --- /dev/null +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgexporterv2_p.h @@ -0,0 +1,49 @@ +// Copyright (C) 2022 David Reondo <kde@david-redondo.de> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only + +#ifndef QWAYLANDXDGEXPORTERV2_H +#define QWAYLANDXDGEXPORTERV2_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 <qwayland-xdg-foreign-unstable-v2.h> + +#include <QtWaylandClient/qtwaylandclientglobal.h> + +QT_BEGIN_NAMESPACE + +namespace QtWaylandClient { + +class QWaylandXdgExportedV2 : public QtWayland::zxdg_exported_v2 +{ +public: + explicit QWaylandXdgExportedV2(::zxdg_exported_v2 *object); + ~QWaylandXdgExportedV2() override; + QString handle() const; + +private: + void zxdg_exported_v2_handle(const QString &handle) override; + QString mHandle; +}; + +class QWaylandXdgExporterV2 : public QtWayland::zxdg_exporter_v2 +{ +public: + QWaylandXdgExporterV2(wl_registry *registry, uint32_t id, int version); + ~QWaylandXdgExporterV2() override; +}; + +} + +QT_END_NAMESPACE + +#endif // QWAYLANDXDGEXPORTERV2_H diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp index bd1f5a210..6e5e47da9 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell.cpp @@ -1,51 +1,21 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr> +// Copyright (C) 2023 David Edmundson <davidedmundson@kde.org> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qwaylandxdgshell_p.h" +#include "qwaylandxdgexporterv2_p.h" +#include "qwaylandxdgdialogv1_p.h" + #include <QtWaylandClient/private/qwaylanddisplay_p.h> #include <QtWaylandClient/private/qwaylandwindow_p.h> #include <QtWaylandClient/private/qwaylandinputdevice_p.h> #include <QtWaylandClient/private/qwaylandscreen_p.h> +#include <QtWaylandClient/private/qwaylandcursor_p.h> #include <QtWaylandClient/private/qwaylandabstractdecoration_p.h> +#include <QtGui/QGuiApplication> #include <QtGui/private/qwindow_p.h> QT_BEGIN_NAMESPACE @@ -56,21 +26,27 @@ QWaylandXdgSurface::Toplevel::Toplevel(QWaylandXdgSurface *xdgSurface) : QtWayland::xdg_toplevel(xdgSurface->get_toplevel()) , m_xdgSurface(xdgSurface) { - if (auto *decorationManager = m_xdgSurface->m_shell->decorationManager()) - m_decoration = decorationManager->createToplevelDecoration(object()); - QWindow *window = xdgSurface->window()->window(); + if (auto *decorationManager = m_xdgSurface->m_shell->decorationManager()) { + if (!(window->flags() & Qt::FramelessWindowHint)) + m_decoration = decorationManager->createToplevelDecoration(object()); + } requestWindowStates(window->windowStates()); requestWindowFlags(window->flags()); + if (auto transientParent = xdgSurface->window()->transientParent()) { + if (auto parentSurface = + qobject_cast<QWaylandXdgSurface *>(transientParent->shellSurface())) { + set_parent(parentSurface->m_toplevel->object()); + if (window->modality() != Qt::NonModal && m_xdgSurface->m_shell->m_xdgDialogWm) { + m_xdgDialog.reset(m_xdgSurface->m_shell->m_xdgDialogWm->getDialog(object())); + m_xdgDialog->set_modal(); + } + } + } } QWaylandXdgSurface::Toplevel::~Toplevel() { - if (m_applied.states & Qt::WindowActive) { - QWaylandWindow *window = m_xdgSurface->window(); - window->display()->handleWindowDeactivated(window); - } - // The protocol spec requires that the decoration object is deleted before xdg_toplevel. delete m_decoration; m_decoration = nullptr; @@ -82,31 +58,53 @@ QWaylandXdgSurface::Toplevel::~Toplevel() void QWaylandXdgSurface::Toplevel::applyConfigure() { if (!(m_applied.states & (Qt::WindowMaximized|Qt::WindowFullScreen))) - m_normalSize = m_xdgSurface->m_window->window()->frameGeometry().size(); + m_normalSize = m_xdgSurface->m_window->windowContentGeometry().size(); - if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive)) + if ((m_pending.states & Qt::WindowActive) && !(m_applied.states & Qt::WindowActive) + && !m_xdgSurface->m_window->display()->isKeyboardAvailable()) m_xdgSurface->m_window->display()->handleWindowActivated(m_xdgSurface->m_window); - if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive)) + if (!(m_pending.states & Qt::WindowActive) && (m_applied.states & Qt::WindowActive) + && !m_xdgSurface->m_window->display()->isKeyboardAvailable()) m_xdgSurface->m_window->display()->handleWindowDeactivated(m_xdgSurface->m_window); - // TODO: none of the other plugins send WindowActive either, but is it on purpose? - Qt::WindowStates statesWithoutActive = m_pending.states & ~Qt::WindowActive; + m_xdgSurface->m_window->handleToplevelWindowTilingStatesChanged(m_toplevelStates); + m_xdgSurface->m_window->handleWindowStatesChanged(m_pending.states); - m_xdgSurface->m_window->handleWindowStatesChanged(statesWithoutActive); + // If the width or height is zero, the client should decide the size on its own. + QSize surfaceSize; - if (m_pending.size.isEmpty()) { - // An empty size in the configure means it's up to the client to choose the size - bool normalPending = !(m_pending.states & (Qt::WindowMaximized|Qt::WindowFullScreen)); - if (normalPending && !m_normalSize.isEmpty()) - m_xdgSurface->m_window->resizeFromApplyConfigure(m_normalSize); + if (m_pending.size.width() > 0) { + surfaceSize.setWidth(m_pending.size.width()); } else { - m_xdgSurface->m_window->resizeFromApplyConfigure(m_pending.size); + if (Q_UNLIKELY(m_pending.states & (Qt::WindowMaximized | Qt::WindowFullScreen))) { + qCWarning(lcQpaWayland) << "Configure event with maximized or fullscreen state contains invalid width:" << m_pending.size.width(); + } else { + int width = m_normalSize.width(); + if (!m_pending.bounds.isEmpty()) + width = std::min(width, m_pending.bounds.width()); + surfaceSize.setWidth(width); + } } - m_xdgSurface->setSizeHints(); + if (m_pending.size.height() > 0) { + surfaceSize.setHeight(m_pending.size.height()); + } else { + if (Q_UNLIKELY(m_pending.states & (Qt::WindowMaximized | Qt::WindowFullScreen))) { + qCWarning(lcQpaWayland) << "Configure event with maximized or fullscreen state contains invalid height:" << m_pending.size.height(); + } else { + int height = m_normalSize.height(); + if (!m_pending.bounds.isEmpty()) + height = std::min(height, m_pending.bounds.height()); + surfaceSize.setHeight(height); + } + } m_applied = m_pending; + + if (!surfaceSize.isEmpty()) + m_xdgSurface->m_window->resizeFromApplyConfigure(surfaceSize.grownBy(m_xdgSurface->m_window->windowContentMargins())); + qCDebug(lcQpaWayland) << "Applied pending xdg_toplevel configure event:" << m_applied.size << m_applied.states; } @@ -119,6 +117,11 @@ bool QWaylandXdgSurface::Toplevel::wantsDecorations() return !(m_pending.states & Qt::WindowFullScreen); } +void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure_bounds(int32_t width, int32_t height) +{ + m_pending.bounds = QSize(width, height); +} + void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states) { m_pending.size = QSize(width, height); @@ -126,7 +129,9 @@ void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t auto *xdgStates = static_cast<uint32_t *>(states->data); size_t numStates = states->size / sizeof(uint32_t); + m_pending.suspended = false; m_pending.states = Qt::WindowNoState; + m_toplevelStates = QWaylandWindow::WindowNoState; for (size_t i = 0; i < numStates; i++) { switch (xdgStates[i]) { @@ -139,6 +144,21 @@ void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t case XDG_TOPLEVEL_STATE_FULLSCREEN: m_pending.states |= Qt::WindowFullScreen; break; + case XDG_TOPLEVEL_STATE_TILED_LEFT: + m_toplevelStates |= QWaylandWindow::WindowTiledLeft; + break; + case XDG_TOPLEVEL_STATE_TILED_RIGHT: + m_toplevelStates |= QWaylandWindow::WindowTiledRight; + break; + case XDG_TOPLEVEL_STATE_TILED_TOP: + m_toplevelStates |= QWaylandWindow::WindowTiledTop; + break; + case XDG_TOPLEVEL_STATE_TILED_BOTTOM: + m_toplevelStates |= QWaylandWindow::WindowTiledBottom; + break; + case XDG_TOPLEVEL_STATE_SUSPENDED: + m_pending.suspended = true; + break; default: break; } @@ -149,16 +169,18 @@ void QWaylandXdgSurface::Toplevel::xdg_toplevel_configure(int32_t width, int32_t void QWaylandXdgSurface::Toplevel::xdg_toplevel_close() { - m_xdgSurface->m_window->window()->close(); + QWindowSystemInterface::handleCloseEvent(m_xdgSurface->m_window->window()); } void QWaylandXdgSurface::Toplevel::requestWindowFlags(Qt::WindowFlags flags) { if (m_decoration) { - if (flags & Qt::FramelessWindowHint) - m_decoration->requestMode(QWaylandXdgToplevelDecorationV1::mode_client_side); - else + if (flags & Qt::FramelessWindowHint) { + delete m_decoration; + m_decoration = nullptr; + } else { m_decoration->unsetMode(); + } } } @@ -167,6 +189,15 @@ void QWaylandXdgSurface::Toplevel::requestWindowStates(Qt::WindowStates states) // Re-send what's different from the applied state Qt::WindowStates changedStates = m_applied.states ^ states; + // Minimized state is not reported by the protocol, so always send it + if (states & Qt::WindowMinimized) { + set_minimized(); + m_xdgSurface->window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized); + // The internal window state whilst minimized is not maximised or fullscreen, but we don't want to + // update the compositors cached version of this state + return; + } + if (changedStates & Qt::WindowMaximized) { if (states & Qt::WindowMaximized) set_maximized(); @@ -175,17 +206,16 @@ void QWaylandXdgSurface::Toplevel::requestWindowStates(Qt::WindowStates states) } if (changedStates & Qt::WindowFullScreen) { - if (states & Qt::WindowFullScreen) - set_fullscreen(nullptr); - else + if (states & Qt::WindowFullScreen) { + auto screen = m_xdgSurface->window()->waylandScreen(); + if (screen) { + set_fullscreen(screen->output()); + } + } else unset_fullscreen(); } - // Minimized state is not reported by the protocol, so always send it - if (states & Qt::WindowMinimized) { - set_minimized(); - m_xdgSurface->window()->handleWindowStatesChanged(states & ~Qt::WindowMinimized); - } + } QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResizeEdges(Qt::Edges edges) @@ -197,12 +227,15 @@ QtWayland::xdg_toplevel::resize_edge QWaylandXdgSurface::Toplevel::convertToResi | ((edges & Qt::RightEdge) ? resize_edge_right : 0)); } -QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, - QtWayland::xdg_positioner *positioner) - : xdg_popup(xdgSurface->get_popup(parent->object(), positioner->object())) - , m_xdgSurface(xdgSurface) +QWaylandXdgSurface::Popup::Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, + Positioner *positioner) + : m_xdgSurface(xdgSurface) + , m_parentXdgSurface(qobject_cast<QWaylandXdgSurface *>(parent->shellSurface())) , m_parent(parent) { + + init(xdgSurface->get_popup(m_parentXdgSurface ? m_parentXdgSurface->object() : nullptr, + positioner->object())); } QWaylandXdgSurface::Popup::~Popup() @@ -211,22 +244,59 @@ QWaylandXdgSurface::Popup::~Popup() destroy(); if (m_grabbing) { - auto *shell = m_xdgSurface->m_shell; - Q_ASSERT(shell->m_topmostGrabbingPopup == this); - shell->m_topmostGrabbingPopup = m_parent->m_popup; + m_grabbing = false; + + // Synthesize Qt enter/leave events for popup + QWindow *leave = nullptr; + if (m_xdgSurface && m_xdgSurface->window()) + leave = m_xdgSurface->window()->window(); + QWindowSystemInterface::handleLeaveEvent(leave); + + QWindow *enter = nullptr; + if (m_parentXdgSurface && m_parentXdgSurface->window()) { + enter = m_parentXdgSurface->window()->window(); + const auto pos = m_xdgSurface->window()->display()->waylandCursor()->pos(); + QWindowSystemInterface::handleEnterEvent(enter, enter->handle()->mapFromGlobal(pos), pos); + } + } +} + +void QWaylandXdgSurface::Popup::applyConfigure() +{ + if (m_pendingGeometry.isValid()) { + QRect geometryWithMargins = m_pendingGeometry.marginsAdded(m_xdgSurface->m_window->windowContentMargins()); + QMargins parentMargins = m_parent->windowContentMargins() - m_parent->clientSideMargins(); + QRect globalGeometry = geometryWithMargins.translated(m_parent->geometry().topLeft() + QPoint(parentMargins.left(), parentMargins.top())); + m_xdgSurface->setGeometryFromApplyConfigure(globalGeometry.topLeft(), globalGeometry.size()); } + resetConfiguration(); +} + +void QWaylandXdgSurface::Popup::resetConfiguration() +{ + m_pendingGeometry = QRect(); } void QWaylandXdgSurface::Popup::grab(QWaylandInputDevice *seat, uint serial) { - m_xdgSurface->m_shell->m_topmostGrabbingPopup = this; xdg_popup::grab(seat->wl_seat(), serial); m_grabbing = true; } +void QWaylandXdgSurface::Popup::xdg_popup_configure(int32_t x, int32_t y, int32_t width, int32_t height) +{ + m_pendingGeometry = QRect(x, y, width, height); +} + void QWaylandXdgSurface::Popup::xdg_popup_popup_done() { - m_xdgSurface->m_window->window()->close(); + QWindowSystemInterface::handleCloseEvent(m_xdgSurface->m_window->window()); +} + +void QWaylandXdgSurface::Popup::xdg_popup_repositioned(uint32_t token) +{ + if (token == m_waitingForRepositionSerial) + m_waitingForReposition = false; } QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *surface, QWaylandWindow *window) @@ -245,12 +315,8 @@ QWaylandXdgSurface::QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *s setGrabPopup(transientParent, display->lastInputDevice(), display->lastInputSerial()); } else { setToplevel(); - if (transientParent) { - auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(transientParent->shellSurface()); - if (parentXdgSurface) - m_toplevel->set_parent(parentXdgSurface->m_toplevel->object()); - } } + setSizeHints(); } QWaylandXdgSurface::~QWaylandXdgSurface() @@ -266,11 +332,14 @@ QWaylandXdgSurface::~QWaylandXdgSurface() destroy(); } -void QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) +bool QWaylandXdgSurface::resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) { - Q_ASSERT(m_toplevel && m_toplevel->isInitialized()); + if (!m_toplevel || !m_toplevel->isInitialized()) + return false; + auto resizeEdges = Toplevel::convertToResizeEdges(edges); m_toplevel->resize(inputDevice->wl_seat(), inputDevice->serial(), resizeEdges); + return true; } bool QWaylandXdgSurface::move(QWaylandInputDevice *inputDevice) @@ -302,6 +371,8 @@ void QWaylandXdgSurface::setAppId(const QString &appId) { if (m_toplevel) m_toplevel->set_app_id(appId); + + m_appId = appId; } void QWaylandXdgSurface::setWindowFlags(Qt::WindowFlags flags) @@ -312,29 +383,46 @@ void QWaylandXdgSurface::setWindowFlags(Qt::WindowFlags flags) bool QWaylandXdgSurface::isExposed() const { - return m_configured || m_pendingConfigureSerial; + if (m_toplevel && m_toplevel->m_applied.suspended) + return false; + + // the popup repositioning specification is async + // we need to defer commits between our resize request + // and our new popup position being set + if (m_popup && m_popup->m_waitingForReposition) + return false; + + return m_configured; } bool QWaylandXdgSurface::handleExpose(const QRegion ®ion) { if (!isExposed() && !region.isEmpty()) { - m_exposeRegion = region; return true; } + setWindowGeometry(window()->windowContentGeometry()); return false; } void QWaylandXdgSurface::applyConfigure() { - Q_ASSERT(m_pendingConfigureSerial != 0); + bool wasExposed = isExposed(); + + // It is a redundant ack_configure, so skipped. + if (m_pendingConfigureSerial == m_appliedConfigureSerial) + return; if (m_toplevel) m_toplevel->applyConfigure(); + if (m_popup) + m_popup->applyConfigure(); + m_appliedConfigureSerial = m_pendingConfigureSerial; m_configured = true; - ack_configure(m_pendingConfigureSerial); + ack_configure(m_appliedConfigureSerial); - m_pendingConfigureSerial = 0; + if (!wasExposed && isExposed()) + m_window->sendRecursiveExposeEvent(); } bool QWaylandXdgSurface::wantsDecorations() const @@ -345,33 +433,60 @@ bool QWaylandXdgSurface::wantsDecorations() const void QWaylandXdgSurface::propagateSizeHints() { setSizeHints(); - - if (m_toplevel && m_window) - m_window->commit(); } void QWaylandXdgSurface::setWindowGeometry(const QRect &rect) { - set_window_geometry(rect.x(), rect.y(), rect.width(), rect.height()); + if (window()->isExposed()) + set_window_geometry(rect.x(), rect.y(), rect.width(), rect.height()); } void QWaylandXdgSurface::setSizeHints() { if (m_toplevel && m_window) { - const int minWidth = qMax(0, m_window->windowMinimumSize().width()); - const int minHeight = qMax(0, m_window->windowMinimumSize().height()); - m_toplevel->set_min_size(minWidth, minHeight); + const QMargins margins = m_window->windowContentMargins() - m_window->clientSideMargins(); + const QSize minSize = m_window->windowMinimumSize().shrunkBy(margins); + const QSize maxSize = m_window->windowMaximumSize().shrunkBy(margins); + const int minWidth = qMax(0, minSize.width()); + const int minHeight = qMax(0, minSize.height()); + int maxWidth = qMax(0, maxSize.width()); + int maxHeight = qMax(0, maxSize.height()); + + // It will not change min/max sizes if invalid. + if (minWidth > maxWidth || minHeight > maxHeight) + return; - int maxWidth = qMax(0, m_window->windowMaximumSize().width()); if (maxWidth == QWINDOWSIZE_MAX) maxWidth = 0; - int maxHeight = qMax(0, m_window->windowMaximumSize().height()); if (maxHeight == QWINDOWSIZE_MAX) maxHeight = 0; + + m_toplevel->set_min_size(minWidth, minHeight); m_toplevel->set_max_size(maxWidth, maxHeight); } } +void *QWaylandXdgSurface::nativeResource(const QByteArray &resource) +{ + QByteArray lowerCaseResource = resource.toLower(); + if (lowerCaseResource == "xdg_surface") + return object(); + else if (lowerCaseResource == "xdg_toplevel" && m_toplevel) + return m_toplevel->object(); + else if (lowerCaseResource == "xdg_popup" && m_popup) + return m_popup->object(); + return nullptr; +} + +std::any QWaylandXdgSurface::surfaceRole() const +{ + if (m_toplevel) + return m_toplevel->object(); + if (m_popup) + return m_popup->object(); + return {}; +} + void QWaylandXdgSurface::requestWindowStates(Qt::WindowStates states) { if (m_toplevel) @@ -390,43 +505,29 @@ void QWaylandXdgSurface::setPopup(QWaylandWindow *parent) { Q_ASSERT(!m_toplevel && !m_popup); - auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface()); - - auto positioner = new QtWayland::xdg_positioner(m_shell->create_positioner()); - // set_popup expects a position relative to the parent - QPoint transientPos = m_window->geometry().topLeft(); // this is absolute - transientPos -= parent->geometry().topLeft(); - if (parent->decoration()) { - transientPos.setX(transientPos.x() + parent->decoration()->margins().left()); - transientPos.setY(transientPos.y() + parent->decoration()->margins().top()); - } - positioner->set_anchor_rect(transientPos.x(), transientPos.y(), 1, 1); - positioner->set_anchor(QtWayland::xdg_positioner::anchor_top_left); - positioner->set_gravity(QtWayland::xdg_positioner::gravity_bottom_right); - positioner->set_size(m_window->geometry().width(), m_window->geometry().height()); - m_popup = new Popup(this, parentXdgSurface, positioner); - positioner->destroy(); - delete positioner; + std::unique_ptr<Positioner> positioner = createPositioner(parent); + m_popup = new Popup(this, parent, positioner.get()); } void QWaylandXdgSurface::setGrabPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial) { - auto parentXdgSurface = static_cast<QWaylandXdgSurface *>(parent->shellSurface()); - auto *top = m_shell->m_topmostGrabbingPopup; - - if (top && top->m_xdgSurface != parentXdgSurface) { - qCWarning(lcQpaWayland) << "setGrabPopup called with a parent," << parentXdgSurface - << "which does not match the current topmost grabbing popup," - << top->m_xdgSurface << "According to the xdg-shell protocol, this" - << "is not allowed. The wayland QPA plugin is currently handling" - << "it by setting the parent to the topmost grabbing popup." - << "Note, however, that this may cause positioning errors and" - << "popups closing unxpectedly because xdg-shell mandate that child" - << "popups close before parents"; - parent = top->m_xdgSurface->m_window; - } setPopup(parent); m_popup->grab(device, serial); + + // Synthesize Qt enter/leave events for popup + if (!parent) + return; + QWindow *leave = parent->window(); + QWindowSystemInterface::handleLeaveEvent(leave); + + QWindow *enter = nullptr; + if (m_popup && m_popup->m_xdgSurface && m_popup->m_xdgSurface->window()) + enter = m_popup->m_xdgSurface->window()->window(); + + if (enter) { + const auto pos = m_popup->m_xdgSurface->window()->display()->waylandCursor()->pos(); + QWindowSystemInterface::handleEnterEvent(enter, enter->handle()->mapFromGlobal(pos), pos); + } } void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial) @@ -435,40 +536,258 @@ void QWaylandXdgSurface::xdg_surface_configure(uint32_t serial) if (!m_configured) { // We have to do the initial applyConfigure() immediately, since that is the expose. applyConfigure(); - m_exposeRegion = QRegion(QRect(QPoint(), m_window->geometry().size())); } else { // Later configures are probably resizes, so we have to queue them up for a time when we // are not painting to the window. m_window->applyConfigureWhenPossible(); } +} - if (!m_exposeRegion.isEmpty()) { - m_window->handleExpose(m_exposeRegion); - m_exposeRegion = QRegion(); +bool QWaylandXdgSurface::requestActivate() +{ + if (auto *activation = m_shell->activation()) { + if (!m_activationToken.isEmpty()) { + activation->activate(m_activationToken, window()->wlSurface()); + m_activationToken = {}; + return true; + } else if (const auto token = qEnvironmentVariable("XDG_ACTIVATION_TOKEN"); !token.isEmpty()) { + activation->activate(token, window()->wlSurface()); + qunsetenv("XDG_ACTIVATION_TOKEN"); + return true; + } else { + const auto focusWindow = QGuiApplication::focusWindow(); + // At least GNOME requires to request the token in order to get the + // focus stealing prevention indication, so requestXdgActivationToken call + // is still necessary in that case. + const auto wlWindow = focusWindow ? static_cast<QWaylandWindow*>(focusWindow->handle()) : m_window; + + QString appId; + if (const auto xdgSurface = qobject_cast<QWaylandXdgSurface *>(wlWindow->shellSurface())) + appId = xdgSurface->m_appId; + + if (const auto seat = wlWindow->display()->lastInputDevice()) { + const auto tokenProvider = activation->requestXdgActivationToken( + wlWindow->display(), wlWindow->wlSurface(), seat->serial(), appId); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, + [this, tokenProvider](const QString &token) { + m_shell->activation()->activate(token, window()->wlSurface()); + tokenProvider->deleteLater(); + }); + return true; + } + } } + return false; } -QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion) - : QtWayland::xdg_wm_base(display->wl_registry(), id, qMin(availableVersion, 1u)) - , m_display(display) +bool QWaylandXdgSurface::requestActivateOnShow() { - display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this); + const Qt::WindowType type = m_window->window()->type(); + if (type == Qt::ToolTip || type == Qt::Popup || type == Qt::SplashScreen) + return false; + + if (m_window->window()->property("_q_showWithoutActivating").toBool()) + return false; + + return requestActivate(); } -QWaylandXdgShell::~QWaylandXdgShell() +void QWaylandXdgSurface::requestXdgActivationToken(quint32 serial) { - m_display->removeListener(&QWaylandXdgShell::handleRegistryGlobal, this); - destroy(); + if (auto *activation = m_shell->activation()) { + auto tokenProvider = activation->requestXdgActivationToken( + m_shell->m_display, m_window->wlSurface(), serial, m_appId); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, + [this, tokenProvider](const QString &token) { + Q_EMIT m_window->xdgActivationTokenCreated(token); + tokenProvider->deleteLater(); + }); + } else { + QWaylandShellSurface::requestXdgActivationToken(serial); + } +} + +void QWaylandXdgSurface::setXdgActivationToken(const QString &token) +{ + if (m_shell->activation()) { + m_activationToken = token; + } else { + qCWarning(lcQpaWayland) << "zxdg_activation_v1 not available"; + } +} + +void QWaylandXdgSurface::setAlertState(bool enabled) +{ + if (m_alertState == enabled) + return; + + m_alertState = enabled; + + if (!m_alertState) + return; + + auto *activation = m_shell->activation(); + if (!activation) + return; + + const auto tokenProvider = activation->requestXdgActivationToken( + m_shell->m_display, m_window->wlSurface(), std::nullopt, m_appId); + connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, + [this, tokenProvider](const QString &token) { + m_shell->activation()->activate(token, m_window->wlSurface()); + tokenProvider->deleteLater(); + }); } -QWaylandXdgSurface *QWaylandXdgShell::getXdgSurface(QWaylandWindow *window) +QString QWaylandXdgSurface::externWindowHandle() { - return new QWaylandXdgSurface(this, get_xdg_surface(window->wlSurface()), window); + if (!m_toplevel || !m_shell->exporter()) { + return QString(); + } + if (!m_toplevel->m_exported) { + auto *exporterWrapper = static_cast<zxdg_exporter_v2 *>( + wl_proxy_create_wrapper(m_shell->exporter()->object())); + auto exportQueue = wl_display_create_queue(m_shell->display()->wl_display()); + wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(exporterWrapper), exportQueue); + m_toplevel->m_exported.reset(new QWaylandXdgExportedV2( + zxdg_exporter_v2_export_toplevel(exporterWrapper, m_window->wlSurface()))); + // handle events is sent immediately + wl_display_roundtrip_queue(m_shell->display()->wl_display(), exportQueue); + + wl_proxy_set_queue(reinterpret_cast<wl_proxy *>(m_toplevel->m_exported->object()), nullptr); + wl_proxy_wrapper_destroy(exporterWrapper); + wl_event_queue_destroy(exportQueue); + } + return m_toplevel->m_exported->handle(); } -void QWaylandXdgShell::xdg_wm_base_ping(uint32_t serial) +void QWaylandXdgSurface::setWindowPosition(const QPoint &position) { - pong(serial); + Q_UNUSED(position); + + if (!m_popup) + return; + + if (m_popup->version() < XDG_POPUP_REPOSITIONED_SINCE_VERSION) + return; + + std::unique_ptr<Positioner> positioner = createPositioner(m_window->transientParent()); + m_popup->m_waitingForRepositionSerial++; + m_popup->reposition(positioner->object(), m_popup->m_waitingForRepositionSerial); + m_popup->m_waitingForReposition = true; +} + +std::unique_ptr<QWaylandXdgSurface::Positioner> QWaylandXdgSurface::createPositioner(QWaylandWindow *parent) +{ + std::unique_ptr<Positioner> positioner(new Positioner(m_shell)); + // set_popup expects a position relative to the parent + QRect windowGeometry = m_window->windowContentGeometry(); + QMargins windowMargins = m_window->windowContentMargins() - m_window->clientSideMargins(); + QMargins parentMargins = parent->windowContentMargins() - parent->clientSideMargins(); + + // These property overrides may be removed when public API becomes available + QRect placementAnchor = m_window->window()->property("_q_waylandPopupAnchorRect").toRect(); + if (!placementAnchor.isValid()) { + placementAnchor = QRect(m_window->geometry().topLeft() - parent->geometry().topLeft(), QSize(1,1)); + } + placementAnchor.translate(windowMargins.left(), windowMargins.top()); + placementAnchor.translate(-parentMargins.left(), -parentMargins.top()); + + uint32_t anchor = QtWayland::xdg_positioner::anchor_top_left; + const QVariant anchorVariant = m_window->window()->property("_q_waylandPopupAnchor"); + if (anchorVariant.isValid()) { + switch (anchorVariant.value<Qt::Edges>()) { + case Qt::Edges(): + anchor = QtWayland::xdg_positioner::anchor_none; + break; + case Qt::TopEdge: + anchor = QtWayland::xdg_positioner::anchor_top; + break; + case Qt::TopEdge | Qt::RightEdge: + anchor = QtWayland::xdg_positioner::anchor_top_right; + break; + case Qt::RightEdge: + anchor = QtWayland::xdg_positioner::anchor_right; + break; + case Qt::BottomEdge | Qt::RightEdge: + anchor = QtWayland::xdg_positioner::anchor_bottom_right; + break; + case Qt::BottomEdge: + anchor = QtWayland::xdg_positioner::anchor_bottom; + break; + case Qt::BottomEdge | Qt::LeftEdge: + anchor = QtWayland::xdg_positioner::anchor_bottom_left; + break; + case Qt::LeftEdge: + anchor = QtWayland::xdg_positioner::anchor_left; + break; + case Qt::TopEdge | Qt::LeftEdge: + anchor = QtWayland::xdg_positioner::anchor_top_left; + break; + } + } + + uint32_t gravity = QtWayland::xdg_positioner::gravity_bottom_right; + const QVariant popupGravityVariant = m_window->window()->property("_q_waylandPopupGravity"); + if (popupGravityVariant.isValid()) { + switch (popupGravityVariant.value<Qt::Edges>()) { + case Qt::Edges(): + gravity = QtWayland::xdg_positioner::gravity_none; + break; + case Qt::TopEdge: + gravity = QtWayland::xdg_positioner::gravity_top; + break; + case Qt::TopEdge | Qt::RightEdge: + gravity = QtWayland::xdg_positioner::gravity_top_right; + break; + case Qt::RightEdge: + gravity = QtWayland::xdg_positioner::gravity_right; + break; + case Qt::BottomEdge | Qt::RightEdge: + gravity = QtWayland::xdg_positioner::gravity_bottom_right; + break; + case Qt::BottomEdge: + gravity = QtWayland::xdg_positioner::gravity_bottom; + break; + case Qt::BottomEdge | Qt::LeftEdge: + gravity = QtWayland::xdg_positioner::gravity_bottom_left; + break; + case Qt::LeftEdge: + gravity = QtWayland::xdg_positioner::gravity_left; + break; + case Qt::TopEdge | Qt::LeftEdge: + gravity = QtWayland::xdg_positioner::gravity_top_left; + break; + } + } + + uint32_t constraintAdjustment = QtWayland::xdg_positioner::constraint_adjustment_slide_x | QtWayland::xdg_positioner::constraint_adjustment_slide_y; + const QVariant constraintAdjustmentVariant = m_window->window()->property("_q_waylandPopupConstraintAdjustment"); + if (constraintAdjustmentVariant.isValid()) { + constraintAdjustment = constraintAdjustmentVariant.toUInt(); + } + + positioner->set_anchor_rect(placementAnchor.x(), + placementAnchor.y(), + placementAnchor.width(), + placementAnchor.height()); + positioner->set_anchor(anchor); + positioner->set_gravity(gravity); + positioner->set_size(windowGeometry.width(), windowGeometry.height()); + positioner->set_constraint_adjustment(constraintAdjustment); + return positioner; +} + + +QWaylandXdgShell::QWaylandXdgShell(QWaylandDisplay *display, QtWayland::xdg_wm_base *xdgWmBase) + : m_display(display), m_xdgWmBase(xdgWmBase) +{ + display->addRegistryListener(&QWaylandXdgShell::handleRegistryGlobal, this); +} + +QWaylandXdgShell::~QWaylandXdgShell() +{ + m_display->removeListener(&QWaylandXdgShell::handleRegistryGlobal, this); } void QWaylandXdgShell::handleRegistryGlobal(void *data, wl_registry *registry, uint id, @@ -477,8 +796,32 @@ void QWaylandXdgShell::handleRegistryGlobal(void *data, wl_registry *registry, u QWaylandXdgShell *xdgShell = static_cast<QWaylandXdgShell *>(data); if (interface == QLatin1String(QWaylandXdgDecorationManagerV1::interface()->name)) xdgShell->m_xdgDecorationManager.reset(new QWaylandXdgDecorationManagerV1(registry, id, version)); + + if (interface == QLatin1String(QWaylandXdgActivationV1::interface()->name)) { + xdgShell->m_xdgActivation.reset(new QWaylandXdgActivationV1(registry, id, version)); + } + + if (interface == QLatin1String(QWaylandXdgExporterV2::interface()->name)) { + xdgShell->m_xdgExporter.reset(new QWaylandXdgExporterV2(registry, id, version)); + } + + if (interface == QLatin1String(QWaylandXdgDialogWmV1::interface()->name)) { + xdgShell->m_xdgDialogWm.reset(new QWaylandXdgDialogWmV1(registry, id, version)); + } +} + +QWaylandXdgSurface::Positioner::Positioner(QWaylandXdgShell *xdgShell) + : QtWayland::xdg_positioner(xdgShell->m_xdgWmBase->create_positioner()) +{ +} + +QWaylandXdgSurface::Positioner::~Positioner() +{ + destroy(); } } QT_END_NAMESPACE + +#include "moc_qwaylandxdgshell_p.cpp" diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h index 8f8682a47..d18ce4d72 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshell_p.h @@ -1,42 +1,6 @@ -/**************************************************************************** -** -** Copyright (C) 2017 The Qt Company Ltd. -** Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr> -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the config.tests 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// Copyright (C) 2017 Eurogiciel, author: <philippe.coval@eurogiciel.fr> +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWAYLANDXDGSHELL_H #define QWAYLANDXDGSHELL_H @@ -55,9 +19,11 @@ #include "qwayland-xdg-shell.h" #include "qwaylandxdgdecorationv1_p.h" +#include "qwaylandxdgactivationv1_p.h" #include <QtWaylandClient/qtwaylandclientglobal.h> #include <QtWaylandClient/private/qwaylandshellsurface_p.h> +#include <QtWaylandClient/private/qwaylandwindow_p.h> #include <QtCore/QSize> #include <QtGui/QRegion> @@ -69,18 +35,21 @@ class QWindow; namespace QtWaylandClient { class QWaylandDisplay; -class QWaylandWindow; class QWaylandInputDevice; class QWaylandXdgShell; +class QWaylandXdgExportedV2; +class QWaylandXdgExporterV2; +class QWaylandXdgDialogWmV1; +class QWaylandXdgDialogV1; -class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface, public QtWayland::xdg_surface +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgSurface : public QWaylandShellSurface, public QtWayland::xdg_surface { Q_OBJECT public: QWaylandXdgSurface(QWaylandXdgShell *shell, ::xdg_surface *surface, QWaylandWindow *window); ~QWaylandXdgSurface() override; - void resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; + bool resize(QWaylandInputDevice *inputDevice, Qt::Edges edges) override; bool move(QWaylandInputDevice *inputDevice) override; bool showWindowMenu(QWaylandInputDevice *seat) override; void setTitle(const QString &title) override; @@ -94,9 +63,21 @@ public: bool wantsDecorations() const override; void propagateSizeHints() override; void setWindowGeometry(const QRect &rect) override; + bool requestActivate() override; + bool requestActivateOnShow() override; + void setXdgActivationToken(const QString &token) override; + void requestXdgActivationToken(quint32 serial) override; + void setAlertState(bool enabled) override; + bool isAlertState() const override { return m_alertState; } + QString externWindowHandle() override; + void setWindowPosition(const QPoint &position) override; void setSizeHints(); + void *nativeResource(const QByteArray &resource); + + std::any surfaceRole() const override; + protected: void requestWindowStates(Qt::WindowStates states) override; void xdg_surface_configure(uint32_t serial) override; @@ -113,6 +94,7 @@ private: void xdg_toplevel_configure(int32_t width, int32_t height, wl_array *states) override; void xdg_toplevel_close() override; + void xdg_toplevel_configure_bounds(int32_t width, int32_t height) override; void requestWindowFlags(Qt::WindowFlags flags); void requestWindowStates(Qt::WindowStates states); @@ -120,62 +102,91 @@ private: static resize_edge convertToResizeEdges(Qt::Edges edges); struct { + QSize bounds = {0, 0}; QSize size = {0, 0}; Qt::WindowStates states = Qt::WindowNoState; + bool suspended = false; } m_pending, m_applied; + QWaylandWindow::ToplevelWindowTilingStates m_toplevelStates = QWaylandWindow::WindowNoState; QSize m_normalSize; QWaylandXdgSurface *m_xdgSurface = nullptr; QWaylandXdgToplevelDecorationV1 *m_decoration = nullptr; + QScopedPointer<QWaylandXdgExportedV2> m_exported; + QScopedPointer<QWaylandXdgDialogV1> m_xdgDialog; + }; + + class Positioner : public QtWayland::xdg_positioner { + public: + Positioner(QWaylandXdgShell *xdgShell); + ~Positioner() override; }; class Popup : public QtWayland::xdg_popup { public: - Popup(QWaylandXdgSurface *xdgSurface, QWaylandXdgSurface *parent, QtWayland::xdg_positioner *positioner); + Popup(QWaylandXdgSurface *xdgSurface, QWaylandWindow *parent, Positioner *positioner); ~Popup() override; + void applyConfigure(); + void resetConfiguration(); + void grab(QWaylandInputDevice *seat, uint serial); + void xdg_popup_configure(int32_t x, int32_t y, int32_t width, int32_t height) override; void xdg_popup_popup_done() override; + void xdg_popup_repositioned(uint32_t token) override; QWaylandXdgSurface *m_xdgSurface = nullptr; - QWaylandXdgSurface *m_parent = nullptr; + QWaylandXdgSurface *m_parentXdgSurface = nullptr; + QWaylandWindow *m_parent = nullptr; bool m_grabbing = false; + + QRect m_pendingGeometry; + bool m_waitingForReposition = false; + uint32_t m_waitingForRepositionSerial = 0; }; void setToplevel(); void setPopup(QWaylandWindow *parent); void setGrabPopup(QWaylandWindow *parent, QWaylandInputDevice *device, int serial); + std::unique_ptr<Positioner> createPositioner(QWaylandWindow *parent); QWaylandXdgShell *m_shell = nullptr; QWaylandWindow *m_window = nullptr; Toplevel *m_toplevel = nullptr; Popup *m_popup = nullptr; bool m_configured = false; - QRegion m_exposeRegion; uint m_pendingConfigureSerial = 0; + uint m_appliedConfigureSerial = 0; + QString m_activationToken; + QString m_appId; + bool m_alertState = false; friend class QWaylandXdgShell; }; -class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShell : public QtWayland::xdg_wm_base +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShell { public: - QWaylandXdgShell(QWaylandDisplay *display, uint32_t id, uint32_t availableVersion); - ~QWaylandXdgShell() override; + QWaylandXdgShell(QWaylandDisplay *display, QtWayland::xdg_wm_base *xdg_wm_base); + ~QWaylandXdgShell(); + + QWaylandDisplay *display() const { return m_display; } QWaylandXdgDecorationManagerV1 *decorationManager() { return m_xdgDecorationManager.data(); } + QWaylandXdgActivationV1 *activation() const { return m_xdgActivation.data(); } + QWaylandXdgExporterV2 *exporter() const { return m_xdgExporter.data(); } QWaylandXdgSurface *getXdgSurface(QWaylandWindow *window); -protected: - void xdg_wm_base_ping(uint32_t serial) override; - private: static void handleRegistryGlobal(void *data, ::wl_registry *registry, uint id, const QString &interface, uint version); QWaylandDisplay *m_display = nullptr; + QtWayland::xdg_wm_base *m_xdgWmBase = nullptr; QScopedPointer<QWaylandXdgDecorationManagerV1> m_xdgDecorationManager; - QWaylandXdgSurface::Popup *m_topmostGrabbingPopup = nullptr; + QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation; + QScopedPointer<QWaylandXdgExporterV2> m_xdgExporter; + QScopedPointer<QWaylandXdgDialogWmV1> m_xdgDialogWm; friend class QWaylandXdgSurface; }; diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp index 8769d9716..f1bb8bee4 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration.cpp @@ -1,42 +1,7 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only +#include "qwaylandxdgshell_p.h" #include "qwaylandxdgshellintegration_p.h" #include "qwaylandxdgdecorationv1_p.h" @@ -47,40 +12,48 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display) +QWaylandXdgShellIntegration::QWaylandXdgShellIntegration() : QWaylandShellIntegrationTemplate(6) { - for (QWaylandDisplay::RegistryGlobal global : display->globals()) { - if (global.interface == QLatin1String("xdg_wm_base")) { - m_xdgShell.reset(new QWaylandXdgShell(display, global.id, global.version)); - break; + connect(this, &QWaylandShellIntegrationTemplate::activeChanged, this, [this] { + if (isActive()) { + mXdgShell.reset(new QWaylandXdgShell(mDisplay, this)); + } else { + mXdgShell.reset(nullptr); + destroy(); } - } + }); +} - if (!m_xdgShell) { - qCDebug(lcQpaWayland) << "Couldn't find global xdg_wm_base for xdg-shell stable"; - return false; - } +QWaylandXdgShellIntegration::~QWaylandXdgShellIntegration() +{ + if (isActive()) + destroy(); +} - return QWaylandShellIntegration::initialize(display); +bool QWaylandXdgShellIntegration::initialize(QWaylandDisplay *display) +{ + mDisplay = display; + return QWaylandShellIntegrationTemplate::initialize(display); +} + +void QWaylandXdgShellIntegration::xdg_wm_base_ping(uint32_t serial) +{ + pong(serial); } QWaylandShellSurface *QWaylandXdgShellIntegration::createShellSurface(QWaylandWindow *window) { - return m_xdgShell->getXdgSurface(window); + return new QWaylandXdgSurface(mXdgShell.get(), get_xdg_surface(window->wlSurface()), window); } -void QWaylandXdgShellIntegration::handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) +void *QWaylandXdgShellIntegration::nativeResourceForWindow(const QByteArray &resource, QWindow *window) { - if (newFocus) { - auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(newFocus->shellSurface()); - if (xdgSurface && !xdgSurface->handlesActiveState()) - m_display->handleWindowActivated(newFocus); - } - if (oldFocus && qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface())) { - auto *xdgSurface = qobject_cast<QWaylandXdgSurface *>(oldFocus->shellSurface()); - if (xdgSurface && !xdgSurface->handlesActiveState()) - m_display->handleWindowDeactivated(oldFocus); + if (auto waylandWindow = static_cast<QWaylandWindow *>(window->handle())) { + if (auto xdgSurface = qobject_cast<QWaylandXdgSurface *>(waylandWindow->shellSurface())) { + return xdgSurface->nativeResource(resource); + } } + return nullptr; } } diff --git a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h index b6caa6c95..b7627d804 100644 --- a/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h +++ b/src/plugins/shellintegration/xdg-shell/qwaylandxdgshellintegration_p.h @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2017 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$ -** -****************************************************************************/ +// Copyright (C) 2017 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #ifndef QWAYLANDXDGSHELLINTEGRATION_P_H #define QWAYLANDXDGSHELLINTEGRATION_P_H @@ -51,7 +15,7 @@ // We mean it. // -#include "qwaylandxdgshell_p.h" +#include "qwayland-xdg-shell.h" #include <QtWaylandClient/private/qwaylandshellintegration_p.h> @@ -59,16 +23,25 @@ QT_BEGIN_NAMESPACE namespace QtWaylandClient { -class Q_WAYLAND_CLIENT_EXPORT QWaylandXdgShellIntegration : public QWaylandShellIntegration +class QWaylandXdgShell; + +class Q_WAYLANDCLIENT_EXPORT QWaylandXdgShellIntegration + : public QWaylandShellIntegrationTemplate<QWaylandXdgShellIntegration>, + public QtWayland::xdg_wm_base { public: - QWaylandXdgShellIntegration() {} - bool initialize(QWaylandDisplay *display) override; + QWaylandXdgShellIntegration(); + ~QWaylandXdgShellIntegration() override; QWaylandShellSurface *createShellSurface(QWaylandWindow *window) override; - void handleKeyboardFocusChanged(QWaylandWindow *newFocus, QWaylandWindow *oldFocus) override; + void *nativeResourceForWindow(const QByteArray &resource, QWindow *window) override; + bool initialize(QWaylandDisplay *display) override; + +protected: + void xdg_wm_base_ping(uint32_t serial) override; private: - QScopedPointer<QWaylandXdgShell> m_xdgShell; + QWaylandDisplay *mDisplay; + QScopedPointer<QWaylandXdgShell> mXdgShell; }; } diff --git a/src/plugins/shellintegration/xdg-shell/xdg-shell.pro b/src/plugins/shellintegration/xdg-shell/xdg-shell.pro deleted file mode 100644 index 261715845..000000000 --- a/src/plugins/shellintegration/xdg-shell/xdg-shell.pro +++ /dev/null @@ -1,28 +0,0 @@ -QT += gui-private waylandclient-private -CONFIG += wayland-scanner - -QMAKE_USE += wayland-client -qtConfig(xkbcommon): \ - QMAKE_USE_PRIVATE += xkbcommon - -WAYLANDCLIENTSOURCES += \ - ../../../3rdparty/protocol/xdg-decoration-unstable-v1.xml \ - ../../../3rdparty/protocol/xdg-shell.xml - -HEADERS += \ - qwaylandxdgdecorationv1_p.h \ - qwaylandxdgshell_p.h \ - qwaylandxdgshellintegration_p.h \ - -SOURCES += \ - main.cpp \ - qwaylandxdgdecorationv1.cpp \ - qwaylandxdgshell.cpp \ - qwaylandxdgshellintegration.cpp \ - -OTHER_FILES += \ - xdg-shell.json - -PLUGIN_TYPE = wayland-shell-integration -PLUGIN_CLASS_NAME = QWaylandXdgShellIntegrationPlugin -load(qt_plugin) |