mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2026-02-03 12:20:08 -05:00
Compare commits
9 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 94ac4be08f | |||
| df03deab5c | |||
| 44fe89b1b6 | |||
| 58f549d136 | |||
| 9ddf87a444 | |||
| b9e1260949 | |||
| cb79d3f60a | |||
| 2b8544f5a0 | |||
| e4b5bdbf1b |
@ -4,13 +4,13 @@
|
|||||||
cmake_minimum_required(VERSION 3.16)
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
|
||||||
project(layershellqt)
|
project(layershellqt)
|
||||||
set(PROJECT_VERSION "6.4.90")
|
set(PROJECT_VERSION "6.5.90")
|
||||||
set(PROJECT_VERSION_MAJOR 6)
|
set(PROJECT_VERSION_MAJOR 6)
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 99)
|
||||||
|
|
||||||
set(QT_MIN_VERSION "6.9.0")
|
set(QT_MIN_VERSION "6.10.0")
|
||||||
set(KF6_MIN_VERSION "6.18.0")
|
set(KF6_MIN_VERSION "6.22.0")
|
||||||
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 20)
|
set(CMAKE_CXX_STANDARD 20)
|
||||||
@ -32,6 +32,7 @@ include(KDEClangFormat)
|
|||||||
include(ECMQtDeclareLoggingCategory)
|
include(ECMQtDeclareLoggingCategory)
|
||||||
include(ECMQmlModule)
|
include(ECMQmlModule)
|
||||||
include(KDEGitCommitHooks)
|
include(KDEGitCommitHooks)
|
||||||
|
include(ECMGenerateExportHeader)
|
||||||
|
|
||||||
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
|
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
|
BASE_NAME LayerShellQtInterface
|
||||||
EXPORT_MACRO_NAME LAYERSHELLQT_EXPORT
|
EXPORT_MACRO_NAME LAYERSHELLQT_EXPORT
|
||||||
EXPORT_FILE_NAME LayerShellQt/layershellqt_export.h
|
EXPORT_FILE_NAME LayerShellQt/layershellqt_export.h
|
||||||
|
VERSION ${LAYERSHELLQT_VERSION}
|
||||||
|
DEPRECATION_VERSIONS 6.6
|
||||||
)
|
)
|
||||||
|
|
||||||
install(TARGETS layer-shell
|
install(TARGETS layer-shell
|
||||||
|
|||||||
@ -4,7 +4,7 @@
|
|||||||
ecm_add_qml_module(LayerShellQtQml
|
ecm_add_qml_module(LayerShellQtQml
|
||||||
URI "org.kde.layershell"
|
URI "org.kde.layershell"
|
||||||
VERSION 1.0
|
VERSION 1.0
|
||||||
SOURCES types.h types.cpp
|
SOURCES types.h
|
||||||
GENERATE_PLUGIN_SOURCE)
|
GENERATE_PLUGIN_SOURCE)
|
||||||
target_link_libraries(LayerShellQtQml PRIVATE Qt::Qml LayerShellQtInterface)
|
target_link_libraries(LayerShellQtQml PRIVATE Qt::Qml LayerShellQtInterface)
|
||||||
|
|
||||||
|
|||||||
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* SPDX-FileCopyrightText: 2023 Aleix Pol Gonzalez <aleix.pol_gonzalez@mercedes-benz.com>
|
|
||||||
*
|
|
||||||
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "types.h"
|
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 1)
|
|
||||||
int QQmlMarginsValueType::left() const
|
|
||||||
{
|
|
||||||
return m.left();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QQmlMarginsValueType::top() const
|
|
||||||
{
|
|
||||||
return m.top();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QQmlMarginsValueType::right() const
|
|
||||||
{
|
|
||||||
return m.right();
|
|
||||||
}
|
|
||||||
|
|
||||||
int QQmlMarginsValueType::bottom() const
|
|
||||||
{
|
|
||||||
return m.bottom();
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQmlMarginsValueType::setLeft(int left)
|
|
||||||
{
|
|
||||||
m.setLeft(left);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQmlMarginsValueType::setTop(int top)
|
|
||||||
{
|
|
||||||
m.setTop(top);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQmlMarginsValueType::setRight(int right)
|
|
||||||
{
|
|
||||||
m.setRight(right);
|
|
||||||
}
|
|
||||||
|
|
||||||
void QQmlMarginsValueType::setBottom(int bottom)
|
|
||||||
{
|
|
||||||
m.setBottom(bottom);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
@ -17,39 +17,3 @@ class WindowForeign
|
|||||||
QML_UNCREATABLE("")
|
QML_UNCREATABLE("")
|
||||||
QML_ATTACHED(LayerShellQt::Window)
|
QML_ATTACHED(LayerShellQt::Window)
|
||||||
};
|
};
|
||||||
|
|
||||||
// available upstream since https://invent.kde.org/qt/qt/qtdeclarative/-/commit/a398101f715bfc447aa889fc9c58b13bfe75ab47
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 8, 1)
|
|
||||||
struct Q_QML_EXPORT QQmlMarginsValueType {
|
|
||||||
QMargins m;
|
|
||||||
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)
|
|
||||||
Q_GADGET
|
|
||||||
QML_ANONYMOUS
|
|
||||||
QML_FOREIGN(QMargins)
|
|
||||||
QML_EXTENDED(QQmlMarginsValueType)
|
|
||||||
QML_STRUCTURED_VALUE
|
|
||||||
|
|
||||||
public:
|
|
||||||
QQmlMarginsValueType() = default;
|
|
||||||
Q_INVOKABLE QQmlMarginsValueType(const QMarginsF &margins)
|
|
||||||
: m(margins.toMargins())
|
|
||||||
{
|
|
||||||
}
|
|
||||||
int left() const;
|
|
||||||
int right() const;
|
|
||||||
int top() const;
|
|
||||||
int bottom() const;
|
|
||||||
void setLeft(int);
|
|
||||||
void setRight(int);
|
|
||||||
void setTop(int);
|
|
||||||
void setBottom(int);
|
|
||||||
|
|
||||||
operator QMargins() const
|
|
||||||
{
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
#endif
|
|
||||||
|
|||||||
@ -5,6 +5,9 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "shell.h"
|
#include "shell.h"
|
||||||
|
|
||||||
|
#if LAYERSHELLQTINTERFACE_BUILD_DEPRECATED_SINCE(6, 6)
|
||||||
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
#include <layershellqt_logging.h>
|
#include <layershellqt_logging.h>
|
||||||
#include <qglobal.h>
|
#include <qglobal.h>
|
||||||
@ -18,3 +21,4 @@ void Shell::useLayerShell()
|
|||||||
qCDebug(LAYERSHELLQT) << "Unable to set QT_WAYLAND_SHELL_INTEGRATION=layer-shell";
|
qCDebug(LAYERSHELLQT) << "Unable to set QT_WAYLAND_SHELL_INTEGRATION=layer-shell";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|||||||
@ -8,7 +8,9 @@
|
|||||||
#define LAYERSHELLQTSHELL_H
|
#define LAYERSHELLQTSHELL_H
|
||||||
|
|
||||||
#include "layershellqt_export.h"
|
#include "layershellqt_export.h"
|
||||||
#include "window.h"
|
|
||||||
|
#if LAYERSHELLQTINTERFACE_ENABLE_DEPRECATED_SINCE(6, 6)
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
|
||||||
namespace LayerShellQt
|
namespace LayerShellQt
|
||||||
@ -19,9 +21,11 @@ namespace LayerShellQt
|
|||||||
class LAYERSHELLQT_EXPORT Shell
|
class LAYERSHELLQT_EXPORT Shell
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
LAYERSHELLQTINTERFACE_DEPRECATED_VERSION(6, 6, "Calling useLayerShell is not needed since Qt 6.5")
|
||||||
static void useLayerShell();
|
static void useLayerShell();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -9,6 +9,7 @@
|
|||||||
|
|
||||||
#include <layershellqt_logging.h>
|
#include <layershellqt_logging.h>
|
||||||
|
|
||||||
|
#include <QPlatformSurfaceEvent>
|
||||||
#include <QPointer>
|
#include <QPointer>
|
||||||
#include <optional>
|
#include <optional>
|
||||||
|
|
||||||
@ -186,12 +187,35 @@ Window::Window(QWindow *window)
|
|||||||
, d(new WindowPrivate(window))
|
, d(new WindowPrivate(window))
|
||||||
{
|
{
|
||||||
s_map.insert(d->parentWindow, this);
|
s_map.insert(d->parentWindow, this);
|
||||||
|
window->installEventFilter(this);
|
||||||
|
if (window->isVisible()) {
|
||||||
|
qCWarning(LAYERSHELLQT) << d->parentWindow << "already has a shell integration. Call QWindow::close() first and show it again.";
|
||||||
|
}
|
||||||
|
|
||||||
window->create();
|
if (window->handle()) {
|
||||||
|
initializeShell();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
|
bool Window::eventFilter(QObject *watched, QEvent *event)
|
||||||
|
{
|
||||||
|
auto window = qobject_cast<QWindow *>(watched);
|
||||||
|
if (!window) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (event->type() == QEvent::PlatformSurface) {
|
||||||
|
if (auto pse = static_cast<QPlatformSurfaceEvent *>(event); pse->surfaceEventType() == QPlatformSurfaceEvent::SurfaceCreated) {
|
||||||
|
initializeShell();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Window::initializeShell()
|
||||||
|
{
|
||||||
|
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(d->parentWindow->handle());
|
||||||
if (!waylandWindow) {
|
if (!waylandWindow) {
|
||||||
qCWarning(LAYERSHELLQT) << window << "is not a wayland window. Not creating zwlr_layer_surface";
|
qCWarning(LAYERSHELLQT) << d->parentWindow << "is not a wayland window. Not creating zwlr_layer_surface";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -205,7 +229,6 @@ Window::Window(QWindow *window)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
waylandWindow->setShellIntegration(shellIntegration);
|
waylandWindow->setShellIntegration(shellIntegration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -138,6 +138,8 @@ public:
|
|||||||
|
|
||||||
static Window *qmlAttachedProperties(QObject *object);
|
static Window *qmlAttachedProperties(QObject *object);
|
||||||
|
|
||||||
|
bool eventFilter(QObject *watched, QEvent *event) override;
|
||||||
|
|
||||||
Q_SIGNALS:
|
Q_SIGNALS:
|
||||||
void anchorsChanged();
|
void anchorsChanged();
|
||||||
void exclusionZoneChanged();
|
void exclusionZoneChanged();
|
||||||
@ -148,6 +150,8 @@ Q_SIGNALS:
|
|||||||
void layerChanged();
|
void layerChanged();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
void initializeShell();
|
||||||
|
|
||||||
Window(QWindow *window);
|
Window(QWindow *window);
|
||||||
QScopedPointer<WindowPrivate> d;
|
QScopedPointer<WindowPrivate> d;
|
||||||
};
|
};
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#include "qwaylandlayersurface_p.h"
|
#include "qwaylandlayersurface_p.h"
|
||||||
#include "qwaylandxdgactivationv1_p.h"
|
#include "qwaylandxdgactivationv1_p.h"
|
||||||
|
|
||||||
|
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
|
||||||
#include <QtWaylandClient/private/qwaylandscreen_p.h>
|
#include <QtWaylandClient/private/qwaylandscreen_p.h>
|
||||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
||||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||||
@ -124,13 +125,7 @@ void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *po
|
|||||||
|
|
||||||
void QWaylandLayerSurface::applyConfigure()
|
void QWaylandLayerSurface::applyConfigure()
|
||||||
{
|
{
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
|
||||||
m_configuring = true;
|
|
||||||
#endif
|
|
||||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
|
||||||
m_configuring = false;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
||||||
@ -181,25 +176,12 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
|||||||
set_layer(layer);
|
set_layer(layer);
|
||||||
}
|
}
|
||||||
|
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
|
||||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
|
||||||
{
|
|
||||||
if (m_configuring) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (m_interface->desiredSize().isNull()) {
|
|
||||||
setDesiredSize(geometry.size());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#else
|
|
||||||
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
||||||
{
|
{
|
||||||
if (m_interface->desiredSize().isNull()) {
|
if (m_interface->desiredSize().isNull()) {
|
||||||
setDesiredSize(size);
|
setDesiredSize(size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
bool QWaylandLayerSurface::requestActivate()
|
bool QWaylandLayerSurface::requestActivate()
|
||||||
{
|
{
|
||||||
@ -219,7 +201,7 @@ bool QWaylandLayerSurface::requestActivate()
|
|||||||
const auto focusWindow = QGuiApplication::focusWindow();
|
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()) {
|
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) {
|
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this, [this](const QString &token) {
|
||||||
m_shell->activation()->activate(token, window()->wlSurface());
|
m_shell->activation()->activate(token, window()->wlSurface());
|
||||||
});
|
});
|
||||||
@ -268,13 +250,6 @@ void QWaylandLayerSurface::requestXdgActivationToken(quint32 serial)
|
|||||||
|
|
||||||
void QWaylandLayerSurface::sendExpose()
|
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();
|
window()->updateExposure();
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -43,11 +43,7 @@ public:
|
|||||||
void setLayer(uint32_t layer);
|
void setLayer(uint32_t layer);
|
||||||
|
|
||||||
void applyConfigure() override;
|
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;
|
void setWindowSize(const QSize &size) override;
|
||||||
#endif
|
|
||||||
|
|
||||||
bool requestActivate() override;
|
bool requestActivate() override;
|
||||||
bool requestActivateOnShow() override;
|
bool requestActivateOnShow() override;
|
||||||
@ -66,9 +62,6 @@ private:
|
|||||||
QString m_activationToken;
|
QString m_activationToken;
|
||||||
|
|
||||||
bool m_configured = false;
|
bool m_configured = false;
|
||||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
|
||||||
bool m_configuring = false;
|
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
42
tests/become-layershell.qml
Normal file
42
tests/become-layershell.qml
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
/*
|
||||||
|
* SPDX-FileCopyrightText: 2025 Aleix Pol i Gonzalez <aleixpol@kde.org>
|
||||||
|
*
|
||||||
|
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||||
|
*/
|
||||||
|
|
||||||
|
import QtQuick
|
||||||
|
import QtQuick.Controls
|
||||||
|
import org.kde.layershell 1.0 as LayerShell
|
||||||
|
|
||||||
|
Item
|
||||||
|
{
|
||||||
|
Button {
|
||||||
|
text: "Convert"
|
||||||
|
anchors.centerIn: parent
|
||||||
|
|
||||||
|
onClicked: {
|
||||||
|
win.close()
|
||||||
|
win.LayerShell.Window.anchors = LayerShell.Window.AnchorLeft;
|
||||||
|
win.LayerShell.Window.layer = LayerShell.Window.LayerTop;
|
||||||
|
win.LayerShell.Window.exclusionZone = -1;
|
||||||
|
win.show()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Window {
|
||||||
|
id: win
|
||||||
|
|
||||||
|
width: 100
|
||||||
|
height: 100
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
color: "red"
|
||||||
|
|
||||||
|
Text {
|
||||||
|
anchors.centerIn: parent
|
||||||
|
text: "top"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
visible: true
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user