mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2026-01-30 18:30:11 -05:00
Compare commits
8 Commits
work/zzag/
...
v6.5.91
| Author | SHA1 | Date | |
|---|---|---|---|
| 211decbae8 | |||
| 60b7d27ae0 | |||
| 3dacd70398 | |||
| 94ac4be08f | |||
| df03deab5c | |||
| 44fe89b1b6 | |||
| 58f549d136 | |||
| 9ddf87a444 |
@ -4,13 +4,13 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(layershellqt)
|
||||
set(PROJECT_VERSION "6.5.80")
|
||||
set(PROJECT_VERSION "6.5.91")
|
||||
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)
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -11,55 +11,13 @@
|
||||
|
||||
#include <QPlatformSurfaceEvent>
|
||||
#include <QPointer>
|
||||
#include <mutex>
|
||||
#include <optional>
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
|
||||
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,12 +33,10 @@ 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;
|
||||
QPointer<QScreen> screen;
|
||||
bool wantsToBeOnActiveScreen = false;
|
||||
bool closeOnDismissed = true;
|
||||
bool activateOnShow = true;
|
||||
};
|
||||
@ -135,74 +91,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)
|
||||
@ -257,14 +154,73 @@ Window::Layer Window::layer() const
|
||||
return d->layer;
|
||||
}
|
||||
|
||||
#if LAYERSHELLQTINTERFACE_BUILD_DEPRECATED_SINCE(6, 6)
|
||||
Window::ScreenConfiguration Window::screenConfiguration() const
|
||||
{
|
||||
return d->screenConfiguration;
|
||||
if (wantsToBeOnActiveScreen()) {
|
||||
return ScreenFromCompositor;
|
||||
} else {
|
||||
// If an explicit screen is set, it's quite inaccurate but it should be fine.
|
||||
return ScreenFromQWindow;
|
||||
}
|
||||
}
|
||||
|
||||
void Window::setScreenConfiguration(Window::ScreenConfiguration screenConfiguration)
|
||||
void Window::setScreenConfiguration(ScreenConfiguration screenConfiguration)
|
||||
{
|
||||
d->screenConfiguration = screenConfiguration;
|
||||
static std::once_flag deprecationFlag;
|
||||
std::call_once(deprecationFlag, []() {
|
||||
qWarning() << "LayerShellQt.Window.screenConfiguration is deprecated use screen and wantsToBeOnActiveScreen instead";
|
||||
});
|
||||
|
||||
if (screenConfiguration == ScreenFromCompositor) {
|
||||
setWantsToBeOnActiveScreen(true);
|
||||
} else {
|
||||
setWantsToBeOnActiveScreen(false);
|
||||
setScreen(nullptr);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void Window::setWantsToBeOnActiveScreen(bool set)
|
||||
{
|
||||
if (d->wantsToBeOnActiveScreen == set) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->wantsToBeOnActiveScreen = set;
|
||||
|
||||
if (d->wantsToBeOnActiveScreen && d->screen) {
|
||||
d->screen = nullptr;
|
||||
Q_EMIT screenChanged();
|
||||
}
|
||||
|
||||
Q_EMIT wantsToBeOnActiveScreenChanged();
|
||||
}
|
||||
|
||||
bool Window::wantsToBeOnActiveScreen() const
|
||||
{
|
||||
return d->wantsToBeOnActiveScreen;
|
||||
}
|
||||
|
||||
void Window::setScreen(QScreen *screen)
|
||||
{
|
||||
if (d->screen == screen) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->screen = screen;
|
||||
|
||||
if (d->screen && d->wantsToBeOnActiveScreen) {
|
||||
d->wantsToBeOnActiveScreen = false;
|
||||
Q_EMIT wantsToBeOnActiveScreenChanged();
|
||||
}
|
||||
|
||||
Q_EMIT screenChanged();
|
||||
}
|
||||
|
||||
QScreen *Window::screen() const
|
||||
{
|
||||
return d->screen;
|
||||
}
|
||||
|
||||
bool Window::closeOnDismissed() const
|
||||
|
||||
@ -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
|
||||
@ -55,8 +27,12 @@ class LAYERSHELLQT_EXPORT Window : public QObject
|
||||
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)
|
||||
Q_PROPERTY(bool activateOnShow READ activateOnShow WRITE setActivateOnShow)
|
||||
Q_PROPERTY(bool wantsToBeOnActiveScreen READ wantsToBeOnActiveScreen WRITE setWantsToBeOnActiveScreen NOTIFY wantsToBeOnActiveScreenChanged)
|
||||
Q_PROPERTY(QScreen *screen READ screen WRITE setScreen NOTIFY screenChanged)
|
||||
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
|
||||
Q_PROPERTY(ScreenConfiguration screenConfiguration READ screenConfiguration WRITE setScreenConfiguration)
|
||||
#endif
|
||||
|
||||
public:
|
||||
~Window() override;
|
||||
@ -92,17 +68,6 @@ 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;
|
||||
|
||||
@ -115,18 +80,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;
|
||||
|
||||
@ -136,8 +89,48 @@ public:
|
||||
void setLayer(Layer layer);
|
||||
Layer layer() const;
|
||||
|
||||
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Use wantsToBeOnActiveScreen and screen instead")
|
||||
enum ScreenConfiguration {
|
||||
ScreenFromQWindow = 0,
|
||||
ScreenFromCompositor = 1,
|
||||
};
|
||||
Q_ENUM(ScreenConfiguration)
|
||||
|
||||
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Use wantsToBeOnActiveScreen and screen instead")
|
||||
void setScreenConfiguration(ScreenConfiguration screenConfiguration);
|
||||
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Use wantsToBeOnActiveScreen and screen instead")
|
||||
ScreenConfiguration screenConfiguration() const;
|
||||
#endif
|
||||
|
||||
/**
|
||||
* Indicates whether the layer shell surface should be placed on the active screen based on @a set.
|
||||
*
|
||||
* The active screen depends on the compositor policies.
|
||||
*
|
||||
* If the screen() is @c null and the wantsToBeOnActiveScreen() is @c false, then the
|
||||
* QWindow::screen() will be used to decide what screen the layer shell surface should be placed on.
|
||||
*
|
||||
* The screen() will be reset if @a set is @c true.
|
||||
*/
|
||||
void setWantsToBeOnActiveScreen(bool set);
|
||||
bool wantsToBeOnActiveScreen() const;
|
||||
|
||||
/**
|
||||
* Indicates that the layer shell surface should be placed on the specified @a screen.
|
||||
*
|
||||
* If the screen() is @c null and the wantsToBeOnActiveScreen() is @c false, then the
|
||||
* QWindow::screen() will be used to decide what screen the layer shell surface should be placed on.
|
||||
*
|
||||
* The wantsToBeOnActiveScreen() will be reset to @c false after calling this function.
|
||||
*/
|
||||
void setScreen(QScreen *screen);
|
||||
QScreen *screen() const;
|
||||
|
||||
/**
|
||||
* Sets a string based identifier for this window.
|
||||
@ -185,13 +178,11 @@ Q_SIGNALS:
|
||||
void exclusionZoneChanged();
|
||||
void exclusiveEdgeChanged();
|
||||
void marginsChanged();
|
||||
void leftMarginChanged();
|
||||
void topMarginChanged();
|
||||
void rightMarginChanged();
|
||||
void bottomMarginChanged();
|
||||
void desiredSizeChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
void wantsToBeOnActiveScreenChanged();
|
||||
void screenChanged();
|
||||
|
||||
private:
|
||||
void initializeShell();
|
||||
|
||||
@ -15,7 +15,7 @@
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
|
||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(6)
|
||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(5)
|
||||
, m_xdgActivation(new QWaylandXdgActivationV1)
|
||||
{
|
||||
}
|
||||
|
||||
@ -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>
|
||||
@ -26,8 +27,13 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
, m_window(window)
|
||||
{
|
||||
wl_output *output = nullptr;
|
||||
if (m_interface->screenConfiguration() == Window::ScreenFromQWindow) {
|
||||
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(window->window()->screen()->handle());
|
||||
if (!m_interface->wantsToBeOnActiveScreen()) {
|
||||
QScreen *desiredScreen = m_interface->screen();
|
||||
if (!desiredScreen) {
|
||||
desiredScreen = window->window()->screen();
|
||||
}
|
||||
|
||||
auto waylandScreen = dynamic_cast<QtWaylandClient::QWaylandScreen *>(desiredScreen->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) {
|
||||
@ -60,24 +66,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 +165,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 +206,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());
|
||||
});
|
||||
|
||||
@ -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);
|
||||
|
||||
|
||||
@ -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>
|
||||
|
||||
Reference in New Issue
Block a user