mirror of
https://invent.kde.org/plasma/layer-shell-qt.git
synced 2025-06-04 01:28:35 -04:00
wip activation
This commit is contained in:
parent
1573a89aac
commit
1b0f42ce20
@ -6,9 +6,18 @@ remove_definitions(-DQT_NO_SIGNALS_SLOTS_KEYWORDS)
|
|||||||
add_library(LayerShellQtInterface)
|
add_library(LayerShellQtInterface)
|
||||||
qt6_generate_wayland_protocol_client_sources(LayerShellQtInterface FILES
|
qt6_generate_wayland_protocol_client_sources(LayerShellQtInterface FILES
|
||||||
${WaylandProtocols_DATADIR}/stable/xdg-shell/xdg-shell.xml
|
${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
|
${CMAKE_CURRENT_SOURCE_DIR}/wlr-layer-shell-unstable-v1.xml
|
||||||
)
|
)
|
||||||
|
|
||||||
|
set(LAYER_SHELL_SOURCES
|
||||||
|
qwaylandxdgactivationv1.cpp
|
||||||
|
qwaylandlayersurface.cpp
|
||||||
|
qwaylandlayershellintegration.cpp
|
||||||
|
interfaces/window.cpp
|
||||||
|
interfaces/shell.cpp
|
||||||
|
)
|
||||||
|
|
||||||
ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES
|
ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES
|
||||||
HEADER
|
HEADER
|
||||||
layershellqt_logging.h
|
layershellqt_logging.h
|
||||||
@ -18,7 +27,7 @@ ecm_qt_declare_logging_category(LAYER_SHELL_SOURCES
|
|||||||
layershellqt
|
layershellqt
|
||||||
)
|
)
|
||||||
|
|
||||||
target_sources(LayerShellQtInterface PRIVATE qwaylandlayersurface.cpp interfaces/window.cpp interfaces/shell.cpp qwaylandlayershellintegration.cpp ${LAYER_SHELL_SOURCES})
|
target_sources(LayerShellQtInterface PRIVATE ${LAYER_SHELL_SOURCES})
|
||||||
target_link_libraries(LayerShellQtInterface PUBLIC Qt::Gui)
|
target_link_libraries(LayerShellQtInterface PUBLIC Qt::Gui)
|
||||||
target_link_libraries(LayerShellQtInterface PRIVATE Qt::WaylandClientPrivate Wayland::Client PkgConfig::XKBCOMMON)
|
target_link_libraries(LayerShellQtInterface PRIVATE Qt::WaylandClientPrivate Wayland::Client PkgConfig::XKBCOMMON)
|
||||||
if (TARGET Qt::XkbCommonSupportPrivate)
|
if (TARGET Qt::XkbCommonSupportPrivate)
|
||||||
|
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "qwaylandlayershellintegration_p.h"
|
#include "qwaylandlayershellintegration_p.h"
|
||||||
#include "qwaylandlayersurface_p.h"
|
#include "qwaylandlayersurface_p.h"
|
||||||
|
#include "qwaylandxdgactivationv1_p.h"
|
||||||
|
|
||||||
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
#include <QtWaylandClient/private/qwaylanddisplay_p.h>
|
||||||
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
#include <QtWaylandClient/private/qwaylandwindow_p.h>
|
||||||
@ -15,6 +16,7 @@ namespace LayerShellQt
|
|||||||
{
|
{
|
||||||
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
|
QWaylandLayerShellIntegration::QWaylandLayerShellIntegration()
|
||||||
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(4)
|
: QWaylandShellIntegrationTemplate<QWaylandLayerShellIntegration>(4)
|
||||||
|
, m_xdgActivation(new QWaylandXdgActivationV1)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
|
#include <QtWaylandClient/private/qwaylandshellintegration_p.h>
|
||||||
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
||||||
|
|
||||||
|
class QWaylandXdgActivationV1;
|
||||||
|
|
||||||
namespace LayerShellQt
|
namespace LayerShellQt
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -22,7 +24,10 @@ public:
|
|||||||
QWaylandLayerShellIntegration();
|
QWaylandLayerShellIntegration();
|
||||||
~QWaylandLayerShellIntegration() override;
|
~QWaylandLayerShellIntegration() override;
|
||||||
|
|
||||||
|
QWaylandXdgActivationV1 *activation() const { return m_xdgActivation.data(); }
|
||||||
QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
|
QtWaylandClient::QWaylandShellSurface *createShellSurface(QtWaylandClient::QWaylandWindow *window) override;
|
||||||
|
private:
|
||||||
|
QScopedPointer<QWaylandXdgActivationV1> m_xdgActivation;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,16 +8,20 @@
|
|||||||
#include "interfaces/window.h"
|
#include "interfaces/window.h"
|
||||||
#include "layershellqt_logging.h"
|
#include "layershellqt_logging.h"
|
||||||
#include "qwaylandlayersurface_p.h"
|
#include "qwaylandlayersurface_p.h"
|
||||||
|
#include "qwaylandxdgactivationv1_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>
|
||||||
|
|
||||||
|
#include <QGuiApplication>
|
||||||
|
|
||||||
namespace LayerShellQt
|
namespace LayerShellQt
|
||||||
{
|
{
|
||||||
QWaylandLayerSurface::QWaylandLayerSurface(QtWayland::zwlr_layer_shell_v1 *shell, QtWaylandClient::QWaylandWindow *window)
|
QWaylandLayerSurface::QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window)
|
||||||
: QtWaylandClient::QWaylandShellSurface(window)
|
: QtWaylandClient::QWaylandShellSurface(window)
|
||||||
, QtWayland::zwlr_layer_surface_v1()
|
, QtWayland::zwlr_layer_surface_v1()
|
||||||
|
, m_shell(shell)
|
||||||
, m_interface(Window::get(window->window()))
|
, m_interface(Window::get(window->window()))
|
||||||
{
|
{
|
||||||
wl_output *output = nullptr;
|
wl_output *output = nullptr;
|
||||||
@ -155,4 +159,56 @@ void QWaylandLayerSurface::setWindowGeometry(const QRect &geometry)
|
|||||||
set_size(size.width(), size.height());
|
set_size(size.width(), size.height());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool QWaylandLayerSurface::requestActivate()
|
||||||
|
{
|
||||||
|
qDebug() << "activate@ @ " << window()->window();
|
||||||
|
auto activation = m_shell->activation();
|
||||||
|
if (activation->isActive()) {
|
||||||
|
if (!m_activationToken.isEmpty()) {
|
||||||
|
activation->activate(m_activationToken, window()->wlSurface());
|
||||||
|
m_activationToken = {};
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
qDebug() << this << "request activate";
|
||||||
|
const auto focusWindow = QGuiApplication::focusWindow();
|
||||||
|
const auto wlWindow = focusWindow ? static_cast<QtWaylandClient::QWaylandWindow*>(focusWindow->handle()) : window();
|
||||||
|
qDebug() << "focus is " << wlWindow->window();
|
||||||
|
if (const auto seat = wlWindow->display()->lastInputDevice()) {
|
||||||
|
const auto tokenProvider = activation->requestXdgActivationToken(
|
||||||
|
nullptr, wlWindow->wlSurface(), 0, QString());
|
||||||
|
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this,
|
||||||
|
[this, tokenProvider](const QString &token) {
|
||||||
|
qDebug() << this << "activating" << token;
|
||||||
|
m_shell->activation()->activate(token, window()->wlSurface());
|
||||||
|
tokenProvider->deleteLater();
|
||||||
|
});
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void QWaylandLayerSurface::setXdgActivationToken(const QString &token)
|
||||||
|
{
|
||||||
|
m_activationToken = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
void QWaylandLayerSurface::requestXdgActivationToken(quint32 serial)
|
||||||
|
{
|
||||||
|
if (auto *activation = m_shell->activation()) {
|
||||||
|
auto tokenProvider = activation->requestXdgActivationToken(
|
||||||
|
nullptr, window()->wlSurface(), serial, QString());
|
||||||
|
|
||||||
|
connect(tokenProvider, &QWaylandXdgActivationTokenV1::done, this,
|
||||||
|
[this, tokenProvider](const QString &token) {
|
||||||
|
Q_EMIT window()->xdgActivationTokenCreated(token);
|
||||||
|
tokenProvider->deleteLater();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
QWaylandShellSurface::requestXdgActivationToken(serial);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
#include <wayland-client.h>
|
#include <wayland-client.h>
|
||||||
|
|
||||||
|
#include "qwaylandlayershellintegration_p.h"
|
||||||
|
|
||||||
#include "layershellqt_export.h"
|
#include "layershellqt_export.h"
|
||||||
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
|
#include <QtWaylandClient/private/qwaylandshellsurface_p.h>
|
||||||
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
#include <qwayland-wlr-layer-shell-unstable-v1.h>
|
||||||
@ -23,7 +25,7 @@ class LAYERSHELLQT_EXPORT QWaylandLayerSurface : public QtWaylandClient::QWaylan
|
|||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
QWaylandLayerSurface(QtWayland::zwlr_layer_shell_v1 *shell, QtWaylandClient::QWaylandWindow *window);
|
QWaylandLayerSurface(QWaylandLayerShellIntegration *shell, QtWaylandClient::QWaylandWindow *window);
|
||||||
~QWaylandLayerSurface() override;
|
~QWaylandLayerSurface() override;
|
||||||
|
|
||||||
bool isExposed() const override
|
bool isExposed() const override
|
||||||
@ -43,12 +45,18 @@ public:
|
|||||||
void applyConfigure() override;
|
void applyConfigure() override;
|
||||||
void setWindowGeometry(const QRect &geometry) override;
|
void setWindowGeometry(const QRect &geometry) override;
|
||||||
|
|
||||||
|
bool requestActivate() override;
|
||||||
|
void setXdgActivationToken(const QString &token) override;
|
||||||
|
void requestXdgActivationToken(quint32 serial) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
void zwlr_layer_surface_v1_configure(uint32_t serial, uint32_t width, uint32_t height) override;
|
||||||
void zwlr_layer_surface_v1_closed() override;
|
void zwlr_layer_surface_v1_closed() override;
|
||||||
|
|
||||||
|
QWaylandLayerShellIntegration *m_shell;
|
||||||
LayerShellQt::Window *m_interface;
|
LayerShellQt::Window *m_interface;
|
||||||
QSize m_pendingSize;
|
QSize m_pendingSize;
|
||||||
|
QString m_activationToken;
|
||||||
bool m_configured = false;
|
bool m_configured = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
43
src/qwaylandxdgactivationv1.cpp
Normal file
43
src/qwaylandxdgactivationv1.cpp
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||||
|
|
||||||
|
#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(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"
|
41
src/qwaylandxdgactivationv1_p.h
Normal file
41
src/qwaylandxdgactivationv1_p.h
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
// Copyright (C) 2020 Aleix Pol Gonzalez <aleixpol@kde.org>
|
||||||
|
// 2023
|
||||||
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
||||||
|
|
||||||
|
#ifndef QWAYLANDXDGACTIVATIONV1_P_H
|
||||||
|
#define QWAYLANDXDGACTIVATIONV1_P_H
|
||||||
|
|
||||||
|
#include <QObject>
|
||||||
|
#include "qwayland-xdg-activation-v1.h"
|
||||||
|
|
||||||
|
#include <QtWaylandClient/QWaylandClientExtension>
|
||||||
|
|
||||||
|
class QWaylandDisplay;
|
||||||
|
class QWaylandSurface;
|
||||||
|
|
||||||
|
class QWaylandXdgActivationTokenV1
|
||||||
|
: public QObject,
|
||||||
|
public QtWayland::xdg_activation_token_v1
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
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(QWaylandDisplay *display,
|
||||||
|
struct ::wl_surface *surface,
|
||||||
|
std::optional<uint32_t> serial,
|
||||||
|
const QString &app_id);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // QWAYLANDXDGACTIVATIONV1_P_H
|
Loading…
x
Reference in New Issue
Block a user