Compare commits

..

5 Commits

Author SHA1 Message Date
94ac4be08f Update version for new release 6.5.90 2026-01-13 15:43:16 +05:30
df03deab5c Update Qt version requirement to 6.10.0
GIT_SILENT
2026-01-13 14:39:55 +05:30
44fe89b1b6 Update Frameworks version requirement to 6.22.0
GIT_SILENT
2026-01-13 14:39:55 +05:30
58f549d136 Provide serial for requesting an activation token
Otherwise, window activation does not work.

Taken from QWaylandXdgSurface::requestActivate
2025-12-24 15:03:48 +03:00
9ddf87a444 Deprecate Shell::useLayerShell()
it's not needed since Qt 6.5 and can potentially leak the environment
variable.
2025-12-18 15:20:57 +01:00
10 changed files with 35 additions and 388 deletions

View File

@ -4,13 +4,13 @@
cmake_minimum_required(VERSION 3.16)
project(layershellqt)
set(PROJECT_VERSION "6.5.80")
set(PROJECT_VERSION "6.5.90")
set(PROJECT_VERSION_MAJOR 6)
set(CMAKE_C_STANDARD 99)
set(QT_MIN_VERSION "6.9.0")
set(KF6_MIN_VERSION "6.18.0")
set(QT_MIN_VERSION "6.10.0")
set(KF6_MIN_VERSION "6.22.0")
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
set(CMAKE_CXX_STANDARD 20)
@ -32,6 +32,7 @@ include(KDEClangFormat)
include(ECMQtDeclareLoggingCategory)
include(ECMQmlModule)
include(KDEGitCommitHooks)
include(ECMGenerateExportHeader)
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)

View File

@ -64,10 +64,12 @@ ecm_generate_headers(LayerShellQt_HEADERS
)
generate_export_header(LayerShellQtInterface
ecm_generate_export_header(LayerShellQtInterface
BASE_NAME LayerShellQtInterface
EXPORT_MACRO_NAME LAYERSHELLQT_EXPORT
EXPORT_FILE_NAME LayerShellQt/layershellqt_export.h
VERSION ${LAYERSHELLQT_VERSION}
DEPRECATION_VERSIONS 6.6
)
install(TARGETS layer-shell

View File

@ -5,6 +5,9 @@
*/
#include "shell.h"
#if LAYERSHELLQTINTERFACE_BUILD_DEPRECATED_SINCE(6, 6)
#include <QByteArray>
#include <layershellqt_logging.h>
#include <qglobal.h>
@ -18,3 +21,4 @@ void Shell::useLayerShell()
qCDebug(LAYERSHELLQT) << "Unable to set QT_WAYLAND_SHELL_INTEGRATION=layer-shell";
}
}
#endif

View File

@ -8,7 +8,9 @@
#define LAYERSHELLQTSHELL_H
#include "layershellqt_export.h"
#include "window.h"
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
#include <QString>
namespace LayerShellQt
@ -19,9 +21,11 @@ namespace LayerShellQt
class LAYERSHELLQT_EXPORT Shell
{
public:
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Calling useLayerShell is not needed since Qt 6.5")
static void useLayerShell();
};
}
#endif
#endif

View File

