Compare commits

..

30 Commits

Author SHA1 Message Date
7a074a3684 update version for new release 2025-05-19 18:33:35 +05:30
8b54edb695 update version for new release 2025-05-15 15:14:19 +05:30
ffa33fef9f Update Qt version requirement to 6.8.0
GIT_SILENT
2025-05-15 14:20:07 +05:30
3522070454 Update Frameworks version requirement to 6.14.0
GIT_SILENT
2025-05-15 14:20:07 +05:30
80d5e3c935 Expose setDesiredSize to the C++ API
Making it possible for clients to call setDesiredSize directly,

The idea is that under Wayland, the panel calls this intead of setGeometry,
not trying to set an abosulute geometry that might cause the panel sized wrongly,
but just sets an hint which will ensure the panel won't overlap another one

used by https://invent.kde.org/plasma/plasma-workspace/-/merge_requests/5437

CCBUG:489703
2025-04-30 17:23:48 +02:00
b37ac92e9f CI: Add linux-qt6-next build 2025-02-12 07:28:37 +01:00
c8c8e3e983 Add xml/yaml linting 2025-02-01 09:52:29 +01:00
72d40f696e Fix build with Qt 6.10
The private parts have been extracted into a separate CMake config file, which we need to search for now

See https://bugreports.qt.io/browse/QTBUG-87776
2025-01-29 15:34:52 +01:00
ac333b19c7 update version for new release 2025-01-09 12:46:54 +00:00
c85d6e7baa update version for new release 2025-01-09 11:01:05 +00:00
e534206172 Update Frameworks version requirement to 6.10.0
GIT_SILENT
2025-01-09 10:29:52 +00:00
edb8f67b1b It compiles without deprecated methods 2024-12-18 13:24:21 +01:00
1796255496 update version for new release 2024-10-03 13:11:32 +01:00
2dbd1d6eb7 Update Frameworks version requirement to 6.5.0
GIT_SILENT
2024-09-12 11:08:45 +01:00
0d11058c8f update version for new release 2024-09-12 10:50:16 +01:00
a5fbaa5975 Reformat CMake code for better readability 2024-08-14 11:08:41 +02:00
6f8a3f5d42 Generate wayland code with PRIVATE_CODE 2024-08-14 10:47:07 +02:00
303f68cf10 Update Qt version requirement to 6.7.0
GIT_SILENT
2024-08-02 10:15:46 +01:00
368cf2dd37 Port to QWaylandWindow::updateExposure() 2024-07-05 09:49:38 +03:00
16a1debdca Port to QWaylandShellSurface::setWindowSize() 2024-06-26 13:01:50 +03:00
c4987c01c7 update version for new release 2024-05-24 16:14:22 +01:00
bfdf40b1b5 Update Qt version requirement to 6.6.0
GIT_SILENT
2024-05-24 13:11:58 +01:00
8676cf98ce update version for new release 2024-05-24 12:32:48 +01:00
16da49d3a9 Update Qt version requirement to 6.7.0
GIT_SILENT
2024-05-24 11:22:43 +01:00
97d85c8722 Update Frameworks version requirement to 6.2.0
GIT_SILENT
2024-05-24 11:22:43 +01:00
44e011e2c6 declarative: Add a QML extension object for accessing the margins property
Otherwise we get the following error message:
Property "margins" with type "QMargins", which is not a value type

Signed-off-by: Victoria Fischer <victoria.fischer@mbition.io>
2024-05-20 10:01:24 +00:00
05de6c67b2 Enforce passing tests on all platforms 2024-04-22 23:45:49 +02:00
7c4706c415 Add clang-format commit hook 2024-04-21 17:51:44 +02:00
80a047c0db Run clang-format 2024-04-21 17:50:57 +02:00
2ac46d8d9d Drop now defunct code to sync resizes
This code was designed to make sure we didn't commit new buffers whilst
we were waiting for a configure. The way this worked failed in 6 after
kwin does not reply to desired_size changes immediately.

It is uneeded after kwin commit "wayland: Avoid rearranging layer
surfaces when wl_surface size changes" which means if we do submit
frames between size change requests, they'll be ignored. Meaning the
client will eventually get a configure event at the right size.
2024-04-11 17:57:14 +01:00
13 changed files with 141 additions and 100 deletions

