mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-07-14 02:54:31 -04:00
Compare commits
31 Commits
work/d_ed/
...
v6.3.3
Author | SHA1 | Date | |
---|---|---|---|
7ed94f9246 | |||
aa4cfaf37e | |||
d44f84a8da | |||
a0923de84d | |||
5dccaf1b84 | |||
c85d6e7baa | |||
e534206172 | |||
edb8f67b1b | |||
1796255496 | |||
2dbd1d6eb7 | |||
0d11058c8f | |||
a5fbaa5975 | |||
6f8a3f5d42 | |||
303f68cf10 | |||
368cf2dd37 | |||
16a1debdca | |||
c4987c01c7 | |||
bfdf40b1b5 | |||
8676cf98ce | |||
16da49d3a9 | |||
97d85c8722 | |||
44e011e2c6 | |||
05de6c67b2 | |||
7c4706c415 | |||
80a047c0db | |||
2ac46d8d9d | |||
e8594be884 | |||
0a31923938 | |||
127d817aa1 | |||
c407f9a8c4 | |||
17be1332cf |
@ -7,3 +7,6 @@ Dependencies:
|
||||
'frameworks/extra-cmake-modules': '@latest-kf6'
|
||||
'third-party/wayland': '@latest'
|
||||
'third-party/wayland-protocols': '@latest'
|
||||
|
||||
Options:
|
||||
require-passing-tests-on: ['Linux', 'FreeBSD', 'Windows']
|
||||
|
@ -4,13 +4,13 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(layershellqt)
|
||||
set(PROJECT_VERSION "6.0.80")
|
||||
set(PROJECT_VERSION "6.3.3")
|
||||
set(PROJECT_VERSION_MAJOR 6)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
set(QT_MIN_VERSION "6.6.0")
|
||||
set(KF6_MIN_VERSION "5.240.0")
|
||||
set(QT_MIN_VERSION "6.7.0")
|
||||
set(KF6_MIN_VERSION "6.10.0")
|
||||
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
@ -31,7 +31,7 @@ include(GenerateExportHeader)
|
||||
include(KDEClangFormat)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMQmlModule)
|
||||
|
||||
include(KDEGitCommitHooks)
|
||||
|
||||
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
|
||||
find_package(WaylandScanner REQUIRED)
|
||||
@ -53,8 +53,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)
|
||||
|
@ -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
|
||||
|
@ -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++"));
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -32,5 +32,4 @@ QtWaylandClient::QWaylandShellSurface *QWaylandLayerShellIntegration::createShel
|
||||
return new QWaylandLayerSurface(this, window);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -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;
|
||||
};
|
||||
|
@ -41,10 +41,12 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setLayer(m_interface->layer());
|
||||
});
|
||||
|
||||
set_anchor(m_interface->anchors());
|
||||
setAnchor(m_interface->anchors());
|
||||
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
||||
set_anchor(m_interface->anchors());
|
||||
setAnchor(m_interface->anchors());
|
||||
setDesiredSize(m_window->windowContentGeometry().size());
|
||||
});
|
||||
|
||||
setExclusiveZone(m_interface->exclusionZone());
|
||||
connect(m_interface, &Window::exclusionZoneChanged, this, [this]() {
|
||||
setExclusiveZone(m_interface->exclusionZone());
|
||||
@ -64,17 +66,7 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
});
|
||||
|
||||
QSize size = window->surfaceSize();
|
||||
const Window::Anchors anchors = m_interface->anchors();
|
||||
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());
|
||||
}
|
||||
setDesiredSize(window->windowContentGeometry().size());
|
||||
}
|
||||
|
||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||
@ -96,12 +88,8 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
||||
|
||||
if (!m_configured) {
|
||||
m_configured = true;
|
||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||
window()->handleExpose(QRect(QPoint(), m_pendingSize));
|
||||
#else
|
||||
window()->sendRecursiveExposeEvent();
|
||||
#endif
|
||||
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.
|
||||
@ -122,13 +110,33 @@ void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *po
|
||||
|
||||
void QWaylandLayerSurface::applyConfigure()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
m_configuring = true;
|
||||
#endif
|
||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
m_configuring = false;
|
||||
#endif
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
set_anchor(anchor);
|
||||
setWindowGeometry(window()->windowContentGeometry());
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setExclusiveZone(int32_t zone)
|
||||
@ -159,21 +167,21 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
||||
set_layer(layer);
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
{
|
||||
const bool horizontallyConstrained = m_interface->anchors().testFlags({Window::AnchorLeft, Window::AnchorRight});
|
||||
const bool verticallyConstrained = m_interface->anchors().testFlags({Window::AnchorTop, Window::AnchorBottom});
|
||||
if (m_configuring) {
|
||||
return;
|
||||
}
|
||||
|
||||
QSize size = geometry.size();
|
||||
if (horizontallyConstrained) {
|
||||
size.setWidth(0);
|
||||
}
|
||||
if (verticallyConstrained) {
|
||||
size.setHeight(0);
|
||||
}
|
||||
set_size(size.width(), size.height());
|
||||
wl_display_roundtrip(m_window->display()->wl_display());
|
||||
setDesiredSize(geometry.size());
|
||||
}
|
||||
#else
|
||||
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
||||
{
|
||||
setDesiredSize(size);
|
||||
}
|
||||
#endif
|
||||
|
||||
bool QWaylandLayerSurface::requestActivate()
|
||||
{
|
||||
@ -187,14 +195,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;
|
||||
}
|
||||
@ -213,16 +219,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);
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::sendExpose()
|
||||
{
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 7, 0)
|
||||
window()->handleExpose(QRect(QPoint(), m_pendingSize));
|
||||
#elif QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
window()->sendRecursiveExposeEvent();
|
||||
#else
|
||||
window()->updateExposure();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -34,6 +34,7 @@ public:
|
||||
}
|
||||
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);
|
||||
@ -42,13 +43,18 @@ 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 sendExpose();
|
||||
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
||||
void zwlr_layer_surface_v1_closed() override;
|
||||
|
||||
@ -57,7 +63,11 @@ private:
|
||||
QtWaylandClient::QWaylandWindow *m_window;
|
||||
QSize m_pendingSize;
|
||||
QString m_activationToken;
|
||||
|
||||
bool m_configured = false;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
bool m_configuring = false;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user