@ -17,49 +17,6 @@
using namespace LayerShellQt;
Margin::Margin()
: m_value(0)
{
}
Margin::Margin(int pixels)
: m_value(pixels)
{
}
Margin::Margin(qreal fraction)
: m_value(fraction)
{
}
Margin Margin::fromPixels(int pixels)
{
return Margin(pixels);
}
Margin Margin::fromFraction(qreal fraction)
{
return Margin(fraction);
}
std::optional<int> Margin::pixels() const
{
if (std::holds_alternative<int>(m_value)) {
return std::get<int>(m_value);
} else {
return std::nullopt;
}
}
std::optional<qreal> Margin::fraction() const
{
if (std::holds_alternative<qreal>(m_value)) {
return std::get<qreal>(m_value);
} else {
return std::nullopt;
}
}
class LayerShellQt::WindowPrivate
{
public:
@ -75,10 +32,7 @@ public:
Window::Anchor exclusiveEdge = Window::AnchorNone;
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
Window::Layer layer = Window::LayerTop;
Margin leftMargin;
Margin topMargin;
Margin rightMargin;
Margin bottomMargin;
QMargins margins;
QSize desiredSize = QSize(0, 0);
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
bool closeOnDismissed = true;
@ -135,74 +89,15 @@ Window::Anchor Window::exclusiveEdge() const
void Window::setMargins(const QMargins &margins)
{
setLeftMargin(Margin::fromPixels(margins.left()));
setTopMargin(Margin::fromPixels(margins.top()));
setRightMargin(Margin::fromPixels(margins.right()));
setBottomMargin(Margin::fromPixels(margins.bottom()));
if (d->margins != margins) {
d->margins = margins;
Q_EMIT marginsChanged();
}
}
QMargins Window::margins() const
{
return QMargins(d->leftMargin.pixels().value_or(0),
d->topMargin.pixels().value_or(0),
d->rightMargin.pixels().value_or(0),
d->bottomMargin.pixels().value_or(0));
}
void Window::setLeftMargin(Margin margin)
{
if (d->leftMargin != margin) {
d->leftMargin = margin;
Q_EMIT leftMarginChanged();
Q_EMIT marginsChanged();
}
}
Margin Window::leftMargin() const
{
return d->leftMargin;
}
void Window::setTopMargin(Margin margin)
{
if (d->topMargin != margin) {
d->topMargin = margin;
Q_EMIT topMarginChanged();
Q_EMIT marginsChanged();
}
}
Margin Window::topMargin() const
{
return d->topMargin;
}
void Window::setRightMargin(Margin margin)
{
if (d->rightMargin != margin) {
d->rightMargin = margin;
Q_EMIT rightMarginChanged();
Q_EMIT marginsChanged();
}
}
Margin Window::rightMargin() const
{
return d->rightMargin;
}
void Window::setBottomMargin(Margin margin)
{
if (d->bottomMargin != margin) {
d->bottomMargin = margin;
Q_EMIT bottomMarginChanged();
Q_EMIT marginsChanged();
}
}
Margin Window::bottomMargin() const
{
return d->bottomMargin;
return d->margins;
}
void Window::setDesiredSize(const QSize &size)

View File

@ -18,34 +18,6 @@ namespace LayerShellQt
{
class WindowPrivate;
/**
* The Margin type provides a way to specify how far a layer surface should be away from a screen edge.
*
* A margin can have an absolute value or a percent value. An absolute value indicates the distance
* in pixels. A percent value indicates the distance as a percentage of the output size, for example
* this can be used to tell the compositor that the surface should be one third of the output height from
* a screen edge, etc.
*/
class LAYERSHELLQT_EXPORT Margin
{
public:
static Margin fromPixels(int pixels);
static Margin fromFraction(qreal fraction);
Margin();
std::optional<int> pixels() const;
std::optional<qreal> fraction() const;
auto operator<=>(const Margin &other) const = default;
private:
Margin(int pixels);
Margin(qreal fraction);
std::variant<int, qreal> m_value;
};
class LAYERSHELLQT_EXPORT Window : public QObject
{
Q_OBJECT
@ -115,18 +87,6 @@ public:
void setMargins(const QMargins &margins);
QMargins margins() const;
void setLeftMargin(Margin margin);
Margin leftMargin() const;
void setTopMargin(Margin margin);
Margin topMargin() const;
void setRightMargin(Margin margin);
Margin rightMargin() const;
void setBottomMargin(Margin margin);
Margin bottomMargin() const;
void setDesiredSize(const QSize &size);
QSize desiredSize() const;
@ -185,10 +145,6 @@ Q_SIGNALS:
void exclusionZoneChanged();
void exclusiveEdgeChanged();
void marginsChanged();
void leftMarginChanged();
void topMarginChanged();
void rightMarginChanged();
void bottomMarginChanged();
void desiredSizeChanged();
void keyboardInteractivityChanged();
void layerChanged();

View File

@ -15,7 +15,7 @@
namespace LayerShellQt
{
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(6)
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(5)
, m_xdgActivation(new QWaylandXdgActivationV1)
{
}

View File

@ -10,6 +10,7 @@
#include "qwaylandlayersurface_p.h"
#include "qwaylandxdgactivationv1_p.h"
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
#include <QtWaylandClient/private/qwaylandscreen_p.h>
#include <QtWaylandClient/private/qwaylandsurface_p.h>
#include <QtWaylandClient/private/qwaylandwindow_p.h>
@ -60,24 +61,9 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
setExclusiveEdge(m_interface->exclusiveEdge());
});
setLeftMargin(m_interface->leftMargin());
connect(m_interface, &Window::leftMarginChanged, this, [this]() {
setLeftMargin(m_interface->leftMargin());
});
setTopMargin(m_interface->topMargin());
connect(m_interface, &Window::topMarginChanged, this, [this]() {
setTopMargin(m_interface->topMargin());
});
setRightMargin(m_interface->rightMargin());
connect(m_interface, &Window::rightMarginChanged, this, [this]() {
setRightMargin(m_interface->rightMargin());
});
setBottomMargin(m_interface->bottomMargin());
connect(m_interface, &Window::bottomMarginChanged, this, [this]() {
setBottomMargin(m_interface->bottomMargin());
setMargins(m_interface->margins());
connect(m_interface, &Window::marginsChanged, this, [this]() {
setMargins(m_interface->margins());
});
connect(m_interface, &Window::desiredSizeChanged, this, [this]() {
@ -174,68 +160,9 @@ void QWaylandLayerSurface::setExclusiveEdge(uint32_t edge)
}
}
void QWaylandLayerSurface::setLeftMargin(const Margin &margin)
void QWaylandLayerSurface::setMargins(const QMargins &margins)
{
if (zwlr_layer_surface_v1_get_version(object()) >= 6) {
if (const auto pixels = margin.pixels()) {
set_left_margin_units(*pixels);
} else if (const auto fraction = margin.fraction()) {
set_left_margin_fraction(wl_fixed_from_double(*fraction));
} else {
qCWarning(LAYERSHELLQT) << "Unspecified left margin for" << m_window->window();
}
} else {
const QMargins margins = m_interface->margins();
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
}
}
void QWaylandLayerSurface::setTopMargin(const Margin &margin)
{
if (zwlr_layer_surface_v1_get_version(object()) >= 6) {
if (const auto pixels = margin.pixels()) {
set_top_margin_units(*pixels);
} else if (const auto fraction = margin.fraction()) {
set_top_margin_fraction(wl_fixed_from_double(*fraction));
} else {
qCWarning(LAYERSHELLQT) << "Unspecified top margin for" << m_window->window();
}
} else {
const QMargins margins = m_interface->margins();
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
}
}
void QWaylandLayerSurface::setRightMargin(const Margin &margin)
{
if (zwlr_layer_surface_v1_get_version(object()) >= 6) {
if (const auto pixels = margin.pixels()) {
set_right_margin_units(*pixels);
} else if (const auto fraction = margin.fraction()) {
set_right_margin_fraction(wl_fixed_from_double(*fraction));
} else {
qCWarning(LAYERSHELLQT) << "Unspecified right margin for" << m_window->window();
}
} else {
const QMargins margins = m_interface->margins();
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
}
}
void QWaylandLayerSurface::setBottomMargin(const Margin &margin)
{
if (zwlr_layer_surface_v1_get_version(object()) >= 6) {
if (const auto pixels = margin.pixels()) {
set_bottom_margin_units(*pixels);
} else if (const auto fraction = margin.fraction()) {
set_bottom_margin_fraction(wl_fixed_from_double(*fraction));
} else {
qCWarning(LAYERSHELLQT) << "Unspecified bottom margin for" << m_window->window();
}
} else {
const QMargins margins = m_interface->margins();
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
}
set_margin(margins.top(), margins.right(), margins.bottom(), margins.left());
}
void QWaylandLayerSurface::setKeyboardInteractivity(uint32_t interactivity)
@ -274,7 +201,7 @@ bool QWaylandLayerSurface::requestActivate()
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());
const auto tokenProvider = activation->requestXdgActivationToken(wlWindow->display(), wlWindow->wlSurface(), seat->serial(), QString());
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, [this](const QString &token) {
m_shell->activation()->activate(token, window()->wlSurface());
});

View File

@ -19,7 +19,6 @@
namespace LayerShellQt
{
class Margin;
class Window;
class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylandShellSurface, public QtWayland::zwlr_layer_surface_v1
@ -39,10 +38,7 @@ public:
void setAnchor(uint32_t anchor);
void setExclusiveZone(int32_t zone);
void setExclusiveEdge(uint32_t edge);
void setLeftMargin(const Margin &margin);
void setTopMargin(const Margin &margin);
void setRightMargin(const Margin &margin);
void setBottomMargin(const Margin &margin);
void setMargins(const QMargins &margins);
void setKeyboardInteractivity(uint32_t interactivity);
void setLayer(uint32_t layer);

View File

@ -25,7 +25,7 @@
THIS SOFTWARE.
</copyright>
<interface name="zwlr_layer_shell_v1" version="6">
<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="6">
<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
@ -187,7 +187,7 @@
<arg name="zone" type="int"/>
</request>
<request name="set_margin" deprecated-since="6">
<request name="set_margin">
<description summary="sets a margin from the anchor point">
Requests that the surface be placed some distance away from the anchor
point on the output, in surface-local coordinates. Setting this value
@ -196,10 +196,6 @@
The exclusive zone includes the margin.
Margin is double-buffered, see wl_surface.commit.
This request is deprecated since version 6. Use set_left_margin_{units,fraction},
set_top_margin_{units,fraction}, set_right_margin_{units,fraction}, and
set_bottom_margin_{units,fraction} requests instead.
</description>
<arg name="top" type="int"/>
<arg name="right" type="int"/>
@ -405,141 +401,7 @@
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" enum="anchor"/>
</request>
<!-- Version 6 additions -->
<request name="set_left_margin_units" since="6">
<description summary="set the left margin in surface local coordinates">
Sets the left margin in surface-local coordinates.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The left margin specified using set_left_margin_fraction will be
overwritten by this request.
Margins are double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="int"/>
</request>
<request name="set_left_margin_fraction" since="6">
<description summary="set the left margin as a fraction">
Sets the left margin as a fraction of the available area width. The
margin value is a number between 0 and 1.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The left margin specified using set_left_margin_units will be
overwritten by this request.
Margin is double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="fixed"/>
</request>
<request name="set_top_margin_units" since="6">
<description summary="set the top margin in surface local coordinates">
Sets the top margin in surface-local coordinates.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The top margin specified using set_top_margin_fraction will be
overwritten by this request.
Margins are double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="int"/>
</request>
<request name="set_top_margin_fraction" since="6">
<description summary="set the top margin as a fraction">
Sets the top margin as a fraction of the available area height. The
margin value is a number between 0 and 1.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The top margin specified using set_top_margin_units will be
overwritten by this request.
Margin is double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="fixed"/>
</request>
<request name="set_right_margin_units" since="6">
<description summary="set the right margin in surface local coordinates">
Sets the right margin in surface-local coordinates.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The right margin specified using set_right_margin_fraction will be
overwritten by this request.
Margins are double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="int"/>
</request>
<request name="set_right_margin_fraction" since="6">
<description summary="set the right margin as a fraction">
Sets the right margin as a fraction of the available area width. The
margin value is a number between 0 and 1.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The right margin specified using set_right_margin_units will be
overwritten by this request.
Margin is double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="fixed"/>
</request>
<request name="set_bottom_margin_units" since="6">
<description summary="set the bottom margin in surface local coordinates">
Sets the bottom margin in surface-local coordinates.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The bottom margin specified using set_bottom_margin_fraction will be
overwritten by this request.
Margins are double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="int"/>
</request>
<request name="set_bottom_margin_fraction" since="6">
<description summary="set the bottom margin as a fraction">
Sets the bottom margin as a fraction of the available area height. The
margin value is a number between 0 and 1.
Margins specify that the surface should be placed some distance away
from the anchor point on the output. Setting a margin for an edge
you are not anchored to has no effect.
The bottom margin specified using set_bottom_margin_units will be
overwritten by this request.
Margin is double-buffered, see wl_surface.commit.
</description>
<arg name="margin" type="fixed"/>
<arg name="edge" type="uint"/>
</request>
</interface>
</protocol>