Commit 36e94e57 authored by Vlad Zahorodnii's avatar Vlad Zahorodnii
Browse files

Drop support for wl_shell_surface

wl_shell_surface has been deprecated for quite a long time. Nowadays
most clients use the xdg-shell protocol to create desktop-style user
interface elements.
parent e13d521c
......@@ -49,17 +49,6 @@ target_link_libraries( testWaylandOutput Qt5::Test Qt5::Gui KF5::WaylandClient P
add_test(NAME kwayland-testWaylandOutput COMMAND testWaylandOutput)
ecm_mark_as_test(testWaylandOutput)
########################################################
# Test WaylandShell
########################################################
set( testWaylandShell_SRCS
test_wayland_shell.cpp
)
add_executable(testWaylandShell ${testWaylandShell_SRCS})
target_link_libraries( testWaylandShell Qt5::Test Qt5::Gui KF5::WaylandClient Plasma::KWaylandServer Wayland::Client Wayland::Server)
add_test(NAME kwayland-testWaylandShell COMMAND testWaylandShell)
ecm_mark_as_test(testWaylandShell)
########################################################
# Test WaylandSurface
########################################################
......
......@@ -16,7 +16,6 @@
#include "KWayland/Client/touch.h"
#include "KWayland/Client/registry.h"
#include "KWayland/Client/seat.h"
#include "KWayland/Client/shell.h"
#include "KWayland/Client/shm_pool.h"
#include "KWayland/Client/surface.h"
#include "../../src/server/display.h"
......@@ -24,7 +23,6 @@
#include "../../src/server/datadevicemanager_interface.h"
#include "../../src/server/datasource_interface.h"
#include "../../src/server/seat_interface.h"
#include "../../src/server/shell_interface.h"
class TestDragAndDrop : public QObject
{
......@@ -47,7 +45,6 @@ private:
KWaylandServer::CompositorInterface *m_compositorInterface = nullptr;
KWaylandServer::DataDeviceManagerInterface *m_dataDeviceManagerInterface = nullptr;
KWaylandServer::SeatInterface *m_seatInterface = nullptr;
KWaylandServer::ShellInterface *m_shellInterface = nullptr;
KWayland::Client::ConnectionThread *m_connection = nullptr;
KWayland::Client::Compositor *m_compositor = nullptr;
KWayland::Client::EventQueue *m_queue = nullptr;
......@@ -60,7 +57,6 @@ private:
KWayland::Client::Touch *m_touch = nullptr;
KWayland::Client::DataDeviceManager *m_ddm = nullptr;
KWayland::Client::ShmPool *m_shm = nullptr;
KWayland::Client::Shell *m_shell = nullptr;
};
static const QString s_socketName = QStringLiteral("kwayland-test-wayland-drag-n-drop-0");
......@@ -93,8 +89,6 @@ void TestDragAndDrop::init()
m_dataDeviceManagerInterface->create();
QVERIFY(m_dataDeviceManagerInterface->isValid());
m_display->createShm();
m_shellInterface = m_display->createShell(m_display);
m_shellInterface->create();
m_thread = new QThread(this);
m_connection->moveToThread(m_thread);
......@@ -128,7 +122,6 @@ void TestDragAndDrop::init()
CREATE(m_seat, Seat, Seat)
CREATE(m_ddm, DataDeviceManager, DataDeviceManager)
CREATE(m_shm, ShmPool, Shm)
CREATE(m_shell, Shell, Shell)
#undef CREATE
......@@ -155,7 +148,6 @@ void TestDragAndDrop::cleanup()
}
DELETE(m_dataSource)
DELETE(m_dataDevice)
DELETE(m_shell)
DELETE(m_shm)
DELETE(m_compositor)
DELETE(m_ddm)
......
......@@ -11,12 +11,10 @@
#include "KWayland/Client/event_queue.h"
#include "KWayland/Client/plasmashell.h"
#include "KWayland/Client/registry.h"
#include "KWayland/Client/shell.h"
#include "KWayland/Client/surface.h"
// server
#include "../../src/server/display.h"
#include "../../src/server/compositor_interface.h"
#include "../../src/server/shell_interface.h"
#include "../../src/server/plasmashell_interface.h"
#include <wayland-client-protocol.h>
......@@ -33,15 +31,11 @@ private Q_SLOTS:
void init();
void cleanup();
void testMultipleShellSurfacesForSurface();
void testMultiplePlasmaShellSurfacesForSurface();
void testTransientForSameSurface_data();
void testTransientForSameSurface();
private:
Display *m_display = nullptr;
CompositorInterface *m_ci = nullptr;
ShellInterface *m_si = nullptr;
PlasmaShellInterface *m_psi = nullptr;
ConnectionThread *m_connection = nullptr;
QThread *m_thread = nullptr;
......@@ -63,8 +57,6 @@ void ErrorTest::init()
m_display->createShm();
m_ci = m_display->createCompositor(m_display);
m_ci->create();
m_si = m_display->createShell(m_display);
m_si->create();
m_psi = m_display->createPlasmaShell(m_display);
m_psi->create();
......@@ -97,10 +89,6 @@ void ErrorTest::init()
registry.interface(Registry::Interface::Compositor).version,
this);
QVERIFY(m_compositor);
m_shell = registry.createShell(registry.interface(Registry::Interface::Shell).name,
registry.interface(Registry::Interface::Shell).version,
this);
QVERIFY(m_shell);
m_plasmaShell = registry.createPlasmaShell(registry.interface(Registry::Interface::PlasmaShell).name,
registry.interface(Registry::Interface::PlasmaShell).version,
this);
......@@ -129,25 +117,11 @@ void ErrorTest::cleanup()
m_thread = nullptr;
}
CLEANUP(m_psi)
CLEANUP(m_si)
CLEANUP(m_ci)
CLEANUP(m_display)
#undef CLEANUP
}
void ErrorTest::testMultipleShellSurfacesForSurface()
{
// this test verifies that creating two ShellSurfaces for the same Surface triggers a protocol error
QSignalSpy errorSpy(m_connection, &ConnectionThread::errorOccurred);
QVERIFY(errorSpy.isValid());
QScopedPointer<Surface> surface(m_compositor->createSurface());
QScopedPointer<ShellSurface> shellSurface1(m_shell->createSurface(surface.data()));
QScopedPointer<ShellSurface> shellSurface2(m_shell->createSurface(surface.data()));
QVERIFY(errorSpy.wait());
QVERIFY(m_connection->hasError());
QCOMPARE(m_connection->errorCode(), EPROTO);
}
void ErrorTest::testMultiplePlasmaShellSurfacesForSurface()
{
// this test verifies that creating two ShellSurfaces for the same Surface triggers a protocol error
......@@ -165,27 +139,5 @@ void ErrorTest::testMultiplePlasmaShellSurfacesForSurface()
wl_surface_destroy(surface);
}
void ErrorTest::testTransientForSameSurface_data()
{
QTest::addColumn<ShellSurface::TransientFlag>("flag");
QTest::newRow("transient") << ShellSurface::TransientFlag::Default;
QTest::newRow("transient no focus") << ShellSurface::TransientFlag::NoFocus;
}
void ErrorTest::testTransientForSameSurface()
{
// this test verifies that creating a transient shell surface for itself triggers a protocol error
QSignalSpy errorSpy(m_connection, &ConnectionThread::errorOccurred);
QVERIFY(errorSpy.isValid());
QScopedPointer<Surface> surface(m_compositor->createSurface());
QScopedPointer<ShellSurface> shellSurface(m_shell->createSurface(surface.data()));
QFETCH(ShellSurface::TransientFlag, flag);
shellSurface->setTransient(surface.data(), QPoint(), flag);
QVERIFY(errorSpy.wait());
QVERIFY(m_connection->hasError());
QCOMPARE(m_connection->errorCode(), EPROTO);
}
QTEST_GUILESS_MAIN(ErrorTest)
#include "test_error.moc"
......@@ -15,7 +15,6 @@
#include "KWayland/Client/output.h"
#include "KWayland/Client/registry.h"
#include "../../src/server/display.h"
#include "../../src/server/shell_interface.h"
#include "../../src/server/compositor_interface.h"
#include "../../src/server/outputconfiguration_interface.h"
#include "../../src/server/outputdevice_interface.h"
......@@ -96,8 +95,6 @@ void TestWaylandOutputManagement::init()
m_display->start();
QVERIFY(m_display->isRunning());
auto shell = m_display->createShell(this);
shell->create();
auto comp = m_display->createCompositor(this);
comp->create();
......
......@@ -20,7 +20,6 @@
#include "KWayland/Client/seat.h"
#include "KWayland/Client/relativepointer.h"
#include "KWayland/Client/server_decoration.h"
#include "KWayland/Client/shell.h"
#include "KWayland/Client/surface.h"
#include "KWayland/Client/subcompositor.h"
#include "KWayland/Client/xdgshell.h"
......@@ -31,7 +30,6 @@
#include "../../src/server/idleinhibit_interface.h"
#include "../../src/server/output_interface.h"
#include "../../src/server/seat_interface.h"
#include "../../src/server/shell_interface.h"
#include "../../src/server/blur_interface.h"
#include "../../src/server/contrast_interface.h"
#include "../../src/server/server_decoration_interface.h"
......@@ -67,7 +65,6 @@ private Q_SLOTS:
void testCreate();
void testBindCompositor();
void testBindShell();
void testBindOutput();
void testBindShm();
void testBindSeat();
......@@ -96,7 +93,6 @@ private:
KWaylandServer::OutputInterface *m_output;
KWaylandServer::OutputDeviceInterface *m_outputDevice;
KWaylandServer::SeatInterface *m_seat;
KWaylandServer::ShellInterface *m_shell;
KWaylandServer::SubCompositorInterface *m_subcompositor;
KWaylandServer::DataDeviceManagerInterface *m_dataDeviceManager;
KWaylandServer::OutputManagementInterface *m_outputManagement;
......@@ -122,7 +118,6 @@ TestWaylandRegistry::TestWaylandRegistry(QObject *parent)
, m_output(nullptr)
, m_outputDevice(nullptr)
, m_seat(nullptr)
, m_shell(nullptr)
, m_subcompositor(nullptr)
, m_dataDeviceManager(nullptr)
, m_outputManagement(nullptr)
......@@ -151,8 +146,6 @@ void TestWaylandRegistry::init()
m_output->create();
m_seat = m_display->createSeat();
m_seat->create();
m_shell = m_display->createShell();
m_shell->create();
m_subcompositor = m_display->createSubCompositor();
m_subcompositor->create();
m_dataDeviceManager = m_display->createDataDeviceManager();
......@@ -263,11 +256,6 @@ void TestWaylandRegistry::testBindCompositor()
TEST_BIND(KWayland::Client::Registry::Interface::Compositor, SIGNAL(compositorAnnounced(quint32,quint32)), bindCompositor, wl_compositor_destroy)
}
void TestWaylandRegistry::testBindShell()
{
TEST_BIND(KWayland::Client::Registry::Interface::Shell, SIGNAL(shellAnnounced(quint32,quint32)), bindShell, free)
}
void TestWaylandRegistry::testBindOutput()
{
TEST_BIND(KWayland::Client::Registry::Interface::Output, SIGNAL(outputAnnounced(quint32,quint32)), bindOutput, wl_output_destroy)
......@@ -363,8 +351,6 @@ void TestWaylandRegistry::testRemoval()
QVERIFY(outputAnnouncedSpy.isValid());
QSignalSpy outputDeviceAnnouncedSpy(&registry, SIGNAL(outputDeviceAnnounced(quint32,quint32)));
QVERIFY(outputDeviceAnnouncedSpy.isValid());
QSignalSpy shellAnnouncedSpy(&registry, SIGNAL(shellAnnounced(quint32,quint32)));
QVERIFY(shellAnnouncedSpy.isValid());
QSignalSpy seatAnnouncedSpy(&registry, SIGNAL(seatAnnounced(quint32,quint32)));
QVERIFY(seatAnnouncedSpy.isValid());
QSignalSpy subCompositorAnnouncedSpy(&registry, SIGNAL(subCompositorAnnounced(quint32,quint32)));
......@@ -386,7 +372,6 @@ void TestWaylandRegistry::testRemoval()
QVERIFY(!compositorAnnouncedSpy.isEmpty());
QVERIFY(!outputAnnouncedSpy.isEmpty());
QVERIFY(!outputDeviceAnnouncedSpy.isEmpty());
QVERIFY(!shellAnnouncedSpy.isEmpty());
QVERIFY(!seatAnnouncedSpy.isEmpty());
QVERIFY(!subCompositorAnnouncedSpy.isEmpty());
QVERIFY(!outputManagementAnnouncedSpy.isEmpty());
......@@ -399,7 +384,6 @@ void TestWaylandRegistry::testRemoval()
QVERIFY(registry.hasInterface(KWayland::Client::Registry::Interface::Output));
QVERIFY(registry.hasInterface(KWayland::Client::Registry::Interface::OutputDevice));
QVERIFY(registry.hasInterface(KWayland::Client::Registry::Interface::Seat));
QVERIFY(registry.hasInterface(KWayland::Client::Registry::Interface::Shell));
QVERIFY(registry.hasInterface(KWayland::Client::Registry::Interface::Shm));
QVERIFY(registry.hasInterface(KWayland::Client::Registry::Interface::SubCompositor));
QVERIFY(!registry.hasInterface(KWayland::Client::Registry::Interface::FullscreenShell));
......@@ -412,7 +396,6 @@ void TestWaylandRegistry::testRemoval()
QVERIFY(!registry.interfaces(KWayland::Client::Registry::Interface::Output).isEmpty());
QVERIFY(!registry.interfaces(KWayland::Client::Registry::Interface::OutputDevice).isEmpty());
QVERIFY(!registry.interfaces(KWayland::Client::Registry::Interface::Seat).isEmpty());
QVERIFY(!registry.interfaces(KWayland::Client::Registry::Interface::Shell).isEmpty());
QVERIFY(!registry.interfaces(KWayland::Client::Registry::Interface::Shm).isEmpty());
QVERIFY(!registry.interfaces(KWayland::Client::Registry::Interface::SubCompositor).isEmpty());
QVERIFY(registry.interfaces(KWayland::Client::Registry::Interface::FullscreenShell).isEmpty());
......@@ -425,7 +408,6 @@ void TestWaylandRegistry::testRemoval()
QVERIFY(seatRemovedSpy.isValid());
Seat *seat = registry.createSeat(registry.interface(Registry::Interface::Seat).name, registry.interface(Registry::Interface::Seat).version, &registry);
Shell *shell = registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version, &registry);
Output *output = registry.createOutput(registry.interface(Registry::Interface::Output).name, registry.interface(Registry::Interface::Output).version, &registry);
Compositor *compositor = registry.createCompositor(registry.interface(Registry::Interface::Compositor).name, registry.interface(Registry::Interface::Compositor).version, &registry);
SubCompositor *subcompositor = registry.createSubCompositor(registry.interface(Registry::Interface::SubCompositor).name, registry.interface(Registry::Interface::SubCompositor).version, &registry);
......@@ -437,8 +419,6 @@ void TestWaylandRegistry::testRemoval()
m_display->dispatchEvents();
QSignalSpy seatObjectRemovedSpy(seat, &Seat::removed);
QVERIFY(seatObjectRemovedSpy.isValid());
QSignalSpy shellObjectRemovedSpy(shell, &Shell::removed);
QVERIFY(shellObjectRemovedSpy.isValid());
QSignalSpy outputObjectRemovedSpy(output, &Output::removed);
QVERIFY(outputObjectRemovedSpy.isValid());
QSignalSpy compositorObjectRemovedSpy(compositor, &Compositor::removed);
......@@ -455,16 +435,6 @@ void TestWaylandRegistry::testRemoval()
QVERIFY(registry.interfaces(KWayland::Client::Registry::Interface::Seat).isEmpty());
QCOMPARE(seatObjectRemovedSpy.count(), 1);
QSignalSpy shellRemovedSpy(&registry, SIGNAL(shellRemoved(quint32)));
QVERIFY(shellRemovedSpy.isValid());
delete m_shell;
QVERIFY(shellRemovedSpy.wait());
QCOMPARE(shellRemovedSpy.first().first(), shellAnnouncedSpy.first().first());
QVERIFY(!registry.hasInterface(KWayland::Client::Registry::Interface::Shell));
QVERIFY(registry.interfaces(KWayland::Client::Registry::Interface::Shell).isEmpty());
QCOMPARE(shellObjectRemovedSpy.count(), 1);
QSignalSpy outputRemovedSpy(&registry, SIGNAL(outputRemoved(quint32)));
QVERIFY(outputRemovedSpy.isValid());
......@@ -549,7 +519,6 @@ void TestWaylandRegistry::testRemoval()
// verify everything has been removed only once
QCOMPARE(seatObjectRemovedSpy.count(), 1);
QCOMPARE(shellObjectRemovedSpy.count(), 1);
QCOMPARE(outputObjectRemovedSpy.count(), 1);
QCOMPARE(compositorObjectRemovedSpy.count(), 1);
QCOMPARE(subcompositorObjectRemovedSpy.count(), 1);
......@@ -642,7 +611,7 @@ void TestWaylandRegistry::testDestroy()
QVERIFY(connectedSpy.wait());
Registry registry;
QSignalSpy shellAnnouncedSpy(&registry, SIGNAL(shellAnnounced(quint32,quint32)));
QSignalSpy seatAnnouncedSpy(&registry, SIGNAL(seatAnnounced(quint32,quint32)));
QVERIFY(!registry.isValid());
registry.create(&connection);
......@@ -650,8 +619,10 @@ void TestWaylandRegistry::testDestroy()
QVERIFY(registry.isValid());
//create some arbitrary Interface
shellAnnouncedSpy.wait();
QScopedPointer<Shell> shell(registry.createShell(registry.interface(Registry::Interface::Shell).name, registry.interface(Registry::Interface::Shell).version, &registry));
seatAnnouncedSpy.wait();
QScopedPointer<Seat> seat(registry.createSeat(registry.interface(Registry::Interface::Seat).name,
registry.interface(Registry::Interface::Seat).version,
&registry));
QSignalSpy connectionDiedSpy(&connection, SIGNAL(connectionDied()));
......@@ -672,7 +643,7 @@ void TestWaylandRegistry::testDestroy()
// calling destroy again should not fail
registry.destroy();
shell->destroy();
seat->destroy();
}
void TestWaylandRegistry::testGlobalSync()
......
This diff is collapsed.
......@@ -44,7 +44,6 @@ set(SERVER_LIB_SRCS
server_decoration_interface.cpp
server_decoration_palette_interface.cpp
shadow_interface.cpp
shell_interface.cpp
slide_interface.cpp
subcompositor_interface.cpp
surface_interface.cpp
......@@ -370,7 +369,6 @@ set(SERVER_LIB_HEADERS
server_decoration_interface.h
server_decoration_palette_interface.h
shadow_interface.h
shell_interface.h
slide_interface.h
subcompositor_interface.h
surface_interface.h
......
......@@ -33,7 +33,6 @@
#include "server_decoration_interface.h"
#include "server_decoration_palette_interface.h"
#include "shadow_interface.h"
#include "shell_interface.h"
#include "slide_interface.h"
#include "subcompositor_interface.h"
#include "tablet_interface.h"
......@@ -245,13 +244,6 @@ CompositorInterface *Display::createCompositor(QObject *parent)
return compositor;
}
ShellInterface *Display::createShell(QObject *parent)
{
ShellInterface *shell = new ShellInterface(this, parent);
connect(this, &Display::aboutToTerminate, shell, [shell] { delete shell; });
return shell;
}
OutputDeviceInterface *Display::createOutputDevice(QObject *parent)
{
OutputDeviceInterface *output = new OutputDeviceInterface(this, parent);
......
......@@ -55,7 +55,6 @@ class BlurManagerInterface;
class ContrastManagerInterface;
class ServerSideDecorationManagerInterface;
class SlideManagerInterface;
class ShellInterface;
class SubCompositorInterface;
enum class TextInputInterfaceVersion;
class TextInputManagerInterface;
......@@ -169,7 +168,6 @@ public:
CompositorInterface *createCompositor(QObject *parent = nullptr);
void createShm();
ShellInterface *createShell(QObject *parent = nullptr);
SeatInterface *createSeat(QObject *parent = nullptr);
/**
* @returns All SeatInterface currently managed on the Display.
......
/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "shell_interface.h"
#include "generic_shell_surface_p.h"
#include "global_p.h"
#include "resource_p.h"
#include "display.h"
#include "surface_interface.h"
#include <QTimer>
#include <wayland-server.h>
namespace KWaylandServer
{
class ShellInterface::Private : public Global::Private
{
public:
Private(ShellInterface *q, Display *d);
QList<ShellSurfaceInterface*> surfaces;
private:
static void createSurfaceCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface);
void bind(wl_client *client, uint32_t version, uint32_t id) override;
void createSurface(wl_client *client, uint32_t version, uint32_t id, SurfaceInterface *surface, wl_resource *parentResource);
ShellInterface *q;
static const struct wl_shell_interface s_interface;
static const quint32 s_version;
};
const quint32 ShellInterface::Private::s_version = 1;
ShellInterface::Private::Private(ShellInterface *q, Display *d)
: Global::Private(d, &wl_shell_interface, s_version)
, q(q)
{
}
#ifndef K_DOXYGEN
const struct wl_shell_interface ShellInterface::Private::s_interface = {
createSurfaceCallback
};
#endif
class ShellSurfaceInterface::Private : public Resource::Private, public GenericShellSurface<ShellSurfaceInterface>
{
public:
Private(ShellSurfaceInterface *q, ShellInterface *shell, SurfaceInterface *surface, wl_resource *parentResource);
void ping();
void commit() override;
QScopedPointer<QTimer> pingTimer;
quint32 pingSerial = 0;
enum class WindowMode {
Fullscreen,
Toplevel,
Maximized,
Popup
};
WindowMode windowMode = WindowMode::Toplevel;
QPoint transientOffset;
QPointer<SurfaceInterface> transientFor;
bool acceptsKeyboardFocus = true;
void setWindowMode(WindowMode newWindowMode);
ShellSurfaceInterface *q_func() {
return reinterpret_cast<ShellSurfaceInterface *>(q);
}
private:
// interface callbacks
static void pongCallback(wl_client *client, wl_resource *resource, uint32_t serial);
static void setToplevelCallback(wl_client *client, wl_resource *resource);
static void setTransientCallback(wl_client *client, wl_resource *resource, wl_resource *parent,
int32_t x, int32_t y, uint32_t flags);
static void setFullscreenCallback(wl_client *client, wl_resource *resource, uint32_t method,
uint32_t framerate, wl_resource *output);
static void setPopupCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial,
wl_resource *parent, int32_t x, int32_t y, uint32_t flags);
static void setMaximizedCallback(wl_client *client, wl_resource *resource, wl_resource *output);
void pong(quint32 serial);
void setAcceptsFocus(quint32 flags);
static const struct wl_shell_surface_interface s_interface;
};
ShellInterface::ShellInterface(Display *display, QObject *parent)
: Global(new Private(this, display), parent)
{
}
ShellInterface::~ShellInterface() = default;
void ShellInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
{
auto c = display->getConnection(client);
wl_resource *shell = c->createResource(&wl_shell_interface, qMin(version, s_version), id);
if (!shell) {
wl_client_post_no_memory(client);
return;
}
wl_resource_set_implementation(shell, &s_interface, this, nullptr);
}
void ShellInterface::Private::createSurfaceCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface)
{
auto s = reinterpret_cast<ShellInterface::Private*>(wl_resource_get_user_data(resource));
s->createSurface(client, wl_resource_get_version(resource), id, SurfaceInterface::get(surface), resource);
}
void ShellInterface::Private::createSurface(wl_client *client, uint32_t version, uint32_t id, SurfaceInterface *surface, wl_resource *parentResource)
{
auto it = std::find_if(surfaces.constBegin(), surfaces.constEnd(),
[surface](ShellSurfaceInterface *s) {
return surface == s->surface();
}
);
if (it != surfaces.constEnd()) {
wl_resource_post_error(surface->resource(), WL_SHELL_ERROR_ROLE, "ShellSurface already created");
return;
}
ShellSurfaceInterface *shellSurface = new ShellSurfaceInterface(q, surface, parentResource);
surfaces << shellSurface;
QObject::connect(shellSurface, &ShellSurfaceInterface::destroyed, q,
[this, shellSurface] {
surfaces.removeAll(shellSurface);
}
);
shellSurface->d->create(display->getConnection(client), version, id);
emit q->surfaceCreated(shellSurface);
}
/*********************************
* ShellSurfaceInterface
*********************************/
ShellSurfaceInterface::Private::Private(ShellSurfaceInterface *q, ShellInterface *shell, SurfaceInterface *surface, wl_resource *parentResource)
: Resource::Private(q, shell, parentResource, &wl_shell_surface_interface, &s_interface)
, GenericShellSurface<KWaylandServer::ShellSurfaceInterface>(q, surface)
, pingTimer(new QTimer)
{
pingTimer->setSingleShot(true);
pingTimer->setInterval(1000);
}
#ifndef K_DOXYGEN
const struct wl_shell_surface_interface ShellSurfaceInterface::Private::s_interface = {
pongCallback,
moveCallback,
resizeCallback<wl_shell_surface_resize>,
setToplevelCallback,
setTransientCallback,
setFullscreenCallback,
setPopupCallback,
setMaximizedCallback,
setTitleCallback,
setAppIdCallback
};
#endif
ShellSurfaceInterface::ShellSurfaceInterface(ShellInterface *shell, SurfaceInterface *parent, wl_resource *parentResource)
: Resource(new Private(this, shell, parent, parentResource))
{
Q_D();
connect(d->pingTimer.data(), &QTimer::timeout, this, &ShellSurfaceInterface::pingTimeout);
auto unsetSurface = [this] {
Q_D();
d->surface = nullptr;
};
connect(parent, &Resource::unbound, this, unsetSurface);
connect(parent, &QObject::destroyed, this, unsetSurface);
}
ShellSurfaceInterface::~ShellSurfaceInterface() = default;
void ShellSurfaceInterface::Private::commit()
{
}
void ShellSurfaceInterface::Private::pongCallback(wl_client *client, wl_resource *resource, uint32_t serial)
{
auto s = cast<Private>(resource);
Q_ASSERT(client == *s->client);
s->pong(serial);
}
void ShellSurfaceInterface::Private::pong(quint32 serial)
{
if (pingTimer->isAc