Compare commits

...

16 Commits

Author SHA1 Message Date
1943de8501 Add a (temporary) way to attach popups to layer surfaces
The new API is temporary. It's needed to help us with porting plasma to
the layer shell protocol until Qt 6.6 is released, which includes
QWaylandShellSurface::attachPopup().
2023-04-03 16:47:55 +03:00
7d1fb40d07 Port to QWaylandWindow::setShellIntegration()
With QWaylandWindow::setShellIntegration(), it's possible to use
xdg-shell and layer-shell protocols in the same process. It's important
for plasmashell, where we want to use the layer shell protocol for
special surfaces such as the desktop background, and the xdg shell
protocol for dialogs.

In order to make a QWindow use the layer shell protocol, you need to
call LayerShellQt::Window::get() before the window is mapped.
2023-04-03 14:47:00 +03:00
488c6d759c Replace KF5 with KF6 2023-02-28 15:05:58 +01:00
d69a528b6c Require Qt 6.4 2023-02-28 15:05:34 +01:00
cfbfe94e79 Use KF6 libs on CI 2023-02-28 15:05:15 +01:00
2b757f3d82 Remove Qt5 CI 2023-02-28 15:05:03 +01:00
3c85e2e889 Use the QScreen of the QWindow as default output
If the Window::setDesiredOutput API was not called for the QWindow, use
QWindow::screen(). This allows assigning QWindows to specific screens using
the plain Qt API.

Passing nullptr to Window::setDesiredOutput explicitly results in nil as
desired output for the layer, which lets the compositor select a screen.
2023-02-22 08:23:17 +01:00
b9f8f6447d Update version number for 5.27.80
GIT_SILENT
2023-01-27 14:56:01 +00:00
7de801802b Revert "Show all headers in qtc6"
There was no consensus for this in Plasma.
This reverts commit 22df3fe914.
2023-01-24 08:49:43 +01:00
22df3fe914 Show all headers in qtc6 2023-01-22 17:38:12 +00:00
8d14abc707 Update kf5 version requirement to 5.102.0
GIT_SILENT
2023-01-21 20:06:42 +00:00
d06bcbe25b Update version number for 5.28.80
GIT_SILENT
2023-01-19 12:28:59 +00:00
fc06e945c8 Update version number for 5.26.90
GIT_SILENT
2023-01-19 11:17:24 +00:00
b95910c086 Use ecm_set_disabled_deprecation_versions 2022-12-23 13:50:51 +01:00
70dc87f673 Use KDE_INSTALL_CMAKEPACKAGEDIR
GIT_SILENT
2022-10-22 13:59:13 +00:00
7b9c2c1db1 Update version number for 5.26.80
GIT_SILENT
2022-09-15 13:57:50 +01:00
11 changed files with 78 additions and 45 deletions

View File

@ -3,7 +3,5 @@
include:
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/reuse-lint.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd-qt6.yml

View File

@ -4,4 +4,4 @@
Dependencies:
- 'on': ['@all']
'require':
'frameworks/extra-cmake-modules': '@latest'
'frameworks/extra-cmake-modules': '@latest-kf6'

View File