View File

@ -7,3 +7,6 @@ include:
- /gitlab-templates/reuse-lint.yml
- /gitlab-templates/linux-qt6.yml
- /gitlab-templates/freebsd-qt6.yml
- /gitlab-templates/xml-lint.yml
- /gitlab-templates/yaml-lint.yml
- /gitlab-templates/linux-qt6-next.yml

View File

@ -2,8 +2,11 @@
# SPDX-License-Identifier: CC0-1.0
Dependencies:
- 'on': ['@all']
'require':
- 'on': ['@all']
'require':
'frameworks/extra-cmake-modules': '@latest-kf6'
'third-party/wayland': '@latest'
'third-party/wayland-protocols': '@latest'
Options:
require-passing-tests-on: ['Linux', 'FreeBSD', 'Windows']

View File

@ -4,13 +4,13 @@
cmake_minimum_required(VERSION 3.16)
project(layershellqt)
set(PROJECT_VERSION "6.0.80")
set(PROJECT_VERSION "6.4.80")
set(PROJECT_VERSION_MAJOR 6)
set(CMAKE_C_STANDARD 99)
set(QT_MIN_VERSION "6.6.0")
set(KF6_MIN_VERSION "6.0.0")
set(QT_MIN_VERSION "6.8.0")
set(KF6_MIN_VERSION "6.14.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 20)
@ -31,9 +31,14 @@ include(GenerateExportHeader)
include(KDEClangFormat)
include(ECMQtDeclareLoggingCategory)
include(ECMQmlModule)
include(KDEGitCommitHooks)
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
if (Qt6WaylandClient_VERSION VERSION_GREATER_EQUAL "6.10.0")
find_package(Qt6WaylandClientPrivate ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
endif()
find_package(WaylandScanner REQUIRED)
find_package(Wayland 1.3 COMPONENTS Client Server)
find_package(WaylandProtocols REQUIRED)
@ -53,8 +58,10 @@ 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 6.5
KF 5.240
kde_configure_git_pre_commit_hook(CHECKS CLANG_FORMAT)
ecm_set_disabled_deprecation_versions(QT 6.8.1
KF 6.9.0
)
add_subdirectory(src)

View File

@ -2,7 +2,7 @@
# SPDX-License-Identifier: CC0-1.0
maintainer:
- vladz
- vladz
description: Layer Shell Qt
platforms:
- name: Linux

View File

@ -4,10 +4,16 @@
remove_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS)
add_library(LayerShellQtInterface)
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
if (Qt6_VERSION VERSION_GREATER_EQUAL "6.8.0")
set(private_code_option "PRIVATE_CODE")
endif()
qt6_generate_wayland_protocol_client_sources(LayerShellQtInterface
${private_code_option}
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
)
ecm_qt_declare_logging_category(LayerShellQtInterface

View File

@ -4,20 +4,47 @@
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include <QQmlExtensionPlugin>
#include "../interfaces/window.h"
#include <QQmlExtensionPlugin>
#include <qqml.h>
QML_DECLARE_TYPEINFO(LayerShellQt::Window, QML_HAS_ATTACHED_PROPERTIES)
class ExtQMargins
{
QMargins m_margins;
Q_GADGET
Q_PROPERTY(int left READ left WRITE setLeft FINAL)
Q_PROPERTY(int right READ right WRITE setRight FINAL)
Q_PROPERTY(int top READ top WRITE setTop FINAL)
Q_PROPERTY(int bottom READ bottom WRITE setBottom FINAL)
QML_FOREIGN(QMargins)
QML_EXTENDED(ExtQMargins)
public:
ExtQMargins(const QMargins &margins);
int left() const { return m_margins.left(); }
void setLeft(int left) { m_margins.setLeft(left); }
int right() const { return m_margins.right(); }
void setRight(int right) { m_margins.setRight(right); }
int top() const { return m_margins.top(); }
void setTop(int top) { m_margins.setTop(top); }
int bottom() const { return m_margins.bottom(); }
void setBottom(int bottom) { m_margins.setBottom(bottom); }
};
class Plugin : public QQmlExtensionPlugin
{
Q_PLUGIN_METADATA(IID "org.kde.layershellqt")
Q_OBJECT
public:
void registerTypes(const char *uri) override {
void registerTypes(const char *uri) override
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.layershell"));
qmlRegisterType<LayerShellQt::Window>(uri, 1, 0, "Window");
qmlRegisterExtendedUncreatableType<QMargins, ExtQMargins>(uri, 1, 0, "ExtQMargins", QStringLiteral("Only created from C++"));
}
};

View File

@ -32,6 +32,7 @@ public:
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
Window::Layer layer = Window::LayerTop;
QMargins margins;
QSize desiredSize = QSize(0, 0);
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
bool closeOnDismissed = true;
};
@ -97,6 +98,21 @@ QMargins Window::margins() const
return d->margins;
}
void Window::setDesiredSize(const QSize &size)
{
if (size == d->desiredSize) {
return;
}
d->desiredSize = size;
Q_EMIT desiredSizeChanged();
}
QSize Window::desiredSize() const
{
return d->desiredSize;
}
void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity)
{
if (d->keyboardInteractivity != interactivity) {

View File

@ -86,6 +86,9 @@ public:
void setMargins(const QMargins &margins);
QMargins margins() const;
void setDesiredSize(const QSize &size);
QSize desiredSize() const;
void setKeyboardInteractivity(KeyboardInteractivity interactivity);
KeyboardInteractivity keyboardInteractivity() const;
@ -127,6 +130,7 @@ Q_SIGNALS:
void exclusionZoneChanged();
void exclusiveEdgeChanged();
void marginsChanged();
void desiredSizeChanged();
void keyboardInteractivityChanged();
void layerChanged();

View File

@ -32,5 +32,4 @@ QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShel
return new QWaylandLayerSurface(this, window);
}
}

