mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-07-14 19:14:23 -04:00
Compare commits
2 Commits
v6.0.2
...
work/fuf/q
Author | SHA1 | Date | |
---|---|---|---|
b8a9938c0d | |||
f1e50306f8 |
@ -4,13 +4,13 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(layershellqt)
|
||||
set(PROJECT_VERSION "6.0.2")
|
||||
set(PROJECT_VERSION "6.0.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(KF6_MIN_VERSION "5.240.0")
|
||||
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
|
@ -28,7 +28,6 @@ public:
|
||||
QString scope = QStringLiteral("window");
|
||||
Window::Anchors anchors = {Window::AnchorTop | Window::AnchorBottom | Window::AnchorLeft | Window::AnchorRight};
|
||||
int32_t exclusionZone = 0;
|
||||
Window::Anchor exclusiveEdge = Window::AnchorNone;
|
||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
|
||||
Window::Layer layer = Window::LayerTop;
|
||||
QMargins margins;
|
||||
@ -69,21 +68,6 @@ 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) {
|
||||
|
@ -33,7 +33,6 @@ 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
|
||||
@ -80,9 +79,6 @@ public:
|
||||
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;
|
||||
|
||||
@ -125,7 +121,6 @@ public:
|
||||
Q_SIGNALS:
|
||||
void anchorsChanged();
|
||||
void exclusionZoneChanged();
|
||||
void exclusiveEdgeChanged();
|
||||
void marginsChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
|
@ -15,7 +15,7 @@
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
|
||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(5)
|
||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(4)
|
||||
, m_xdgActivation(new QWaylandXdgActivationV1)
|
||||
{
|
||||
}
|
||||
|
@ -16,6 +16,31 @@
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
namespace
|
||||
{
|
||||
template<typename T>
|
||||
concept QWaylandWindowNewV6Type = requires(T t) { t.sendRecursiveExposeEvent(); };
|
||||
|
||||
template<typename T>
|
||||
concept QWaylandWindowOldV6Type = requires(T t) { t.handleExpose(QRect()); } && !requires(T t) { t.sendRecursiveExposeEvent(); };
|
||||
|
||||
class ExposeHelper
|
||||
{
|
||||
public:
|
||||
template<QWaylandWindowOldV6Type T>
|
||||
[[maybe_unused]] ExposeHelper(T *window, const QSize &pendingSize)
|
||||
{
|
||||
window->handleExpose(QRect(QPoint(), pendingSize));
|
||||
}
|
||||
|
||||
template<QWaylandWindowNewV6Type T>
|
||||
[[maybe_unused]] ExposeHelper(T *window, [[maybe_unused]] const QSize &pendingSize)
|
||||
{
|
||||
window->sendRecursiveExposeEvent();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window)
|
||||
@ -23,7 +48,6 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
, QtWayland::zwlr_layer_surface_v1()
|
||||
, m_shell(shell)
|
||||
, m_interface(Window::get(window->window()))
|
||||
, m_window(window)
|
||||
{
|
||||
wl_output *output = nullptr;
|
||||
if (m_interface->screenConfiguration() == Window::ScreenFromQWindow) {
|
||||
@ -49,10 +73,6 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
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());
|
||||
});
|
||||
|
||||
setMargins(m_interface->margins());
|
||||
connect(m_interface, &Window::marginsChanged, this, [this]() {
|
||||
@ -79,9 +99,6 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
|
||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||
{
|
||||
if (m_waitForSyncCallback) {
|
||||
wl_callback_destroy(m_waitForSyncCallback);
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -100,7 +117,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
||||
if (!m_configured) {
|
||||
m_configured = true;
|
||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||
sendExpose();
|
||||
ExposeHelper helper(window(), m_pendingSize);
|
||||
} else {
|
||||
// Later configures are resizes, so we have to queue them up for a time when we
|
||||
// are not painting to the window.
|
||||
@ -135,13 +152,6 @@ 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());
|
||||
@ -160,11 +170,6 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
||||
|
||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
{
|
||||
// if we are setting it to the last size we were configured at, we don't need to do anything
|
||||
if (geometry.size() == m_pendingSize && !m_waitForSyncCallback) {
|
||||
return;
|
||||
}
|
||||
|
||||
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
||||
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
|
||||
|
||||
@ -176,7 +181,6 @@ void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
size.setHeight(0);
|
||||
}
|
||||
set_size(size.width(), size.height());
|
||||
requestWaylandSync();
|
||||
}
|
||||
|
||||
bool QWaylandLayerSurface::requestActivate()
|
||||
@ -225,43 +229,7 @@ void QWaylandLayerSurface::requestXdgActivationToken(quint32 serial)
|
||||
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
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,13 +30,12 @@ public:
|
||||
|
||||
bool isExposed() const override
|
||||
{
|
||||
return m_configured && !m_waitForSyncCallback;
|
||||
return m_configured;
|
||||
}
|
||||
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
||||
|
||||
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);
|
||||
@ -49,22 +48,14 @@ public:
|
||||
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;
|
||||
|
||||
static const wl_callback_listener syncCallbackListener;
|
||||
struct wl_callback *m_waitForSyncCallback = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -25,7 +25,7 @@
|
||||
THIS SOFTWARE.
|
||||
</copyright>
|
||||
|
||||
<interface name="zwlr_layer_shell_v1" version="5">
|
||||
<interface name="zwlr_layer_shell_v1" version="4">
|
||||
<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="5">
|
||||
<interface name="zwlr_layer_surface_v1" version="4">
|
||||
<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,7 +367,6 @@
|
||||
<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">
|
||||
@ -387,21 +386,5 @@
|
||||
</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>
|
||||
|
Reference in New Issue
Block a user