@ -4,25 +4,26 @@
cmake_minimum_required(VERSION 3.16)
project(layershellqt)
set(PROJECT_VERSION "5.25.90")
set(PROJECT_VERSION "5.27.80")
set(PROJECT_VERSION_MAJOR 5)
set(CMAKE_C_STANDARD 99)
set(QT_MIN_VERSION "5.15.2")
set(KF5_MIN_VERSION "5.98.0")
set(QT_MIN_VERSION "6.5.0")
set(KF6_MIN_VERSION "5.240.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
find_package(ECM ${KF5_MIN_VERSION} REQUIRED NO_MODULE)
find_package(ECM ${KF6_MIN_VERSION} REQUIRED NO_MODULE)
set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake ${ECM_MODULE_PATH})
include(KDEInstallDirs)
include(KDECMakeSettings)
include(KDECompilerSettings NO_POLICY_SCOPE)
include(ECMSetupVersion)
include(ECMDeprecationSettings)
include(ECMGenerateHeaders)
include(CMakePackageConfigHelpers)
include(FeatureSummary)
@ -30,6 +31,7 @@ include(GenerateExportHeader)
include(KDEClangFormat)
include(ECMQtDeclareLoggingCategory)
find_package(Qt${QT_MAJOR_VERSION} ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
if (QT_MAJOR_VERSION EQUAL "5")
find_package(Qt5XkbCommonSupport REQUIRED PRIVATE)
@ -53,10 +55,15 @@ ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX LAYERSHELLQT
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
ecm_set_disabled_deprecation_versions(QT 5.15.2
KF 5.101
)
add_subdirectory(src)
add_subdirectory(tests)
set(CMAKECONFIG_INSTALL_DIR ${KDE_INSTALL_LIBDIR}/cmake/LayerShellQt)
set(CMAKECONFIG_INSTALL_DIR ${KDE_INSTALL_CMAKEPACKAGEDIR}/LayerShellQt)
install(EXPORT LayerShellQtTargets
NAMESPACE LayerShellQt::
DESTINATION ${CMAKECONFIG_INSTALL_DIR}

View File

@ -5,9 +5,17 @@
*/
#include "window.h"
#include "../qwaylandlayershellintegration_p.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
#include "../qwaylandlayersurface_p.h"
#endif
#include <layershellqt_logging.h>
#include <QPointer>
#include <optional>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
using namespace LayerShellQt;
@ -26,7 +34,7 @@ public:
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityExclusive;
Window::Layer layer = Window::LayerTop;
QMargins margins;
QPointer<QScreen> desiredOutput;
std::optional<QPointer<QScreen>> desiredOutput;
};
static QMap<QWindow *, Window *> s_map;
@ -103,7 +111,12 @@ Window::Layer Window::layer() const
QScreen *Window::desiredOutput() const
{
return d->desiredOutput;
// Don't use .value_or here to avoid a temporary QPointer
if (d->desiredOutput.has_value()) {
return d->desiredOutput.value();
}
return d->parentWindow->screen();
}
void Window::setDesiredOutput(QScreen *output)
@ -111,11 +124,33 @@ void Window::setDesiredOutput(QScreen *output)
d->desiredOutput = output;
}
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
void Window::attachPopup(QWindow *window, xdg_popup *popup)
{
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
if (!waylandWindow) {
return;
}
auto shellSurface = dynamic_cast<QWaylandLayerSurface *>(waylandWindow->shellSurface());
if (shellSurface) {
shellSurface->get_popup(popup);
}
}
#endif
Window::Window(QWindow *window)
: QObject(window)
, d(new WindowPrivate(window))
{
s_map.insert(d->parentWindow, this);
window->create();
if (auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle())) {
static QWaylandLayerShellIntegration integration;
waylandWindow->setShellIntegration(&integration);
}
}
Window *Window::get(QWindow *window)

View File

@ -14,6 +14,10 @@
#include "layershellqt_export.h"
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
struct xdg_popup;
#endif
namespace LayerShellQt
{
class WindowPrivate;
@ -93,6 +97,10 @@ public:
*/
static Window *get(QWindow *window);
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
static void attachPopup(QWindow *window, xdg_popup *popup);
#endif
Q_SIGNALS:
void anchorsChanged();
void exclusionZoneChanged();

View File

@ -10,9 +10,11 @@
namespace LayerShellQt
{
QWaylandLayerShell::QWaylandLayerShell(::wl_registry *registry, uint32_t id, uint32_t version)
: QtWayland::zwlr_layer_shell_v1(registry, id, version)
QWaylandLayerShell::QWaylandLayerShell()
: QWaylandClientExtensionTemplate<QWaylandLayerShell>(4)
, QtWayland::zwlr_layer_shell_v1()
{
initialize();
}
QWaylandLayerShell::~QWaylandLayerShell()
@ -21,9 +23,4 @@ QWaylandLayerShell::~QWaylandLayerShell()
zwlr_layer_shell_v1_destroy(object());
}
QWaylandLayerSurface *QWaylandLayerShell::createLayerSurface(QtWaylandClient::QWaylandWindow *window)
{
return new QWaylandLayerSurface(this, window);
}
}