View File

@ -18,14 +18,19 @@ class QWaylandXdgActivationV1;
namespace LayerShellQt
{
class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>, public QtWayland::zwlr_layer_shell_v1
class LAYERSHELLQT_EXPORT QWaylandLayerShellIntegration : public QtWaylandClient::QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>,
public QtWayland::zwlr_layer_shell_v1
{
public:
QWaylandLayerShellIntegration();
~QWaylandLayerShellIntegration() override;
QWaylandXdgActivationV1 *activation() const { return m_xdgActivation.data(); }
QWaylandXdgActivationV1 *activation() const
{
return m_xdgActivation.data();
}
QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
private:
QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation;
};

View File

@ -44,7 +44,11 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
setAnchor(m_interface->anchors());
connect(m_interface, &Window::anchorsChanged, this, [this]() {
setAnchor(m_interface->anchors());
setDesiredSize(m_window->windowContentGeometry().size());
if (m_interface->desiredSize().isNull()) {
setDesiredSize(m_window->windowContentGeometry().size());
} else {
setDesiredSize(m_interface->desiredSize());
}
});
setExclusiveZone(m_interface->exclusionZone());
@ -61,21 +65,26 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
setMargins(m_interface->margins());
});
connect(m_interface, &Window::desiredSizeChanged, this, [this]() {
if (!m_interface->desiredSize().isNull()) {
setDesiredSize(m_interface->desiredSize());
}
});
setKeyboardInteractivity(m_interface->keyboardInteractivity());
connect(m_interface, &Window::keyboardInteractivityChanged, this, [this]() {
setKeyboardInteractivity(m_interface->keyboardInteractivity());
});
setDesiredSize(window->windowContentGeometry().size());
requestWaylandSync();
if (m_interface->desiredSize().isNull()) {
setDesiredSize(window->windowContentGeometry().size());
} else {
setDesiredSize(m_interface->desiredSize());
}
}
QWaylandLayerSurface::~QWaylandLayerSurface()
{
for (auto syncCallback: m_waitForSyncCallbacks) {
wl_callback_destroy(syncCallback);
}
m_waitForSyncCallbacks.clear();
destroy();
}
@ -88,17 +97,9 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_closed()
void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height)
{
qDebug() << "got configure";
ack_configure(serial);
m_pendingSize = QSize(width, height);
// because configure lacks a way to match it up with our resize requests
// we apply it only when our callback sync is complete
if (!m_waitForSyncCallbacks.isEmpty()) {
m_hasPendingConfigureToApply = true;
return;
}
if (!m_configured) {
m_configured = true;
applyConfigure();
@ -108,8 +109,6 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
// are not painting to the window.
window()->applyConfigureWhenPossible();
}
qDebug() << "end got confiure";
}
void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *popup)
@ -125,10 +124,13 @@ void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *po
void QWaylandLayerSurface::applyConfigure()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
m_configuring = true;
qDebug() << "resizing panel to " << m_pendingSize;
#endif
window()->resizeFromApplyConfigure(m_pendingSize);
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
m_configuring = false;
#endif
}
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
@ -143,7 +145,6 @@ void QWaylandLayerSurface::setDesiredSize(const QSize &size)
if (verticallyConstrained) {
effectiveSize.setHeight(0);
}
qDebug() << "requesting size " << effectiveSize;
set_size(effectiveSize.width(), effectiveSize.height());
}
@ -180,15 +181,25 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
set_layer(layer);
}
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
{
if (m_configuring) {
return;
}
setDesiredSize(geometry.size());
requestWaylandSync();
if (m_interface->desiredSize().isNull()) {
setDesiredSize(geometry.size());
}
}
#else
void QWaylandLayerSurface::setWindowSize(const QSize &size)
{
if (m_interface->desiredSize().isNull()) {
setDesiredSize(size);
}
}
#endif
bool QWaylandLayerSurface::requestActivate()
{
@ -202,14 +213,12 @@ bool QWaylandLayerSurface::requestActivate()
return true;
} else {
const auto focusWindow = QGuiApplication::focusWindow();
const auto wlWindow = focusWindow ? static_cast<QtWaylandClient::QWaylandWindow*>(focusWindow->handle()) : window();
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());
});
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;
}
@ -228,63 +237,23 @@ void QWaylandLayerSurface::requestXdgActivationToken(quint32 serial)
if (!activation->isActive()) {
return;
}
auto tokenProvider = activation->requestXdgActivationToken(
window()->display(), window()->wlSurface(), serial, QString());
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, 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_waitForSyncCallbacks.removeOne(callback);
layerSurface->handleWaylandSyncDone();
}
};
void QWaylandLayerSurface::requestWaylandSync()
{
auto syncCallback = wl_display_sync(m_window->display()->wl_display());
m_waitForSyncCallbacks.append(syncCallback);
wl_callback_add_listener(syncCallback, &syncCallbackListener, this);
}
void QWaylandLayerSurface::handleWaylandSyncDone()
{
qDebug() << "handle sync done";
if (!window()->window()->isVisible() || !m_waitForSyncCallbacks.isEmpty()) {
return;
}
if (m_hasPendingConfigureToApply) {
m_hasPendingConfigureToApply = false;
if (!m_configured) {
m_configured = true;
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.
window()->applyConfigureWhenPossible();
}
}
qDebug() << "end handle sync done";
}
void QWaylandLayerSurface::sendExpose()
{
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
window()->handleExpose(QRect(QPoint(), m_pendingSize));
#else
#elif QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
window()->sendRecursiveExposeEvent();
#else
window()->updateExposure();
#endif
}
}

View File

@ -30,7 +30,7 @@ public:
bool isExposed() const override
{
return m_configured && m_waitForSyncCallbacks.isEmpty();
return m_configured;
}
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
@ -43,15 +43,17 @@ public:
void setLayer(uint32_t layer);
void applyConfigure() override;
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
void setWindowGeometry(const QRect &geometry) override;
#else
void setWindowSize(const QSize &size) override;
#endif
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;
@ -63,12 +65,11 @@ private:
QString m_activationToken;
bool m_configured = false;
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
bool m_configuring = false;
bool m_hasPendingConfigureToApply = false;
static const wl_callback_listener syncCallbackListener;
QList<struct wl_callback*> m_waitForSyncCallbacks;
#endif
};
}
#endif

View File

@ -39,6 +39,7 @@ Item
LayerShell.Window.anchors: LayerShell.Window.AnchorLeft
LayerShell.Window.layer: LayerShell.Window.LayerTop
LayerShell.Window.exclusionZone: width
LayerShell.Window.margins.left: 100
width: 100
height: 100