mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-11-23 02:02:43 -05:00
Compare commits
37 Commits
work/d_ed/
...
v6.4.90
| Author | SHA1 | Date | |
|---|---|---|---|
| ebd64dd395 | |||
| ca0ac57fb4 | |||
| d085a88c81 | |||
| 5e57a060c6 | |||
| d436a779d7 | |||
| f599e829ad | |||
| 397398dfd8 | |||
| 7a074a3684 | |||
| 8b54edb695 | |||
| ffa33fef9f | |||
| 3522070454 | |||
| 80d5e3c935 | |||
| b37ac92e9f | |||
| c8c8e3e983 | |||
| 72d40f696e | |||
| ac333b19c7 | |||
| c85d6e7baa | |||
| e534206172 | |||
| edb8f67b1b | |||
| 1796255496 | |||
| 2dbd1d6eb7 | |||
| 0d11058c8f | |||
| a5fbaa5975 | |||
| 6f8a3f5d42 | |||
| 303f68cf10 | |||
| 368cf2dd37 | |||
| 16a1debdca | |||
| c4987c01c7 | |||
| bfdf40b1b5 | |||
| 8676cf98ce | |||
| 16da49d3a9 | |||
| 97d85c8722 | |||
| 44e011e2c6 | |||
| 05de6c67b2 | |||
| 7c4706c415 | |||
| 80a047c0db | |||
| 2ac46d8d9d |
@ -7,3 +7,6 @@ include:
|
||||
- /gitlab-templates/reuse-lint.yml
|
||||
- /gitlab-templates/linux-qt6.yml
|
||||
- /gitlab-templates/freebsd-qt6.yml
|
||||
- /gitlab-templates/xml-lint.yml
|
||||
- /gitlab-templates/yaml-lint.yml
|
||||
- /gitlab-templates/linux-qt6-next.yml
|
||||
|
||||
@ -2,8 +2,11 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
Dependencies:
|
||||
- 'on': ['@all']
|
||||
'require':
|
||||
- 'on': ['@all']
|
||||
'require':
|
||||
'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.4.90")
|
||||
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(QT_MIN_VERSION "6.9.0")
|
||||
set(KF6_MIN_VERSION "6.18.0")
|
||||
set(KDE_COMPILERSETTINGS_LEVEL "5.82")
|
||||
|
||||
set(CMAKE_CXX_STANDARD 20)
|
||||
@ -31,9 +31,14 @@ include(GenerateExportHeader)
|
||||
include(KDEClangFormat)
|
||||
include(ECMQtDeclareLoggingCategory)
|
||||
include(ECMQmlModule)
|
||||
|
||||
include(KDEGitCommitHooks)
|
||||
|
||||
find_package(Qt6 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS WaylandClient Qml)
|
||||
|
||||
if (Qt6WaylandClient_VERSION VERSION_GREATER_EQUAL "6.10.0")
|
||||
find_package(Qt6WaylandClientPrivate ${REQUIRED_QT_VERSION} REQUIRED NO_MODULE)
|
||||
endif()
|
||||
|
||||
find_package(WaylandScanner REQUIRED)
|
||||
find_package(Wayland 1.3 COMPONENTS Client Server)
|
||||
find_package(WaylandProtocols REQUIRED)
|
||||
@ -53,8 +58,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)
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
# SPDX-License-Identifier: CC0-1.0
|
||||
|
||||
maintainer:
|
||||
- vladz
|
||||
- vladz
|
||||
description: Layer Shell Qt
|
||||
platforms:
|
||||
- name: Linux
|
||||
|
||||
@ -4,10 +4,18 @@
|
||||
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
|
||||
|
||||
qt6_extract_metatypes(LayerShellQtInterface)
|
||||
|
||||
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,7 +4,8 @@
|
||||
ecm_add_qml_module(LayerShellQtQml
|
||||
URI "org.kde.layershell"
|
||||
VERSION 1.0
|
||||
SOURCES layershellqtplugin.cpp)
|
||||
SOURCES types.h types.cpp
|
||||
GENERATE_PLUGIN_SOURCE)
|
||||
target_link_libraries(LayerShellQtQml PRIVATE Qt::Qml LayerShellQtInterface)
|
||||
|
||||
ecm_finalize_qml_module(LayerShellQtQml DESTINATION ${KDE_INSTALL_QMLDIR})
|
||||
ecm_finalize_qml_module(LayerShellQtQml DESTINATION ${KDE_INSTALL_QMLDIR})
|
||||
|
||||
@ -1,24 +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 <QQmlExtensionPlugin>
|
||||
#include "../interfaces/window.h"
|
||||
#include <qqml.h>
|
||||
|
||||
QML_DECLARE_TYPEINFO(LayerShellQt::Window, QML_HAS_ATTACHED_PROPERTIES)
|
||||
|
||||
class Plugin : public QQmlExtensionPlugin
|
||||
{
|
||||
Q_PLUGIN_METADATA(IID "org.kde.layershellqt")
|
||||
Q_OBJECT
|
||||
public:
|
||||
void registerTypes(const char *uri) override {
|
||||
Q_ASSERT(QLatin1String(uri) == QLatin1String("org.kde.layershell"));
|
||||
qmlRegisterType<LayerShellQt::Window>(uri, 1, 0, "Window");
|
||||
}
|
||||
};
|
||||
|
||||
#include "layershellqtplugin.moc"
|
||||
49
src/declarative/types.cpp
Normal file
49
src/declarative/types.cpp
Normal file
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* 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
|
||||
55
src/declarative/types.h
Normal file
55
src/declarative/types.h
Normal file
@ -0,0 +1,55 @@
|
||||
/*
|
||||
* 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 "../interfaces/window.h"
|
||||
#include <qqml.h>
|
||||
|
||||
QML_DECLARE_TYPEINFO(LayerShellQt::Window, QML_HAS_ATTACHED_PROPERTIES)
|
||||
|
||||
class WindowForeign
|
||||
{
|
||||
Q_GADGET
|
||||
QML_NAMED_ELEMENT(Window)
|
||||
QML_FOREIGN(LayerShellQt::Window)
|
||||
QML_UNCREATABLE("")
|
||||
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
|
||||
@ -32,8 +32,10 @@ public:
|
||||
Window::KeyboardInteractivity keyboardInteractivity = Window::KeyboardInteractivityOnDemand;
|
||||
Window::Layer layer = Window::LayerTop;
|
||||
QMargins margins;
|
||||
QSize desiredSize = QSize(0, 0);
|
||||
Window::ScreenConfiguration screenConfiguration = Window::ScreenFromQWindow;
|
||||
bool closeOnDismissed = true;
|
||||
bool activateOnShow = true;
|
||||
};
|
||||
|
||||
static QMap<QWindow *, Window *> s_map;
|
||||
@ -97,6 +99,21 @@ QMargins Window::margins() const
|
||||
return d->margins;
|
||||
}
|
||||
|
||||
void Window::setDesiredSize(const QSize &size)
|
||||
{
|
||||
if (size == d->desiredSize) {
|
||||
return;
|
||||
}
|
||||
|
||||
d->desiredSize = size;
|
||||
Q_EMIT desiredSizeChanged();
|
||||
}
|
||||
|
||||
QSize Window::desiredSize() const
|
||||
{
|
||||
return d->desiredSize;
|
||||
}
|
||||
|
||||
void Window::setKeyboardInteractivity(KeyboardInteractivity interactivity)
|
||||
{
|
||||
if (d->keyboardInteractivity != interactivity) {
|
||||
@ -154,6 +171,16 @@ void Window::setCloseOnDismissed(bool close)
|
||||
d->closeOnDismissed = close;
|
||||
}
|
||||
|
||||
bool Window::activateOnShow() const
|
||||
{
|
||||
return d->activateOnShow;
|
||||
}
|
||||
|
||||
void Window::setActivateOnShow(bool activateOnShow)
|
||||
{
|
||||
d->activateOnShow = activateOnShow;
|
||||
}
|
||||
|
||||
Window::Window(QWindow *window)
|
||||
: QObject(window)
|
||||
, d(new WindowPrivate(window))
|
||||
|
||||
@ -28,6 +28,7 @@ class LAYERSHELLQT_EXPORT Window : public QObject
|
||||
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)
|
||||
|
||||
public:
|
||||
~Window() override;
|
||||
@ -39,8 +40,8 @@ public:
|
||||
AnchorLeft = 4, ///< The left edge of the anchor rectangle
|
||||
AnchorRight = 8, ///< The right edge of the anchor rectangle
|
||||
};
|
||||
Q_ENUM(Anchor);
|
||||
Q_DECLARE_FLAGS(Anchors, Anchor)
|
||||
Q_FLAG(Anchors)
|
||||
|
||||
/**
|
||||
* This enum type is used to specify the layer where a surface can be put in.
|
||||
@ -86,6 +87,9 @@ public:
|
||||
void setMargins(const QMargins &margins);
|
||||
QMargins margins() const;
|
||||
|
||||
void setDesiredSize(const QSize &size);
|
||||
QSize desiredSize() const;
|
||||
|
||||
void setKeyboardInteractivity(KeyboardInteractivity interactivity);
|
||||
KeyboardInteractivity keyboardInteractivity() const;
|
||||
|
||||
@ -114,6 +118,18 @@ public:
|
||||
void setCloseOnDismissed(bool close);
|
||||
bool closeOnDismissed() const;
|
||||
|
||||
/**
|
||||
* Whether the window should requestActivate on show.
|
||||
*
|
||||
* Normally, you want this enabled but in case of e.g. a desktop window, this can be disabled.
|
||||
*
|
||||
* It does nothing when KeyboardInteractivity is KeyboardInteractivityNone.
|
||||
*
|
||||
* The default is true.
|
||||
*/
|
||||
void setActivateOnShow(bool activateOnShow);
|
||||
bool activateOnShow() const;
|
||||
|
||||
/**
|
||||
* Gets the LayerShell Window for a given Qt Window
|
||||
* Ownership is not transferred
|
||||
@ -127,6 +143,7 @@ Q_SIGNALS:
|
||||
void exclusionZoneChanged();
|
||||
void exclusiveEdgeChanged();
|
||||
void marginsChanged();
|
||||
void desiredSizeChanged();
|
||||
void keyboardInteractivityChanged();
|
||||
void layerChanged();
|
||||
|
||||
|
||||
@ -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;
|
||||
};
|
||||
|
||||
@ -44,7 +44,11 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setAnchor(m_interface->anchors());
|
||||
connect(m_interface, &Window::anchorsChanged, this, [this]() {
|
||||
setAnchor(m_interface->anchors());
|
||||
setDesiredSize(m_window->windowContentGeometry().size());
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(m_window->windowContentGeometry().size());
|
||||
} else {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
}
|
||||
});
|
||||
|
||||
setExclusiveZone(m_interface->exclusionZone());
|
||||
@ -61,19 +65,26 @@ QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell,
|
||||
setMargins(m_interface->margins());
|
||||
});
|
||||
|
||||
connect(m_interface, &Window::desiredSizeChanged, this, [this]() {
|
||||
if (!m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
}
|
||||
});
|
||||
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
connect(m_interface, &Window::keyboardInteractivityChanged, this, [this]() {
|
||||
setKeyboardInteractivity(m_interface->keyboardInteractivity());
|
||||
});
|
||||
|
||||
setDesiredSize(window->windowContentGeometry().size());
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(window->windowContentGeometry().size());
|
||||
} else {
|
||||
setDesiredSize(m_interface->desiredSize());
|
||||
}
|
||||
}
|
||||
|
||||
QWaylandLayerSurface::~QWaylandLayerSurface()
|
||||
{
|
||||
if (m_waitForSyncCallback) {
|
||||
wl_callback_destroy(m_waitForSyncCallback);
|
||||
}
|
||||
destroy();
|
||||
}
|
||||
|
||||
@ -113,9 +124,13 @@ 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)
|
||||
@ -166,15 +181,25 @@ void QWaylandLayerSurface::setLayer(uint32_t layer)
|
||||
set_layer(layer);
|
||||
}
|
||||
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
||||
{
|
||||
if (m_configuring) {
|
||||
return;
|
||||
}
|
||||
|
||||
setDesiredSize(geometry.size());
|
||||
requestWaylandSync();
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(geometry.size());
|
||||
}
|
||||
}
|
||||
#else
|
||||
void QWaylandLayerSurface::setWindowSize(const QSize &size)
|
||||
{
|
||||
if (m_interface->desiredSize().isNull()) {
|
||||
setDesiredSize(size);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
bool QWaylandLayerSurface::requestActivate()
|
||||
{
|
||||
@ -186,16 +211,18 @@ bool QWaylandLayerSurface::requestActivate()
|
||||
activation->activate(m_activationToken, window()->wlSurface());
|
||||
m_activationToken = {};
|
||||
return true;
|
||||
} else if (const auto token = qEnvironmentVariable("XDG_ACTIVATION_TOKEN"); !token.isEmpty()) {
|
||||
activation->activate(token, window()->wlSurface());
|
||||
qunsetenv("XDG_ACTIVATION_TOKEN");
|
||||
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;
|
||||
}
|
||||
@ -203,6 +230,23 @@ bool QWaylandLayerSurface::requestActivate()
|
||||
return false;
|
||||
}
|
||||
|
||||
bool QWaylandLayerSurface::requestActivateOnShow()
|
||||
{
|
||||
if (!m_interface->activateOnShow()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_interface->keyboardInteractivity() == Window::KeyboardInteractivityNone) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (m_window->window()->property("_q_showWithoutActivating").toBool()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return requestActivate();
|
||||
}
|
||||
|
||||
void QWaylandLayerSurface::setXdgActivationToken(const QString &token)
|
||||
{
|
||||
m_activationToken = token;
|
||||
@ -214,52 +258,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);
|
||||
}
|
||||
|
||||
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
|
||||
#elif QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
window()->sendRecursiveExposeEvent();
|
||||
#else
|
||||
window()->updateExposure();
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ public:
|
||||
|
||||
bool isExposed() const override
|
||||
{
|
||||
return m_configured && !m_waitForSyncCallback;
|
||||
return m_configured;
|
||||
}
|
||||
void attachPopup(QtWaylandClient::QWaylandShellSurface *popup) override;
|
||||
|
||||
@ -43,15 +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;
|
||||
bool requestActivateOnShow() 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;
|
||||
@ -63,10 +66,9 @@ private:
|
||||
QString m_activationToken;
|
||||
|
||||
bool m_configured = false;
|
||||
#if QT_VERSION < QT_VERSION_CHECK(6, 9, 0)
|
||||
bool m_configuring = false;
|
||||
|
||||
static const wl_callback_listener syncCallbackListener;
|
||||
struct wl_callback *m_waitForSyncCallback = nullptr;
|
||||
#endif
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ int main(int argc, char **argv)
|
||||
QGuiApplication app(argc, argv);
|
||||
|
||||
const auto layerMetaEnum = QMetaEnum::fromType<Window::Layer>();
|
||||
const auto anchorMetaEnum = QMetaEnum::fromType<Window::Anchor>();
|
||||
const auto anchorMetaEnum = QMetaEnum::fromType<Window::Anchors>();
|
||||
|
||||
QCommandLineParser parser;
|
||||
QCommandLineOption marginsOption(QStringLiteral("margins"), QStringLiteral("Window margins"), QStringLiteral("pixels"), QStringLiteral("0"));
|
||||
|
||||
@ -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