mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-07-14 11:04:20 -04:00
Compare commits
1 Commits
v6.0.4
...
work/zzag/
Author | SHA1 | Date | |
---|---|---|---|
4cc1b9cbaa |
@ -2,8 +2,6 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
include:
|
||||
- project: sysadmin/ci-utilities
|
||||
file:
|
||||
- /gitlab-templates/reuse-lint.yml
|
||||
- /gitlab-templates/linux-qt6.yml
|
||||
- /gitlab-templates/freebsd-qt6.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/reuse-lint.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/linux-qt6.yml
|
||||
- https://invent.kde.org/sysadmin/ci-utilities/raw/master/gitlab-templates/freebsd-qt6.yml
|
||||
|
@ -4,13 +4,13 @@
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
|
||||
project(layershellqt)
|
||||
set(PROJECT_VERSION "6.0.4")
|
||||
set(PROJECT_VERSION_MAJOR 6)
|
||||
set(PROJECT_VERSION "5.27.80")
|
||||
set(PROJECT_VERSION_MAJOR 5)
|
||||
|
||||
set(CMAKE_C_STANDARD 99)
|
||||
|
||||
set(QT_MIN_VERSION "6.6.0")
|
||||
set(KF6_MIN_VERSION "6.0.0")
|
||||
set(QT_MIN_VERSION "6.5.0")
|
||||
set(KF6_MIN_VERSION "5.240.0")
|
||||
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
@ -30,7 +30,6 @@ include(FeatureSummary)
|
||||
include(GenerateExportHeader)
|
||||
include(KDEClangFormat)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMQmlModule)
|
||||
|
||||
|
||||
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
|
||||
@ -48,7 +47,7 @@ set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu90")
|
||||
ecm_setup_version(${PROJECT_VERSION} VARIABLE_PREFIX LAYERSHELLQT
|
||||
VERSION_HEADER "${CMAKE_CURRENT_BINARY_DIR}/layershellqt_version.h"
|
||||
PACKAGE_VERSION_FILE "${CMAKE_CURRENT_BINARY_DIR}/LayerShellQtConfigVersion.cmake"
|
||||
SOVERSION ${PROJECT_VERSION_MAJOR})
|
||||
SOVERSION 5)
|
||||
|
||||
file(GLOB_RECURSE ALL_CLANG_FORMAT_SOURCE_FILES *.cpp *.h)
|
||||
kde_clang_format(${ALL_CLANG_FORMAT_SOURCE_FILES})
|
||||
|
@ -6,11 +6,10 @@ 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
|
||||
)
|
||||
|
||||
ecm_qt_declare_logging_category(LayerShellQtInterface
|
||||
ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES
|
||||
HEADER
|
||||
layershellqt_logging.h
|
||||
IDENTIFIER
|
||||
@ -19,14 +18,7 @@ ecm_qt_declare_logging_category(LayerShellQtInterface
|
||||
layershellqt
|
||||
)
|
||||
|
||||
target_sources(LayerShellQtInterface PRIVATE
|
||||
qwaylandxdgactivationv1.cpp
|
||||
qwaylandlayersurface.cpp
|
||||
qwaylandlayershellintegration.cpp
|
||||
interfaces/window.cpp
|
||||
interfaces/shell.cpp
|
||||
)
|
||||
|
||||
target_sources(LayerShellQtInterface PRIVATE qwaylandlayersurface.cpp interfaces/window.cpp interfaces/shell.cpp qwaylandlayershellintegration.cpp ${LAYER_SHELL_SOURCES})
|
||||
target_link_libraries(LayerShellQtInterface PUBLIC Qt::Gui)
|
||||
target_link_libraries(LayerShellQtInterface PRIVATE Qt::WaylandClientPrivate Wayland::Client PkgConfig::XKBCOMMON)
|
||||
if (TARGET Qt::XkbCommonSupportPrivate)
|
||||
|
@ -1,10 +1,9 @@
|
||||
# SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleix.pol_gonzalez@mercedes-benz.com>
|
||||
# SPDX-License-Identifier: BSD-3-Clause
|
||||
|
||||
ecm_add_qml_module(LayerShellQtQml
|
||||
qt_add_qml_module(LayerShellQtQml
|
||||
URI "org.kde.layershell"
|
||||
VERSION 1.0
|
||||
SOURCES layershellqtplugin.cpp)
|
||||
target_link_libraries(LayerShellQtQml PRIVATE Qt::Qml LayerShellQtInterface)
|
||||
|
||||
ecm_finalize_qml_module(LayerShellQtQml DESTINATION ${KDE_INSTALL_QMLDIR})
|
@ -6,6 +6,9 @@
|
||||
|
||||
#include "window.h"
|
||||
#include "../qwaylandlayershellintegration_p.h"
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||
#include "../qwaylandlayersurface_p.h"
|
||||
#endif
|
||||
|
||||
#include <layershellqt_logging.h>
|
||||
|
||||
@ -26,10 +29,10 @@ public:
|
||||
|
||||
QWindow *parentWindow;
|
||||
QString scope = QStringLiteral("window");
|
||||
QSize desiredSize = QSize(0, 0);
|
||||
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::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityNone;
|
||||
Window::Layer layer = Window::LayerTop;
|
||||
QMargins margins;
|
||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
||||
@ -69,21 +72,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) {
|
||||
@ -154,6 +142,34 @@ void Window::setCloseOnDismissed(bool close)
|
||||
d->closeOnDismissed = close;
|
||||
}
|
||||
|
||||
void Window::setDesiredSize(const QSize &size)
|
||||
{
|
||||
if (d->desiredSize != size) {
|
||||
d->desiredSize = size;
|
||||
Q_EMIT desiredSizeChanged();
|
||||
}
|
||||
}
|
||||
|
||||
QSize Window::desiredSize() const
|
||||
{
|
||||
return d->desiredSize;
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||
void Window::attachPopup(QWindow *window, xdg_popup *popup)
|
||||
{
|
||||
auto waylandWindow = dynamic_cast<QtWaylandClient::QWaylandWindow *>(window->handle());
|
||||
if (!waylandWindow) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto shellSurface = dynamic_cast<QWaylandLayerSurface *>(waylandWindow->shellSurface());
|
||||
if (shellSurface) {
|
||||
shellSurface->get_popup(popup);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
Window::Window(QWindow *window)
|
||||
: QObject(window)
|
||||
, d(new WindowPrivate(window))
|
||||
|
@ -14,6 +14,10 @@
|
||||
|
||||
#include "layershellqt_export.h"
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||
struct xdg_popup;
|
||||
#endif
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
class WindowPrivate;
|
||||
@ -33,7 +37,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 +83,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;
|
||||
|
||||
@ -114,21 +114,32 @@ public:
|
||||
void setCloseOnDismissed(bool close);
|
||||
bool closeOnDismissed() const;
|
||||
|
||||
/**
|
||||
* Sets the desired window size. This size indicates how much space the compositor is going
|
||||
* to reserve for the window.
|
||||
*/
|
||||
void setDesiredSize(const QSize &size);
|
||||
QSize desiredSize() const;
|
||||
|
||||
/**
|
||||
* Gets the LayerShell Window for a given Qt Window
|
||||
* Ownership is not transferred
|
||||
*/
|
||||
static Window *get(QWindow *window);
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 6, 0)
|
||||
static void attachPopup(QWindow *window, xdg_popup *popup);
|
||||
#endif
|
||||
|
||||
static Window *qmlAttachedProperties(QObject *object);
|
||||
|
||||
Q_SIGNALS:
|
||||
void anchorsChanged();
|
||||
void exclusionZoneChanged();
|
||||
void exclusiveEdgeChanged();
|
||||
void marginsChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
void desiredSizeChanged();
|
||||
|
||||
private:
|
||||
Window(QWindow *window);
|
||||
|
@ -7,7 +7,6 @@
|
||||
|
||||
#include "qwaylandlayershellintegration_p.h"
|
||||
#include "qwaylandlayersurface_p.h"
|
||||
#include "qwaylandxdgactivationv1_p.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
@ -15,8 +14,7 @@
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
|
||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(5)
|
||||
, m_xdgActivation(new QWaylandXdgActivationV1)
|
||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(4)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,6 @@
|
||||
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
|
||||
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
||||
|
||||
class QWaylandXdgActivationV1;
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
|
||||
@ -24,10 +22,7 @@ public:
|
||||
QWaylandLayerShellIntegration();
|
||||
~QWaylandLayerShellIntegration() override;
|
||||
|
||||
QWaylandXdgActivationV1 *activation() const { return m_xdgActivation.data(); }
|
||||
QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
|
||||
private:
|
||||
QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -8,22 +8,17 @@
|
||||
#include "interfaces/window.h"
|
||||
#include "layershellqt_logging.h"
|
||||
#include "qwaylandlayersurface_p.h"
|
||||
#include "qwaylandxdgactivationv1_p.h"
|
||||
|
||||
#include <QtWaylandClient/private/qwaylandscreen_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandsurface_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||
|
||||
#include <QGuiApplication>
|
||||
|
||||
namespace LayerShellQt
|
||||
{
|
||||
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window)
|
||||
QWaylandLayerSurface::QWaylandLayerSurface(QtWayland::zwlr_layer_shell_v1 *shell, QtWaylandClient::QWaylandWindow *window)
|
||||
: QtWaylandClient::QWaylandShellSurface(window)
|
||||
, 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) {
|
||||
@ -41,20 +36,14 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setLayer(m_interface->layer());
|
||||
});
|
||||
|
||||
setAnchor(m_interface->anchors());
|
||||
set_anchor(m_interface->anchors());
|
||||
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
||||
setAnchor(m_interface->anchors());
|
||||
setDesiredSize(m_window->windowContentGeometry().size());
|
||||
set_anchor(m_interface->anchors());
|
||||
});
|
||||
|
||||
setExclusiveZone(m_interface->exclusionZone());
|
||||
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]() {
|
||||
@ -66,14 +55,14 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
});
|
||||
|
||||
setDesiredSize(window->windowContentGeometry().size());
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
connect(m_interface, &Window::desiredSizeChanged, this, [this]() {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
});
|
||||
}
|
||||
|
||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||
{
|
||||
if (m_waitForSyncCallback) {
|
||||
wl_callback_destroy(m_waitForSyncCallback);
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -91,8 +80,8 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
||||
|
||||
if (!m_configured) {
|
||||
m_configured = true;
|
||||
applyConfigure();
|
||||
sendExpose();
|
||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||
window()->handleExpose(QRect(QPoint(), 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.
|
||||
@ -100,6 +89,7 @@ void QWaylandLayerSurface::zwlr_layer_surface_v1_configure(uint32_t serial, uint
|
||||
}
|
||||
}
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *popup)
|
||||
{
|
||||
std::any anyRole = popup->surfaceRole();
|
||||
@ -110,27 +100,11 @@ void QWaylandLayerSurface::attachPopup(QtWaylandClient::QWaylandShellSurface *po
|
||||
qCWarning(LAYERSHELLQT) << "Cannot attach popup of unknown type";
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void QWaylandLayerSurface::applyConfigure()
|
||||
{
|
||||
m_configuring = true;
|
||||
window()->resizeFromApplyConfigure(m_pendingSize);
|
||||
m_configuring = false;
|
||||
}
|
||||
|
||||
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)
|
||||
@ -143,13 +117,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());
|
||||
@ -162,104 +129,14 @@ void QWaylandLayerSurface::setKeyboardInteractivity(uint32_t interactivity)
|
||||
|
||||
void QWaylandLayerSurface::setLayer(uint32_t layer)
|
||||
{
|
||||
qDebug() << "wtfffffff" << layer << zwlr_layer_surface_v1_get_version(object()) << ZWLR_LAYER_SURFACE_V1_SET_LAYER_SINCE_VERSION;
|
||||
if (zwlr_layer_surface_v1_get_version(object()) >= ZWLR_LAYER_SURFACE_V1_SET_LAYER_SINCE_VERSION)
|
||||
set_layer(layer);
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
void QWaylandLayerSurface::setDesiredSize(const QSize &size)
|
||||
{
|
||||
if (m_configuring) {
|
||||
return;
|
||||
}
|
||||
|
||||
setDesiredSize(geometry.size());
|
||||
requestWaylandSync();
|
||||
}
|
||||
|
||||
bool QWaylandLayerSurface::requestActivate()
|
||||
{
|
||||
QWaylandXdgActivationV1 *activation = m_shell->activation();
|
||||
if (!activation->isActive()) {
|
||||
return false;
|
||||
}
|
||||
if (!m_activationToken.isEmpty()) {
|
||||
activation->activate(m_activationToken, window()->wlSurface());
|
||||
m_activationToken = {};
|
||||
return true;
|
||||
} else {
|
||||
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());
|
||||
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;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setXdgActivationToken(const QString &token)
|
||||
{
|
||||
m_activationToken = token;
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::requestXdgActivationToken(quint32 serial)
|
||||
{
|
||||
QWaylandXdgActivationV1 *activation = m_shell->activation();
|
||||
if (!activation->isActive()) {
|
||||
return;
|
||||
}
|
||||
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, 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
|
||||
set_size(size.width(), size.height());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
#include <wayland-client.h>
|
||||
|
||||
#include "qwaylandlayershellintegration_p.h"
|
||||
|
||||
#include "layershellqt_export.h"
|
||||
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
|
||||
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
||||
@ -25,48 +23,33 @@ class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylan
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window);
|
||||
QWaylandLayerSurface(QtWayland::zwlr_layer_shell_v1 *shell, QtWaylandClient::QWaylandWindow *window);
|
||||
~QWaylandLayerSurface() override;
|
||||
|
||||
bool isExposed() const override
|
||||
{
|
||||
return m_configured && !m_waitForSyncCallback;
|
||||
return m_configured;
|
||||
}
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6, 6, 0)
|
||||
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
||||
#endif
|
||||
|
||||
void setDesiredSize(const QSize &size);
|
||||
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);
|
||||
void setDesiredSize(const QSize &size);
|
||||
|
||||
void applyConfigure() override;
|
||||
void setWindowGeometry(const QRect &geometry) override;
|
||||
|
||||
bool requestActivate() override;
|
||||
void setXdgActivationToken(const QString &token) override;
|
||||
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;
|
||||
bool m_configuring = false;
|
||||
|
||||
static const wl_callback_listener syncCallbackListener;
|
||||
struct wl_callback *m_waitForSyncCallback = nullptr;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -1,44 +0,0 @@
|
||||
/** Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#include "qwaylandxdgactivationv1_p.h"
|
||||
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||
#include <QtWaylandClient/private/qwaylandinputdevice_p.h>
|
||||
|
||||
QWaylandXdgActivationV1::QWaylandXdgActivationV1()
|
||||
: QWaylandClientExtensionTemplate<QWaylandXdgActivationV1>(1)
|
||||
{
|
||||
initialize();
|
||||
}
|
||||
|
||||
QWaylandXdgActivationV1::~QWaylandXdgActivationV1()
|
||||
{
|
||||
if (isActive()) {
|
||||
destroy();
|
||||
}
|
||||
}
|
||||
|
||||
QWaylandXdgActivationTokenV1 *QWaylandXdgActivationV1::requestXdgActivationToken(QtWaylandClient::QWaylandDisplay *display,
|
||||
struct ::wl_surface *surface,
|
||||
std::optional<uint32_t> serial,
|
||||
const QString &app_id)
|
||||
{
|
||||
auto wl = get_activation_token();
|
||||
auto provider = new QWaylandXdgActivationTokenV1;
|
||||
provider->init(wl);
|
||||
|
||||
if (surface) {
|
||||
provider->set_surface(surface);
|
||||
}
|
||||
if (!app_id.isEmpty()) {
|
||||
provider->set_app_id(app_id);
|
||||
}
|
||||
if (serial && display->lastInputDevice()) {
|
||||
provider->set_serial(*serial, display->lastInputDevice()->wl_seat());
|
||||
}
|
||||
provider->commit();
|
||||
return provider;
|
||||
}
|
||||
|
||||
#include "moc_qwaylandxdgactivationv1_p.cpp"
|
@ -1,48 +0,0 @@
|
||||
/** Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||
* SPDX-License-Identifier: LGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
#ifndef QWAYLANDXDGACTIVATIONV1_P_H
|
||||
#define QWAYLANDXDGACTIVATIONV1_P_H
|
||||
|
||||
#include "qwayland-xdg-activation-v1.h"
|
||||
#include <QObject>
|
||||
|
||||
#include <QtWaylandClient/QWaylandClientExtension>
|
||||
|
||||
namespace QtWaylandClient
|
||||
{
|
||||
class QWaylandDisplay;
|
||||
class QWaylandSurface;
|
||||
}
|
||||
|
||||
class QWaylandXdgActivationTokenV1 : public QObject, public QtWayland::xdg_activation_token_v1
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
~QWaylandXdgActivationTokenV1() override
|
||||
{
|
||||
destroy();
|
||||
}
|
||||
|
||||
protected:
|
||||
void xdg_activation_token_v1_done(const QString &token) override
|
||||
{
|
||||
Q_EMIT done(token);
|
||||
}
|
||||
|
||||
Q_SIGNALS:
|
||||
void done(const QString &token);
|
||||
};
|
||||
|
||||
class QWaylandXdgActivationV1 : public QWaylandClientExtensionTemplate<QWaylandXdgActivationV1>, public QtWayland::xdg_activation_v1
|
||||
{
|
||||
public:
|
||||
QWaylandXdgActivationV1();
|
||||
~QWaylandXdgActivationV1() override;
|
||||
|
||||
QWaylandXdgActivationTokenV1 *
|
||||
requestXdgActivationToken(QtWaylandClient::QWaylandDisplay *display, struct ::wl_surface *surface, std::optional<uint32_t> serial, const QString &app_id);
|
||||
};
|
||||
|
||||
#endif // QWAYLANDXDGACTIVATIONV1_P_H
|
@ -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>
|
||||
|
@ -32,7 +32,7 @@ template<typename T>
|
||||
T stringToEnum(QMetaEnum metaEnum, const QString &str)
|
||||
{
|
||||
T ret = {};
|
||||
const auto splitted = str.split(QLatin1Char('|'), Qt::SkipEmptyParts);
|
||||
const auto splitted = str.split(QLatin1Char('|'));
|
||||
for (const auto &value : splitted) {
|
||||
ret |= T(metaEnum.keyToValue(qPrintable(value)));
|
||||
}
|
||||
|
Reference in New Issue
Block a user