mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-07-14 11:04:20 -04:00
Compare commits
76 Commits
v5.25.1
...
Plasma/6.0
Author | SHA1 | Date | |
---|---|---|---|
2c903f3618 | |||
797c8b26ca | |||
32afbcf68a | |||
81782b38e4 | |||
4dfa7b53f1 | |||
aeb8d198ce | |||
f32b64244f | |||
9fb17e63b2 | |||
ec1a2d02fb | |||
c902d638ec | |||
176b7648d4 | |||
cce9896e42 | |||
f7fee6e7f6 | |||
66ec181e1e | |||
1abc1f381f | |||
47539db4b3 | |||
078f36f8f3 | |||
7d3194034c | |||
e3098a660a | |||
d379bc8d8e | |||
715e629dd8 | |||
8ae3b0aef8 | |||
6f0bca5593 | |||
d1ab27dd53 | |||
4569e78e25 | |||
ddb0490592 | |||
3c116e7550 | |||
9e1c5357ac | |||
76e8f33cbc | |||
25bc38dac1 | |||
aa167e8da5 | |||
de9fdb3fb7 | |||
00b26a196d | |||
fcaf8cf95d | |||
1573a89aac | |||
721c0ae334 | |||
143fd1755a | |||
d6aeaef1dc | |||
c97826ab18 | |||
3bfed84c45 | |||
4cb2a27a4c | |||
9750fd8be7 | |||
5e88f449b0 | |||
497d50c4df | |||
541497ff5f | |||
1358743441 | |||
be63783888 | |||
87753746b9 | |||
49f31bb22d | |||
511b92f4ab | |||
fdab1544fb | |||
2985398375 | |||
07e63cab8c | |||
488c6d759c | |||
d69a528b6c | |||
cfbfe94e79 | |||
2b757f3d82 | |||
3c85e2e889 | |||
b9f8f6447d | |||
7de801802b | |||
22df3fe914 | |||
8d14abc707 | |||
d06bcbe25b | |||
fc06e945c8 | |||
b95910c086 | |||
70dc87f673 | |||
7b9c2c1db1 | |||
9b5a39922b | |||
91db77acc2 | |||
5af50ac3ee | |||
7bfac45da8 | |||
7bd63669ea | |||
13961ef7b9 | |||
ff6155a5af | |||
34e7c90c2d | |||
563b61c75c |
@ -2,6 +2,8 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
include:
|
||||
- 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
|
||||
- project: sysadmin/ci-utilities
|
||||
file:
|
||||
- /gitlab-templates/reuse-lint.yml
|
||||
- /gitlab-templates/linux-qt6.yml
|
||||
- /gitlab-templates/freebsd-qt6.yml
|
||||
|
@ -4,4 +4,6 @@
|
||||
Dependencies:
|
||||
- 'on': ['@all']
|
||||
'require':
|
||||
'frameworks/extra-cmake-modules': '@latest'
|
||||
'frameworks/extra-cmake-modules': '@latest-kf6'
|
||||
'third-party/wayland': '@latest'
|
||||
'third-party/wayland-protocols': '@latest'
|
||||
|
@ -4,40 +4,39 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(layershellqt)
|
||||
set(PROJECT_VERSION "5.24.90")
|
||||
set(PROJECT_VERSION_MAJOR 5)
|
||||
set(PROJECT_VERSION "6.0.5")
|
||||
set(PROJECT_VERSION_MAJOR 6)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
set(QT_MIN_VERSION "5.15.0")
|
||||
set(KF5_MIN_VERSION "5.91")
|
||||
set(QT_MIN_VERSION "6.6.0")
|
||||
set(KF6_MIN_VERSION "6.0.0")
|
||||
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
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)
|
||||
include(GenerateExportHeader)
|
||||
include(KDEClangFormat)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMQmlModule)
|
||||
|
||||
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)
|
||||
find_package(QtWaylandScanner)
|
||||
endif()
|
||||
find_package(WaylandScanner)
|
||||
|
||||
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
|
||||
find_package(WaylandScanner REQUIRED)
|
||||
find_package(Wayland 1.3 COMPONENTS Client Server)
|
||||
find_package(WaylandProtocols)
|
||||
find_package(WaylandProtocols REQUIRED)
|
||||
find_package(PkgConfig REQUIRED)
|
||||
|
||||
pkg_check_modules(XKBCOMMON xkbcommon REQUIRED IMPORTED_TARGET)
|
||||
@ -49,14 +48,19 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90")
|
||||
ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX LAYERSHELLQT
|
||||
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/layershellqt_version.h"
|
||||
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LayerShellQtConfigVersion.cmake"
|
||||
SOVERSION 5)
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
|
||||
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
|
||||
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||
|
||||
ecm_set_disabled_deprecation_versions(QT 6.5
|
||||
KF 5.240
|
||||
)
|
||||
|
||||
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}
|
||||
|
@ -4,6 +4,6 @@
|
||||
@PACKAGE_INIT@
|
||||
|
||||
include(CMakeFindDependencyMacro)
|
||||
find_dependency(Qt@QT_MAJOR_VERSION@Gui "@QT_MIN_VERSION@")
|
||||
find_dependency(Qt6Gui "@QT_MIN_VERSION@")
|
||||
|
||||
include("${CMAKE_CURRENT_LIST_DIR}/LayerShellQtTargets.cmake")
|
||||
|
@ -1,3 +1,6 @@
|
||||
# SPDX-FileCopyrightText: None
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
maintainer:
|
||||
- vladz
|
||||
description: Layer Shell Qt
|
||||
|
@ -4,17 +4,13 @@
|
||||
remove_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS)
|
||||
|
||||
add_library(LayerShellQtInterface)
|
||||
if (QT_MAJOR_VERSION EQUAL "5")
|
||||
ecm_add_qtwayland_client_protocol(LAYER_SHELL_SOURCES PROTOCOL ${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml BASENAME xdg-shell)
|
||||
ecm_add_qtwayland_client_protocol(LAYER_SHELL_SOURCES PROTOCOL wlr-layer-shell-unstable-v1.xml BASENAME wlr-layer-shell-unstable-v1)
|
||||
else()
|
||||
qt6_generate_wayland_protocol_client_sources(LayerShellQtInterface FILES
|
||||
${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
|
||||
${WaylandProtocols_DATADIR}/staging/xdg-activation/xdg-activation-v1.xml
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/wlr-layer-shell-unstable-v1.xml
|
||||
)
|
||||
endif()
|
||||
|
||||
ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES
|
||||
ecm_qt_declare_logging_category(LayerShellQtInterface
|
||||
HEADER
|
||||
layershellqt_logging.h
|
||||
IDENTIFIER
|
||||
@ -23,8 +19,16 @@ ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES
|
||||
layershellqt
|
||||
)
|
||||
|
||||
target_sources(LayerShellQtInterface PRIVATE qwaylandlayersurface.cpp interfaces/window.cpp interfaces/shell.cpp qwaylandlayershellintegration.cpp qwaylandlayershell.cpp ${LAYER_SHELL_SOURCES})
|
||||
target_link_libraries(LayerShellQtInterface PRIVATE Qt::Gui Qt::WaylandClientPrivate Wayland::Client PkgConfig::XKBCOMMON)
|
||||
target_sources(LayerShellQtInterface PRIVATE
|
||||
qwaylandxdgactivationv1.cpp
|
||||
qwaylandlayersurface.cpp
|
||||
qwaylandlayershellintegration.cpp
|
||||
interfaces/window.cpp
|
||||
interfaces/shell.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(LayerShellQtInterface PUBLIC Qt::Gui)
|
||||
target_link_libraries(LayerShellQtInterface PRIVATE Qt::WaylandClientPrivate Wayland::Client PkgConfig::XKBCOMMON)
|
||||
if (TARGET Qt::XkbCommonSupportPrivate)
|
||||
target_link_libraries(LayerShellQtInterface PRIVATE Qt::XkbCommonSupportPrivate)
|
||||
endif()
|
||||
@ -68,3 +72,5 @@ install(FILES
|
||||
${CMAKE_CURRENT_BINARY_DIR}/LayerShellQt/layershellqt_export.h
|
||||
DESTINATION ${KDE_INSTALL_INCLUDEDIR}/LayerShellQt COMPONENT Devel
|
||||
)
|
||||
|
||||
add_subdirectory(declarative)
|
||||
|
10
src/declarative/CMakeLists.txt
Normal file
10
src/declarative/CMakeLists.txt
Normal file
@ -0,0 +1,10 @@
|
||||
# SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleix.pol_gonzalez@mercedes-benz.com>
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
ecm_add_qml_module(LayerShellQtQml
|
||||
URI "org.kde.layershell"
|
||||
VERSION 1.0
|
||||
SOURCES layershellqtplugin.cpp)
|
||||
target_link_libraries(LayerShellQtQml PRIVATE Qt::Qml LayerShellQtInterface)
|
||||
|
||||
ecm_finalize_qml_module(LayerShellQtQml DESTINATION ${KDE_INSTALL_QMLDIR})
|
24
src/declarative/layershellqtplugin.cpp
Normal file
24
src/declarative/layershellqtplugin.cpp
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez <aleix.pol_gonzalez@mercedes-benz.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include <QQmlExtensionPlugin>
|
||||
#include "../interfaces/window.h"
|
||||
#include <qqml.h>
|
||||
|
||||
QML_DECLARE_TYPEINFO(LayerShellQt::Window, QML_HAS_ATTACHED_PROPERTIES)
|
||||
|
||||
class Plugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "org.kde.layershellqt")
|
||||
Q_OBJECT
|
||||
public:
|
||||
void registerTypes(const char *uri) override {
|
||||
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.layershell"));
|
||||
qmlRegisterType<LayerShellQt::Window>(uri, 1, 0, "Window");
|
||||
}
|
||||
};
|
||||
|
||||
#include "layershellqtplugin.moc"
|
@ -5,10 +5,14 @@
|
||||
*/
|
||||
|
||||
#include "window.h"
|
||||
#include "../qwaylandlayersurface_p.h"
|
||||
#include "../qwaylandlayershellintegration_p.h"
|
||||
|
||||
#include <layershellqt_logging.h>
|
||||
#include <private/qwaylandshellsurface_p.h>
|
||||
#include <private/qwaylandwindow_p.h>
|
||||
|
||||
#include <QPointer>
|
||||
#include <optional>
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
|
||||
using namespace LayerShellQt;
|
||||
|
||||
@ -24,11 +28,12 @@ public:
|
||||
QString scope = QStringLiteral("window");
|
||||
Window::Anchors anchors = {Window::AnchorTop | Window::AnchorBottom | Window::AnchorLeft | Window::AnchorRight};
|
||||
int32_t exclusionZone = 0;
|
||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityExclusive;
|
||||
Window::Anchor exclusiveEdge = Window::AnchorNone;
|
||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
|
||||
Window::Layer layer = Window::LayerTop;
|
||||
QMargins margins;
|
||||
QWaylandLayerSurface *getSurface() const;
|
||||
QPointer<QScreen> desiredOutput;
|
||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
||||
bool closeOnDismissed = true;
|
||||
};
|
||||
|
||||
static QMap<QWindow *, Window *> s_map;
|
||||
@ -40,9 +45,9 @@ Window::~Window()
|
||||
|
||||
void Window::setAnchors(Anchors anchors)
|
||||
{
|
||||
if (d->anchors != anchors) {
|
||||
d->anchors = anchors;
|
||||
if (auto surface = d->getSurface()) {
|
||||
surface->setAnchor(anchors);
|
||||
Q_EMIT anchorsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -53,9 +58,9 @@ Window::Anchors Window::anchors() const
|
||||
|
||||
void Window::setExclusiveZone(int32_t zone)
|
||||
{
|
||||
if (d->exclusionZone != zone) {
|
||||
d->exclusionZone = zone;
|
||||
if (auto surface = d->getSurface()) {
|
||||
surface->setExclusiveZone(zone);
|
||||
Q_EMIT exclusionZoneChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -64,11 +69,26 @@ int32_t Window::exclusionZone() const
|
||||
return d->exclusionZone;
|
||||
}
|
||||
|
||||
void Window::setExclusiveEdge(Window::Anchor edge)
|
||||
{
|
||||
if (d->exclusiveEdge == edge) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->exclusiveEdge = edge;
|
||||
Q_EMIT exclusiveEdgeChanged();
|
||||
}
|
||||
|
||||
Window::Anchor Window::exclusiveEdge() const
|
||||
{
|
||||
return d->exclusiveEdge;
|
||||
}
|
||||
|
||||
void Window::setMargins(const QMargins &margins)
|
||||
{
|
||||
if (d->margins != margins) {
|
||||
d->margins = margins;
|
||||
if (auto surface = d->getSurface()) {
|
||||
surface->setMargins(margins);
|
||||
Q_EMIT marginsChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,9 +99,9 @@ QMargins Window::margins() const
|
||||
|
||||
void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity)
|
||||
{
|
||||
if (d->keyboardInteractivity != interactivity) {
|
||||
d->keyboardInteractivity = interactivity;
|
||||
if (auto surface = d->getSurface()) {
|
||||
surface->setKeyboardInteractivity(interactivity);
|
||||
Q_EMIT keyboardInteractivityChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -92,9 +112,9 @@ Window::KeyboardInteractivity Window::keyboardInteractivity() const
|
||||
|
||||
void Window::setLayer(Layer layer)
|
||||
{
|
||||
if (d->layer != layer) {
|
||||
d->layer = layer;
|
||||
if (auto surface = d->getSurface()) {
|
||||
surface->setLayer(layer);
|
||||
Q_EMIT layerChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@ -114,14 +134,24 @@ Window::Layer Window::layer() const
|
||||
return d->layer;
|
||||
}
|
||||
|
||||
QScreen *Window::desiredOutput() const
|
||||
Window::ScreenConfiguration Window::screenConfiguration() const
|
||||
{
|
||||
return d->desiredOutput;
|
||||
return d->screenConfiguration;
|
||||
}
|
||||
|
||||
void Window::setDesiredOutput(QScreen *output)
|
||||
void Window::setScreenConfiguration(Window::ScreenConfiguration screenConfiguration)
|
||||
{
|
||||
d->desiredOutput = output;
|
||||
d->screenConfiguration = screenConfiguration;
|
||||
}
|
||||
|
||||
bool Window::closeOnDismissed() const
|
||||
{
|
||||
return d->closeOnDismissed;
|
||||
}
|
||||
|
||||
void Window::setCloseOnDismissed(bool close)
|
||||
{
|
||||
d->closeOnDismissed = close;
|
||||
}
|
||||
|
||||
Window::Window(QWindow *window)
|
||||
@ -129,10 +159,35 @@ Window::Window(QWindow *window)
|
||||
, d(new WindowPrivate(window))
|
||||
{
|
||||
s_map.insert(d->parentWindow, this);
|
||||
|
||||
window->create();
|
||||
|
||||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
|
||||
if (!waylandWindow) {
|
||||
qCWarning(LAYERSHELLQT) << window << "is not a wayland window. Not creating zwlr_layer_surface";
|
||||
return;
|
||||
}
|
||||
|
||||
static QWaylandLayerShellIntegration *shellIntegration = nullptr;
|
||||
if (!shellIntegration) {
|
||||
shellIntegration = new QWaylandLayerShellIntegration();
|
||||
if (!shellIntegration->initialize(waylandWindow->display())) {
|
||||
delete shellIntegration;
|
||||
shellIntegration = nullptr;
|
||||
qCWarning(LAYERSHELLQT) << "Failed to initialize layer-shell integration, possibly because compositor does not support the layer-shell protocol";
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
waylandWindow->setShellIntegration(shellIntegration);
|
||||
}
|
||||
|
||||
Window *Window::get(QWindow *window)
|
||||
{
|
||||
if (!window) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto layerShellWindow = s_map.value(window);
|
||||
if (layerShellWindow) {
|
||||
return layerShellWindow;
|
||||
@ -140,20 +195,7 @@ Window *Window::get(QWindow *window)
|
||||
return new Window(window);
|
||||
}
|
||||
|
||||
QWaylandLayerSurface *WindowPrivate::getSurface() const
|
||||
Window *Window::qmlAttachedProperties(QObject *object)
|
||||
{
|
||||
if (!parentWindow) {
|
||||
return nullptr;
|
||||
}
|
||||
auto ww = dynamic_cast<QtWaylandClient::QWaylandWindow *>(parentWindow->handle());
|
||||
if (!ww) {
|
||||
qCDebug(LAYERSHELLQT) << "window not a wayland window" << parentWindow;
|
||||
return nullptr;
|
||||
}
|
||||
QWaylandLayerSurface *s = qobject_cast<QWaylandLayerSurface *>(ww->shellSurface());
|
||||
if (!s) {
|
||||
qCDebug(LAYERSHELLQT) << "window not using wlr-layer-shell" << parentWindow << ww->shellSurface();
|
||||
return nullptr;
|
||||
}
|
||||
return s;
|
||||
return get(qobject_cast<QWindow *>(object));
|
||||
}
|
||||
|
@ -21,10 +21,19 @@ class WindowPrivate;
|
||||
class LAYERSHELLQT_EXPORT Window : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Anchors anchors READ anchors WRITE setAnchors NOTIFY anchorsChanged)
|
||||
Q_PROPERTY(QString scope READ scope WRITE setScope)
|
||||
Q_PROPERTY(QMargins margins READ margins WRITE setMargins NOTIFY marginsChanged)
|
||||
Q_PROPERTY(qint32 exclusionZone READ exclusionZone WRITE setExclusiveZone NOTIFY exclusionZoneChanged)
|
||||
Q_PROPERTY(Layer layer READ layer WRITE setLayer NOTIFY layerChanged)
|
||||
Q_PROPERTY(KeyboardInteractivity keyboardInteractivity READ keyboardInteractivity WRITE setKeyboardInteractivity NOTIFY keyboardInteractivityChanged)
|
||||
Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
|
||||
|
||||
public:
|
||||
~Window() override;
|
||||
|
||||
enum Anchor {
|
||||
AnchorNone = 0,
|
||||
AnchorTop = 1, ///< The top edge of the anchor rectangle
|
||||
AnchorBottom = 2, ///< The bottom edge of the anchor rectangle
|
||||
AnchorLeft = 4, ///< The left edge of the anchor rectangle
|
||||
@ -54,12 +63,26 @@ public:
|
||||
};
|
||||
Q_ENUM(KeyboardInteractivity)
|
||||
|
||||
/**
|
||||
* This enum type is used to specify which screen to place the surface on.
|
||||
* ScreenFromQWindow (the default) reads QWindow::screen() while ScreenFromCompositor
|
||||
* passes nil and lets the compositor decide.
|
||||
*/
|
||||
enum ScreenConfiguration {
|
||||
ScreenFromQWindow = 0,
|
||||
ScreenFromCompositor = 1,
|
||||
};
|
||||
Q_ENUM(ScreenConfiguration)
|
||||
|
||||
void setAnchors(Anchors anchor);
|
||||
Anchors anchors() const;
|
||||
|
||||
void setExclusiveZone(int32_t zone);
|
||||
int32_t exclusionZone() const;
|
||||
|
||||
void setExclusiveEdge(Window::Anchor edge);
|
||||
Window::Anchor exclusiveEdge() const;
|
||||
|
||||
void setMargins(const QMargins &margins);
|
||||
QMargins margins() const;
|
||||
|
||||
@ -69,13 +92,8 @@ public:
|
||||
void setLayer(Layer layer);
|
||||
Layer layer() const;
|
||||
|
||||
/**
|
||||
* If set, the compositor will try to put the window on the given screen.
|
||||
* If its not set, then the compositor will decide where to put the window.
|
||||
* Under normal circumstances, this should be the active output.
|
||||
*/
|
||||
void setDesiredOutput(QScreen *output);
|
||||
QScreen *desiredOutput() const;
|
||||
void setScreenConfiguration(ScreenConfiguration screenConfiguration);
|
||||
ScreenConfiguration screenConfiguration() const;
|
||||
|
||||
/**
|
||||
* Sets a string based identifier for this window.
|
||||
@ -87,12 +105,31 @@ public:
|
||||
void setScope(const QString &scope);
|
||||
QString scope() const;
|
||||
|
||||
/**
|
||||
* Whether the QWindow should be closed when the layer surface is dismissed by the compositor.
|
||||
* For example, if the associated screen has been removed.
|
||||
*
|
||||
* This can be used to map the window on another screen.
|
||||
*/
|
||||
void setCloseOnDismissed(bool close);
|
||||
bool closeOnDismissed() const;
|
||||
|
||||
/**
|
||||
* Gets the LayerShell Window for a given Qt Window
|
||||
* Ownership is not transferred
|
||||
*/
|
||||
static Window *get(QWindow *window);
|
||||
|
||||
static Window *qmlAttachedProperties(QObject *object);
|
||||
|
||||
Q_SIGNALS:
|
||||
void anchorsChanged();
|
||||
void exclusionZoneChanged();
|
||||
void exclusiveEdgeChanged();
|
||||
void marginsChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
|
||||
private:
|
||||
Window(QWindow *window);
|
||||
QScopedPointer<WindowPrivate> d;
|
||||
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
|
||||
* SPDX-FileCopyrightText: 2018 Drew DeVault <sir@cmpwn.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "qwaylandlayershell_p.h"
|
||||
#include "qwaylandlayersurface_p.h"
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerShell::QWaylandLayerShell(::wl_registry *registry, uint32_t id, uint32_t version)
|
||||
: QtWayland::zwlr_layer_shell_v1(registry, id, version)
|
||||
{
|
||||
}
|
||||
|
||||
QWaylandLayerShell::~QWaylandLayerShell()
|
||||
{
|
||||
if (zwlr_layer_shell_v1_get_version(object()) >= ZWLR_LAYER_SHELL_V1_DESTROY_SINCE_VERSION)
|
||||
zwlr_layer_shell_v1_destroy(object());
|
||||
}
|
||||
|
||||
QWaylandLayerSurface *QWaylandLayerShell::createLayerSurface(QtWaylandClient::QWaylandWindow *window)
|
||||
{
|
||||
return new QWaylandLayerSurface(this, window);
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@blue-systems.com>
|
||||
* SPDX-FileCopyrightText: 2018 Drew DeVault <sir@cmpwn.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef _LAYERSHELL_H
|
||||
#define _LAYERSHELL_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
|
||||
{
|
||||
public:
|
||||
QWaylandLayerShell(::wl_registry *registry, uint32_t id, uint32_t version);
|
||||
~QWaylandLayerShell() override;
|
||||
|
||||
QWaylandLayerSurface *createLayerSurface(QtWaylandClient::QWaylandWindow *window);
|
||||
// TODO: Popups
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
@ -5,45 +5,32 @@
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "qwaylandlayershell_p.h"
|
||||
#include "qwaylandlayershellintegration_p.h"
|
||||
#include "qwaylandlayersurface_p.h"
|
||||
#include "qwaylandxdgactivationv1_p.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
|
||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(5)
|
||||
, m_xdgActivation(new QWaylandXdgActivationV1)
|
||||
{
|
||||
}
|
||||
|
||||
QWaylandLayerShellIntegration::~QWaylandLayerShellIntegration()
|
||||
{
|
||||
if (object() && zwlr_layer_shell_v1_get_version(object()) >= ZWLR_LAYER_SHELL_V1_DESTROY_SINCE_VERSION) {
|
||||
zwlr_layer_shell_v1_destroy(object());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShellSurface(QtWaylandClient::QWaylandWindow *window)
|
||||
{
|
||||
return m_layerShell->createLayerSurface(window);
|
||||
return new QWaylandLayerSurface(this, 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"
|
||||
|
@ -8,28 +8,26 @@
|
||||
#ifndef _LAYERSHELLINTEGRATION_P_H
|
||||
#define _LAYERSHELLINTEGRATION_P_H
|
||||
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "layershellqt_export.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
|
||||
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
||||
|
||||
class QWaylandXdgActivationV1;
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
class QWaylandLayerShell;
|
||||
|
||||
class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegration
|
||||
class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>, public QtWayland::zwlr_layer_shell_v1
|
||||
{
|
||||
public:
|
||||
QWaylandLayerShellIntegration();
|
||||
~QWaylandLayerShellIntegration() override;
|
||||
|
||||
bool initialize(QtWaylandClient::QWaylandDisplay *display) override;
|
||||
QWaylandXdgActivationV1 *activation() const { return m_xdgActivation.data(); }
|
||||
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;
|
||||
QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -5,28 +5,29 @@
|
||||
* 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"
|
||||
#include "qwaylandxdgactivationv1_p.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandscreen_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandClient::QWaylandWindow *window)
|
||||
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window)
|
||||
: QtWaylandClient::QWaylandShellSurface(window)
|
||||
, QtWayland::zwlr_layer_surface_v1()
|
||||
, m_shell(shell)
|
||||
, m_interface(Window::get(window->window()))
|
||||
, m_window(window)
|
||||
{
|
||||
LayerShellQt::Window *interface = Window::get(window->window());
|
||||
Q_ASSERT(interface);
|
||||
|
||||
wl_output *output = nullptr;
|
||||
QScreen *screen = interface->desiredOutput();
|
||||
if (screen) {
|
||||
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(screen->handle());
|
||||
if (m_interface->screenConfiguration() == Window::ScreenFromQWindow) {
|
||||
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(window->window()->screen()->handle());
|
||||
// Qt will always assign a screen to a window, but if the compositor has no screens available a dummy QScreen object is created
|
||||
// this will not cast to a QWaylandScreen
|
||||
if (!waylandScreen) {
|
||||
@ -35,36 +36,53 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandC
|
||||
output = waylandScreen->output();
|
||||
}
|
||||
}
|
||||
init(shell->get_layer_surface(window->waylandSurface()->object(), output, interface->layer(), interface->scope()));
|
||||
init(shell->get_layer_surface(window->waylandSurface()->object(), output, m_interface->layer(), m_interface->scope()));
|
||||
connect(m_interface, &Window::layerChanged, this, [this]() {
|
||||
setLayer(m_interface->layer());
|
||||
});
|
||||
|
||||
Window::Anchors anchors = interface->anchors();
|
||||
setAnchor(m_interface->anchors());
|
||||
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
||||
setAnchor(m_interface->anchors());
|
||||
setDesiredSize(m_window->windowContentGeometry().size());
|
||||
});
|
||||
|
||||
set_anchor(interface->anchors());
|
||||
setMargins(interface->margins());
|
||||
setKeyboardInteractivity(interface->keyboardInteractivity());
|
||||
setExclusiveZone(interface->exclusionZone());
|
||||
setExclusiveZone(m_interface->exclusionZone());
|
||||
connect(m_interface, &Window::exclusionZoneChanged, this, [this]() {
|
||||
setExclusiveZone(m_interface->exclusionZone());
|
||||
});
|
||||
setExclusiveEdge(m_interface->exclusiveEdge());
|
||||
connect(m_interface, &Window::exclusiveEdgeChanged, this, [this]() {
|
||||
setExclusiveEdge(m_interface->exclusiveEdge());
|
||||
});
|
||||
|
||||
QSize size = window->surfaceSize();
|
||||
if ((anchors & Window::AnchorLeft) && (anchors & Window::AnchorRight)) {
|
||||
size.setWidth(0);
|
||||
}
|
||||
if ((anchors & Window::AnchorTop) && (anchors & Window::AnchorBottom)) {
|
||||
size.setHeight(0);
|
||||
}
|
||||
if (size.isValid() && size != QSize(0, 0)) {
|
||||
set_size(size.width(), size.height());
|
||||
}
|
||||
setMargins(m_interface->margins());
|
||||
connect(m_interface, &Window::marginsChanged, this, [this]() {
|
||||
setMargins(m_interface->margins());
|
||||
});
|
||||
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
connect(m_interface, &Window::keyboardInteractivityChanged, this, [this]() {
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
});
|
||||
|
||||
setDesiredSize(window->windowContentGeometry().size());
|
||||
}
|
||||
|
||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||
{
|
||||
if (m_waitForSyncCallback) {
|
||||
wl_callback_destroy(m_waitForSyncCallback);
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::zwlr_layer_surface_v1_closed()
|
||||
{
|
||||
if (m_interface->closeOnDismissed()) {
|
||||
window()->window()->close();
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height)
|
||||
{
|
||||
@ -73,8 +91,8 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
||||
|
||||
if (!m_configured) {
|
||||
m_configured = true;
|
||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||
window()->handleExpose(QRect(QPoint(), m_pendingSize));
|
||||
applyConfigure();
|
||||
sendExpose();
|
||||
} else {
|
||||
// Later configures are resizes, so we have to queue them up for a time when we
|
||||
// are not painting to the window.
|
||||
@ -82,9 +100,37 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *popup)
|
||||
{
|
||||
std::any anyRole = popup->surfaceRole();
|
||||
|
||||
if (auto role = std::any_cast<::xdg_popup *>(&anyRole)) {
|
||||
get_popup(*role);
|
||||
} else {
|
||||
qCWarning(LAYERSHELLQT) << "Cannot attach popup of unknown type";
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::applyConfigure()
|
||||
{
|
||||
m_configuring = true;
|
||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||
m_configuring = false;
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
||||
{
|
||||
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
||||
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
|
||||
|
||||
QSize effectiveSize = size;
|
||||
if (horizontallyConstrained) {
|
||||
effectiveSize.setWidth(0);
|
||||
}
|
||||
if (verticallyConstrained) {
|
||||
effectiveSize.setHeight(0);
|
||||
}
|
||||
set_size(effectiveSize.width(), effectiveSize.height());
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setAnchor(uint anchor)
|
||||
@ -97,6 +143,13 @@ void QWaylandLayerSurface::setExclusiveZone(int32_t zone)
|
||||
set_exclusive_zone(zone);
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge)
|
||||
{
|
||||
if (zwlr_layer_surface_v1_get_version(object()) >= ZWLR_LAYER_SURFACE_V1_SET_EXCLUSIVE_EDGE_SINCE_VERSION) {
|
||||
set_exclusive_edge(edge);
|
||||
}
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setMargins(const QMargins &margins)
|
||||
{
|
||||
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
|
||||
@ -113,4 +166,100 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
||||
set_layer(layer);
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
{
|
||||
if (m_configuring) {
|
||||
return;
|
||||
}
|
||||
|
||||
setDesiredSize(geometry.size());
|
||||
requestWaylandSync();
|
||||
}
|
||||
|
||||
bool QWaylandLayerSurface::requestActivate()
|
||||
{
|
||||
QWaylandXdgActivationV1 *activation = m_shell->activation();
|
||||
if (!activation->isActive()) {
|
||||
return false;
|
||||
}
|
||||
if (!m_activationToken.isEmpty()) {
|
||||
activation->activate(m_activationToken, window()->wlSurface());
|
||||
m_activationToken = {};
|
||||
return true;
|
||||
} else {
|
||||
const auto focusWindow = QGuiApplication::focusWindow();
|
||||
const auto wlWindow = focusWindow ? static_cast<QtWaylandClient::QWaylandWindow*>(focusWindow->handle()) : window();
|
||||
if (const auto seat = wlWindow->display()->lastInputDevice()) {
|
||||
const auto tokenProvider = activation->requestXdgActivationToken(
|
||||
wlWindow->display(), wlWindow->wlSurface(), 0, QString());
|
||||
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this,
|
||||
[this](const QString &token) {
|
||||
m_shell->activation()->activate(token, window()->wlSurface());
|
||||
});
|
||||
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, tokenProvider, &QObject::deleteLater);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setXdgActivationToken(const QString &token)
|
||||
{
|
||||
m_activationToken = token;
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::requestXdgActivationToken(quint32 serial)
|
||||
{
|
||||
QWaylandXdgActivationV1 *activation = m_shell->activation();
|
||||
if (!activation->isActive()) {
|
||||
return;
|
||||
}
|
||||
auto tokenProvider = activation->requestXdgActivationToken(
|
||||
window()->display(), window()->wlSurface(), serial, QString());
|
||||
|
||||
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this,
|
||||
[this](const QString &token) {
|
||||
Q_EMIT window()->xdgActivationTokenCreated(token);
|
||||
});
|
||||
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, tokenProvider, &QObject::deleteLater);
|
||||
}
|
||||
|
||||
const wl_callback_listener QWaylandLayerSurface::syncCallbackListener = {
|
||||
.done = [](void *data, struct wl_callback *callback, uint32_t time){
|
||||
Q_UNUSED(time);
|
||||
wl_callback_destroy(callback);
|
||||
QWaylandLayerSurface *layerSurface = static_cast<QWaylandLayerSurface *>(data);
|
||||
layerSurface->m_waitForSyncCallback = nullptr;
|
||||
layerSurface->sendExpose();
|
||||
}
|
||||
};
|
||||
|
||||
void QWaylandLayerSurface::requestWaylandSync()
|
||||
{
|
||||
if (m_waitForSyncCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
m_waitForSyncCallback = wl_display_sync(m_window->display()->wl_display());
|
||||
wl_callback_add_listener(m_waitForSyncCallback, &syncCallbackListener, this);
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::handleWaylandSyncDone()
|
||||
{
|
||||
if (!window()->isExposed()) {
|
||||
return;
|
||||
}
|
||||
sendExpose();
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::sendExpose()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||
window()->handleExpose(QRect(QPoint(), m_pendingSize));
|
||||
#else
|
||||
window()->sendRecursiveExposeEvent();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,40 +10,63 @@
|
||||
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "qwaylandlayershellintegration_p.h"
|
||||
|
||||
#include "layershellqt_export.h"
|
||||
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
|
||||
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
class QWaylandLayerShell;
|
||||
|
||||
class Window;
|
||||
|
||||
class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylandShellSurface, public QtWayland::zwlr_layer_surface_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWaylandLayerSurface(QWaylandLayerShell *shell, QtWaylandClient::QWaylandWindow *window);
|
||||
QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window);
|
||||
~QWaylandLayerSurface() override;
|
||||
|
||||
bool isExposed() const override
|
||||
{
|
||||
return m_configured;
|
||||
return m_configured && !m_waitForSyncCallback;
|
||||
}
|
||||
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
||||
|
||||
void setDesiredSize(const QSize &size);
|
||||
void setAnchor(uint32_t anchor);
|
||||
void setExclusiveZone(int32_t zone);
|
||||
void setExclusiveEdge(uint32_t edge);
|
||||
void setMargins(const QMargins &margins);
|
||||
void setKeyboardInteractivity(uint32_t interactivity);
|
||||
void setLayer(uint32_t layer);
|
||||
|
||||
void applyConfigure() override;
|
||||
void setWindowGeometry(const QRect &geometry) override;
|
||||
|
||||
bool requestActivate() override;
|
||||
void setXdgActivationToken(const QString &token) override;
|
||||
void requestXdgActivationToken(quint32 serial) override;
|
||||
|
||||
private:
|
||||
void requestWaylandSync();
|
||||
void handleWaylandSyncDone();
|
||||
void sendExpose();
|
||||
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
||||
void zwlr_layer_surface_v1_closed() override;
|
||||
|
||||
QWaylandLayerShellIntegration *m_shell;
|
||||
LayerShellQt::Window *m_interface;
|
||||
QtWaylandClient::QWaylandWindow *m_window;
|
||||
QSize m_pendingSize;
|
||||
QString m_activationToken;
|
||||
|
||||
bool m_configured = false;
|
||||
bool m_configuring = false;
|
||||
|
||||
static const wl_callback_listener syncCallbackListener;
|
||||
struct wl_callback *m_waitForSyncCallback = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
44
src/qwaylandxdgactivationv1.cpp
Normal file
44
src/qwaylandxdgactivationv1.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/** Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "qwaylandxdgactivationv1_p.h"
|
||||
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
|
||||
|
||||
QWaylandXdgActivationV1::QWaylandXdgActivationV1()
|
||||
: QWaylandClientExtensionTemplate<QWaylandXdgActivationV1>(1)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
QWaylandXdgActivationV1::~QWaylandXdgActivationV1()
|
||||
{
|
||||
if (isActive()) {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
QWaylandXdgActivationTokenV1 *QWaylandXdgActivationV1::requestXdgActivationToken(QtWaylandClient::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;
|
||||
}
|
||||
|
||||
#include "moc_qwaylandxdgactivationv1_p.cpp"
|
48
src/qwaylandxdgactivationv1_p.h
Normal file
48
src/qwaylandxdgactivationv1_p.h
Normal file
@ -0,0 +1,48 @@
|
||||
/** Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef QWAYLANDXDGACTIVATIONV1_P_H
|
||||
#define QWAYLANDXDGACTIVATIONV1_P_H
|
||||
|
||||
#include "qwayland-xdg-activation-v1.h"
|
||||
#include <QObject>
|
||||
|
||||
#include <QtWaylandClient/QWaylandClientExtension>
|
||||
|
||||
namespace QtWaylandClient
|
||||
{
|
||||
class QWaylandDisplay;
|
||||
class QWaylandSurface;
|
||||
}
|
||||
|
||||
class QWaylandXdgActivationTokenV1 : public QObject, public QtWayland::xdg_activation_token_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~QWaylandXdgActivationTokenV1() override
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
protected:
|
||||
void xdg_activation_token_v1_done(const QString &token) override
|
||||
{
|
||||
Q_EMIT done(token);
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void done(const QString &token);
|
||||
};
|
||||
|
||||
class QWaylandXdgActivationV1 : public QWaylandClientExtensionTemplate<QWaylandXdgActivationV1>, public QtWayland::xdg_activation_v1
|
||||
{
|
||||
public:
|
||||
QWaylandXdgActivationV1();
|
||||
~QWaylandXdgActivationV1() override;
|
||||
|
||||
QWaylandXdgActivationTokenV1 *
|
||||
requestXdgActivationToken(QtWaylandClient::QWaylandDisplay *display, struct ::wl_surface *surface, std::optional<uint32_t> serial, const QString &app_id);
|
||||
};
|
||||
|
||||
#endif // QWAYLANDXDGACTIVATIONV1_P_H
|
@ -25,7 +25,7 @@
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="zwlr_layer_shell_v1" version="4">
|
||||
<interface name="zwlr_layer_shell_v1" version="5">
|
||||
<description summary="create surfaces that are layers of the desktop">
|
||||
Clients can use this interface to assign the surface_layer role to
|
||||
wl_surfaces. Such surfaces are assigned to a "layer" of the output and
|
||||
@ -100,7 +100,7 @@
|
||||
</request>
|
||||
</interface>
|
||||
|
||||
<interface name="zwlr_layer_surface_v1" version="4">
|
||||
<interface name="zwlr_layer_surface_v1" version="5">
|
||||
<description summary="layer metadata interface">
|
||||
An interface that may be implemented by a wl_surface, for surfaces that
|
||||
are designed to be rendered as a layer of a stacked desktop-like
|
||||
@ -367,6 +367,7 @@
|
||||
<entry name="invalid_size" value="1" summary="size is invalid"/>
|
||||
<entry name="invalid_anchor" value="2" summary="anchor bitfield is invalid"/>
|
||||
<entry name="invalid_keyboard_interactivity" value="3" summary="keyboard interactivity is invalid"/>
|
||||
<entry name="invalid_exclusive_edge" value="4" summary="exclusive edge is invalid given the surface anchors"/>
|
||||
</enum>
|
||||
|
||||
<enum name="anchor" bitfield="true">
|
||||
@ -386,5 +387,21 @@
|
||||
</description>
|
||||
<arg name="layer" type="uint" enum="zwlr_layer_shell_v1.layer" summary="layer to move this surface to"/>
|
||||
</request>
|
||||
|
||||
<!-- Version 5 additions -->
|
||||
|
||||
<request name="set_exclusive_edge" since="5">
|
||||
<description summary="set the edge the exclusive zone will be applied to">
|
||||
Requests an edge for the exclusive zone to apply. The exclusive
|
||||
edge will be automatically deduced from anchor points when possible,
|
||||
but when the surface is anchored to a corner, it will be necessary
|
||||
to set it explicitly to disambiguate, as it is not possible to deduce
|
||||
which one of the two corner edges should be used.
|
||||
|
||||
The edge must be one the surface is anchored to, otherwise the
|
||||
invalid_exclusive_edge protocol error will be raised.
|
||||
</description>
|
||||
<arg name="edge" type="uint"/>
|
||||
</request>
|
||||
</interface>
|
||||
</protocol>
|
||||
|
@ -14,7 +14,6 @@
|
||||
|
||||
#include <QMetaEnum>
|
||||
|
||||
#include <interfaces/shell.h>
|
||||
#include <interfaces/window.h>
|
||||
|
||||
using namespace LayerShellQt;
|
||||
@ -33,7 +32,7 @@ template<typename T>
|
||||
T stringToEnum(QMetaEnum metaEnum, const QString &str)
|
||||
{
|
||||
T ret = {};
|
||||
const auto splitted = str.split(QLatin1Char('|'));
|
||||
const auto splitted = str.split(QLatin1Char('|'), Qt::SkipEmptyParts);
|
||||
for (const auto &value : splitted) {
|
||||
ret |= T(metaEnum.keyToValue(qPrintable(value)));
|
||||
}
|
||||
@ -42,7 +41,7 @@ T stringToEnum(QMetaEnum metaEnum, const QString &str)
|
||||
|
||||
class BasicWindow : public QRasterWindow
|
||||
{
|
||||
void paintEvent(QPaintEvent *)
|
||||
void paintEvent(QPaintEvent *) override
|
||||
{
|
||||
QPainter p(this);
|
||||
p.fillRect(QRect(0, 0, width(), height()), Qt::red);
|
||||
@ -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();
|
||||
|
110
tests/quicktest.qml
Normal file
110
tests/quicktest.qml
Normal file
@ -0,0 +1,110 @@
|
||||
/*
|
||||
* SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleix.pol_gonzalez@mercedes-benz.com>
|
||||
*
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import QtQuick 2.15
|
||||
import org.kde.layershell 1.0 as LayerShell
|
||||
|
||||
Item
|
||||
{
|
||||
Text {
|
||||
text: "A normal Window"
|
||||
anchors.centerIn: parent
|
||||
}
|
||||
|
||||
Window {
|
||||
LayerShell.Window.anchors: LayerShell.Window.AnchorLeft
|
||||
LayerShell.Window.layer: LayerShell.Window.LayerBackground
|
||||
LayerShell.Window.exclusionZone: -1
|
||||
|
||||
width: 200
|
||||
height: 150
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "green"
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "left bg"
|
||||
}
|
||||
}
|
||||
visible: true
|
||||
}
|
||||
|
||||
|
||||
Window {
|
||||
LayerShell.Window.scope: "dock"
|
||||
LayerShell.Window.anchors: LayerShell.Window.AnchorLeft
|
||||
LayerShell.Window.layer: LayerShell.Window.LayerTop
|
||||
LayerShell.Window.exclusionZone: width
|
||||
|
||||
width: 100
|
||||
height: 100
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "red"
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "left"
|
||||
}
|
||||
}
|
||||
visible: true
|
||||
}
|
||||
|
||||
Window {
|
||||
LayerShell.Window.scope: "normal"
|
||||
LayerShell.Window.anchors: LayerShell.Window.AnchorRight
|
||||
|
||||
width: 100
|
||||
height: 100
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "red"
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "right"
|
||||
}
|
||||
}
|
||||
visible: true
|
||||
}
|
||||
|
||||
Window {
|
||||
LayerShell.Window.scope: "normal"
|
||||
LayerShell.Window.anchors: LayerShell.Window.AnchorTop
|
||||
|
||||
width: 100
|
||||
height: 100
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "red"
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "top"
|
||||
}
|
||||
}
|
||||
visible: true
|
||||
}
|
||||
|
||||
Window {
|
||||
LayerShell.Window.scope: "normal"
|
||||
LayerShell.Window.anchors: LayerShell.Window.AnchorBottom
|
||||
|
||||
width: 100
|
||||
height: 100
|
||||
Rectangle {
|
||||
anchors.fill: parent
|
||||
color: "red"
|
||||
|
||||
Text {
|
||||
anchors.centerIn: parent
|
||||
text: "bottom"
|
||||
}
|
||||
}
|
||||
visible: true
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user