View File

@ -8,23 +8,20 @@
#ifndef _LAYERSHELL_H
#define _LAYERSHELL_H
#include "layershellqt_export.h"
#include <wayland-client.h>
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
#include <qwayland-wlr-layer-shell-unstable-v1.h>
#include "qwaylandlayersurface_p.h"
namespace LayerShellQt
{
class LAYERSHELLQT_EXPORT QWaylandLayerShell : public QtWayland::zwlr_layer_shell_v1
class LAYERSHELLQT_EXPORT QWaylandLayerShell : public QWaylandClientExtensionTemplate<QWaylandLayerShell>, public QtWayland::zwlr_layer_shell_v1
{
public:
QWaylandLayerShell(::wl_registry *registry, uint32_t id, uint32_t version);
QWaylandLayerShell();
~QWaylandLayerShell() override;
QWaylandLayerSurface *createLayerSurface(QtWaylandClient::QWaylandWindow *window);
// TODO: Popups
};
}

View File

@ -7,6 +7,7 @@
#include "qwaylandlayershell_p.h"
#include "qwaylandlayershellintegration_p.h"
#include "qwaylandlayersurface_p.h"
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
@ -15,6 +16,7 @@
namespace LayerShellQt
{
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
: m_layerShell(new QWaylandLayerShell())
{
}
@ -24,26 +26,14 @@ QWaylandLayerShellIntegration::~QWaylandLayerShellIntegration()
bool QWaylandLayerShellIntegration::initialize(QtWaylandClient::QWaylandDisplay *display)
{
#if QT_VERSION < QT_VERSION_CHECK(6, 0, 0)
QWaylandShellIntegration::initialize(display);
#endif
display->addRegistryListener(registryLayer, this);
return m_layerShell != nullptr;
Q_UNUSED(display)
return m_layerShell->isActive();
}
QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow *window)
{
return m_layerShell->createLayerSurface(window);
return new QWaylandLayerSurface(m_layerShell.get(), window);
}
void QWaylandLayerShellIntegration::registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version)
{
QWaylandLayerShellIntegration *shell = static_cast<QWaylandLayerShellIntegration *>(data);
if (interface == zwlr_layer_shell_v1_interface.name)
shell->m_layerShell.reset(new QWaylandLayerShell(registry, id, std::min(version, 4u)));
}
}
//#include "qwaylandlayershellintegration.moc"

View File

@ -27,8 +27,6 @@ public:
QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
private:
static void registryLayer(void *data, struct wl_registry *registry, uint32_t id, const QString &interface, uint32_t version);
QScopedPointer<QWaylandLayerShell> m_layerShell;
};

View File

@ -5,7 +5,7 @@
* SPDX-License-Identifier: LGPL-3.0-or-later
*/
#include "interfaces/shell.h"
#include "interfaces/window.h"
#include "layershellqt_logging.h"
#include "qwaylandlayershell_p.h"
#include "qwaylandlayersurface_p.h"

View File

@ -14,7 +14,6 @@
#include <QMetaEnum>
#include <interfaces/shell.h>
#include <interfaces/window.h>
using namespace LayerShellQt;
@ -51,8 +50,6 @@ class BasicWindow : public QRasterWindow
int main(int argc, char **argv)
{
Shell::useLayerShell();
QGuiApplication app(argc, argv);
const auto layerMetaEnum = QMetaEnum::fromType<Window::Layer>();
@ -79,6 +76,8 @@ int main(int argc, char **argv)
BasicWindow window;
LayerShellQt::Window *layerShell = LayerShellQt::Window::get(&window);
layerShell->setLayer(Window::LayerBottom);
if (parser.isSet(marginsOption)) {
int margins = parser.value(marginsOption).toInt();
layerShell->setMargins({margins, margins, margins, margins});
@ -102,6 +101,10 @@ int main(int argc, char **argv)
window.show();
BasicWindow window2;
window2.resize(400, 400);
window2.show();
// just so you don't block yourself out whilst testing
QTimer::singleShot(5000, &app, &QGuiApplication::quit);
return app.exec();