kwayland: remove orphaned patches

Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
This commit is contained in:
Andreas Müller
2021-03-06 15:35:45 +01:00
parent 56aad0b473
commit a51821c71d
4 changed files with 0 additions and 2661 deletions

View File

@@ -1,30 +0,0 @@
From da4f66eb232ab3b9dfc2e8c294358641d3ef1348 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
Date: Tue, 28 Apr 2015 14:38:24 +0200
Subject: [PATCH] do not perform runtime tests
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Upstream-Status: Inappropriate [embedded specific]
Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
---
CMakeLists.txt | 1 -
1 file changed, 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index ed3d185..08c56b8 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -51,7 +51,6 @@ if (IS_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/po")
endif()
add_subdirectory(src)
add_subdirectory(autotests)
-add_subdirectory(tests)
# create a Config.cmake and a ConfigVersion.cmake file and install them
set(CMAKECONFIG_INSTALL_DIR "${CMAKECONFIG_INSTALL_PREFIX}/KF5Wayland")
--
1.9.3

View File

@@ -1,654 +0,0 @@
From 7133d2781230b0a45e18c8c84a3b10b178cb16a6 Mon Sep 17 00:00:00 2001
From: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Date: Sun, 21 Sep 2014 12:25:53 +0200
Subject: [PATCH 3/4] PlasmaEffects interface
Conflicts:
src/client/CMakeLists.txt
src/client/registry.cpp
+ names of generated header changed
---
autotests/client/test_wayland_registry.cpp | 1 +
src/client/CMakeLists.txt | 7 +
src/client/plasma_effects.cpp | 319 +++++++++++++++++++++++++++++
src/client/plasma_effects.h | 102 +++++++++
src/client/registry.cpp | 24 +++
src/client/registry.h | 16 ++
6 files changed, 469 insertions(+)
create mode 100644 src/client/plasma_effects.cpp
create mode 100644 src/client/plasma_effects.h
diff --git a/autotests/client/test_wayland_registry.cpp b/autotests/client/test_wayland_registry.cpp
index 7004f5e..8eacd3c 100644
--- a/autotests/client/test_wayland_registry.cpp
+++ b/autotests/client/test_wayland_registry.cpp
@@ -238,6 +238,7 @@ void TestWaylandRegistry::testRemoval()
QVERIFY(registry.hasInterface(KWayland::Client::Registry::Interface::SubCompositor));
QVERIFY(!registry.hasInterface(KWayland::Client::Registry::Interface::FullscreenShell));
QVERIFY(!registry.hasInterface(KWayland::Client::Registry::Interface::PlasmaShell));
+ QVERIFY(!registry.hasInterface(KWayland::Client::Registry::Interface::PlasmaEffects));
QSignalSpy seatRemovedSpy(&registry, SIGNAL(seatRemoved(quint32)));
QVERIFY(seatRemovedSpy.isValid());
diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt
index b1dfe95..666fa52 100644
--- a/src/client/CMakeLists.txt
+++ b/src/client/CMakeLists.txt
@@ -16,6 +16,7 @@ set(CLIENT_LIB_SRCS
fullscreen_shell.cpp
keyboard.cpp
output.cpp
+ plasma_effects.cpp
plasma_shell.cpp
plasma_surface.cpp
pointer.cpp
@@ -39,6 +40,11 @@ ecm_add_wayland_client_protocol(CLIENT_LIB_SRCS
BASENAME plasma-shell
)
+ecm_add_wayland_client_protocol(CLIENT_LIB_SRCS
+ PROTOCOL ${KWAYLAND_SOURCE_DIR}/src/client/protocols/plasma-effects.xml
+ BASENAME plasma-effects
+)
+
add_library(KF5WaylandClient ${CLIENT_LIB_SRCS})
generate_export_header(KF5WaylandClient
BASE_NAME
@@ -81,6 +87,7 @@ install(FILES
fullscreen_shell.h
keyboard.h
output.h
+ plasma_effects.h
plasma_shell.h
plasma_surface.h
pointer.h
diff --git a/src/client/plasma_effects.cpp b/src/client/plasma_effects.cpp
new file mode 100644
index 0000000..61866a4
--- /dev/null
+++ b/src/client/plasma_effects.cpp
@@ -0,0 +1,319 @@
+/********************************************************************
+Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) version 3, or any
+later version accepted by the membership of KDE e.V. (or its
+successor approved by the membership of KDE e.V.), which shall
+act as a proxy defined in Section 6 of version 3 of the license.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+
+#include "output.h"
+#include "plasma_effects.h"
+#include "surface.h"
+
+// Qt
+#include <QtMath>
+#include <QVector>
+#include <QGuiApplication>
+#include <qpa/qplatformnativeinterface.h>
+#include <QWindow>
+
+// wayland
+#include <wayland-plasma-effects-client-protocol.h>
+#include <wayland-client-protocol.h>
+
+namespace KWayland
+{
+namespace Client
+{
+
+class PlasmaEffects::Private
+{
+public:
+ Private(PlasmaEffects *q);
+
+ void setup(org_kde_plasma_effects *e);
+
+ wl_region *createRegion(const QRegion &region);
+
+ org_kde_plasma_effects *effects = Q_NULLPTR;
+
+private:
+ PlasmaEffects *q;
+};
+
+PlasmaEffects::Private::Private(PlasmaEffects *q)
+ : q(q)
+{
+}
+
+void PlasmaEffects::Private::setup(org_kde_plasma_effects *e)
+{
+ Q_ASSERT(!effects);
+ Q_ASSERT(e);
+ effects = e;
+}
+
+wl_region *PlasmaEffects::Private::createRegion(const QRegion &region)
+{
+ // Platform native interface
+ QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
+ Q_ASSERT(native);
+
+ // Compositor
+ wl_compositor *compositor = static_cast<wl_compositor *>(
+ native->nativeResourceForIntegration("compositor"));
+ Q_ASSERT(compositor);
+
+ // Create wl_region
+ wl_region *wlRegion = wl_compositor_create_region(compositor);
+ Q_ASSERT(wlRegion);
+
+ for (QRect rect: region.rects())
+ wl_region_add(wlRegion, rect.x(), rect.y(), rect.width(), rect.height());
+
+ return wlRegion;
+}
+
+PlasmaEffects::PlasmaEffects(QObject *parent)
+ : QObject(parent)
+ , d(new Private(this))
+{
+}
+
+PlasmaEffects::~PlasmaEffects()
+{
+ release();
+}
+
+bool PlasmaEffects::isValid() const
+{
+ return d->effects != Q_NULLPTR;
+}
+
+void PlasmaEffects::setup(org_kde_plasma_effects *e)
+{
+ d->setup(e);
+}
+
+void PlasmaEffects::release()
+{
+ if (d->effects) {
+ org_kde_plasma_effects_destroy(d->effects);
+ }
+}
+
+void PlasmaEffects::destroy()
+{
+ if (d->effects) {
+ free(d->effects);
+ d->effects = Q_NULLPTR;
+ }
+}
+
+void PlasmaEffects::slide(wl_output *output, wl_surface *surface,
+ const Location &from, const QPoint &to)
+{
+ Q_ASSERT(d->effects);
+ Q_ASSERT(output);
+ Q_ASSERT(surface);
+
+ quint32 wlFrom = ORG_KDE_PLASMA_EFFECTS_LOCATION_NONE;
+ switch (from) {
+ case Location::Left:
+ wlFrom = ORG_KDE_PLASMA_EFFECTS_LOCATION_LEFT;
+ break;
+ case Location::Top:
+ wlFrom = ORG_KDE_PLASMA_EFFECTS_LOCATION_TOP;
+ break;
+ case Location::Right:
+ wlFrom = ORG_KDE_PLASMA_EFFECTS_LOCATION_RIGHT;
+ break;
+ case Location::Bottom:
+ wlFrom = ORG_KDE_PLASMA_EFFECTS_LOCATION_BOTTOM;
+ break;
+ default:
+ break;
+ }
+
+ org_kde_plasma_effects_slide(d->effects, output, surface,
+ wlFrom, to.x(), to.y());
+}
+
+void PlasmaEffects::slide(Output *output, Surface *surface,
+ const Location &from, const QPoint &to)
+{
+ Q_ASSERT(output);
+ Q_ASSERT(surface);
+
+ slide(*output, *surface, from, to);
+}
+
+void PlasmaEffects::slide(QWindow *window,
+ const Location &from, const QPoint &to)
+{
+ Q_ASSERT(window);
+
+ // Platform native interface
+ QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
+ Q_ASSERT(native);
+
+ // Get surface and output
+ wl_surface *wlSurface = static_cast<wl_surface *>(
+ native->nativeResourceForWindow("surface", window));
+ wl_output *wlOutput = static_cast<wl_output *>(
+ native->nativeResourceForScreen("output", window->screen()));
+
+ slide(wlOutput, wlSurface, from, to);
+}
+
+void PlasmaEffects::enableBlurBehind(wl_surface *surface,
+ const QRegion &region)
+{
+ Q_ASSERT(d->effects);
+ Q_ASSERT(surface);
+
+ wl_region *wlRegion = d->createRegion(region);
+ org_kde_plasma_effects_set_blur_behind_region(d->effects, surface, wlRegion);
+}
+
+void PlasmaEffects::enableBlurBehind(Surface *surface,
+ const QRegion &region)
+{
+ Q_ASSERT(surface);
+
+ enableBlurBehind(*surface, region);
+}
+
+void PlasmaEffects::enableBlurBehind(QWindow *window,
+ const QRegion &region)
+{
+ Q_ASSERT(window);
+
+ // Platform native interface
+ QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
+ Q_ASSERT(native);
+
+ // Get surface
+ wl_surface *wlSurface = static_cast<wl_surface *>(
+ native->nativeResourceForWindow("surface", window));
+
+ enableBlurBehind(wlSurface, region);
+}
+
+void PlasmaEffects::disableBlurBehind(wl_surface *surface)
+{
+ Q_ASSERT(d->effects);
+ Q_ASSERT(surface);
+
+ org_kde_plasma_effects_set_blur_behind_region(d->effects, surface, Q_NULLPTR);
+}
+
+void PlasmaEffects::disableBlurBehind(Surface *surface)
+{
+ Q_ASSERT(surface);
+
+ disableBlurBehind(*surface);
+}
+
+void PlasmaEffects::disableBlurBehind(QWindow *window)
+{
+ Q_ASSERT(window);
+
+ // Platform native interface
+ QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
+ Q_ASSERT(native);
+
+ // Get surface
+ wl_surface *wlSurface = static_cast<wl_surface *>(
+ native->nativeResourceForWindow("surface", window));
+
+ disableBlurBehind(wlSurface);
+}
+
+void PlasmaEffects::enableBackgroundContrast(wl_surface *surface, const QRegion &region,
+ qreal contrast, qreal intensity,
+ qreal saturation)
+{
+ Q_ASSERT(d->effects);
+ Q_ASSERT(surface);
+
+ wl_region *wlRegion = d->createRegion(region);
+ org_kde_plasma_effects_set_contrast_region(d->effects, surface, wlRegion,
+ contrast, intensity, saturation);
+}
+
+void PlasmaEffects::enableBackgroundContrast(Surface *surface, const QRegion &region,
+ qreal contrast, qreal intensity,
+ qreal saturation)
+{
+ Q_ASSERT(surface);
+
+ // Convert values to integers
+ quint32 c = qFloor(contrast * 255);
+ quint32 i = qFloor(intensity * 255);
+ quint32 s = qFloor(saturation * 255);
+
+ enableBackgroundContrast(*surface, region, c, i, s);
+}
+
+void PlasmaEffects::enableBackgroundContrast(QWindow *window, const QRegion &region,
+ qreal contrast, qreal intensity,
+ qreal saturation)
+{
+ Q_ASSERT(window);
+
+ // Platform native interface
+ QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
+ Q_ASSERT(native);
+
+ // Get surface
+ wl_surface *wlSurface = static_cast<wl_surface *>(
+ native->nativeResourceForWindow("surface", window));
+
+ enableBackgroundContrast(wlSurface, region, contrast, intensity, saturation);
+}
+
+void PlasmaEffects::disableBackgroundContrast(wl_surface *surface)
+{
+ Q_ASSERT(d->effects);
+ Q_ASSERT(surface);
+
+ org_kde_plasma_effects_set_contrast_region(d->effects, surface, Q_NULLPTR, 0, 0, 0);
+}
+
+void PlasmaEffects::disableBackgroundContrast(Surface *surface)
+{
+ Q_ASSERT(surface);
+
+ disableBackgroundContrast(*surface);
+}
+
+void PlasmaEffects::disableBackgroundContrast(QWindow *window)
+{
+ Q_ASSERT(window);
+
+ // Platform native interface
+ QPlatformNativeInterface *native = QGuiApplication::platformNativeInterface();
+ Q_ASSERT(native);
+
+ // Get surface
+ wl_surface *wlSurface = static_cast<wl_surface *>(
+ native->nativeResourceForWindow("surface", window));
+
+ disableBackgroundContrast(wlSurface);
+}
+
+} // namespace Client
+} // namespace KWayland
diff --git a/src/client/plasma_effects.h b/src/client/plasma_effects.h
new file mode 100644
index 0000000..9a1e89d
--- /dev/null
+++ b/src/client/plasma_effects.h
@@ -0,0 +1,102 @@
+/********************************************************************
+Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) version 3, or any
+later version accepted by the membership of KDE e.V. (or its
+successor approved by the membership of KDE e.V.), which shall
+act as a proxy defined in Section 6 of version 3 of the license.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+
+#ifndef WAYLAND_PLASMA_EFFECTS_H
+#define WAYLAND_PLASMA_EFFECTS_H
+
+#include <QObject>
+#include <QRegion>
+
+#include <KWayland/Client/kwaylandclient_export.h>
+
+class QWindow;
+
+struct wl_output;
+struct wl_surface;
+struct org_kde_plasma_effects;
+
+namespace KWayland
+{
+namespace Client
+{
+
+class Output;
+class Surface;
+
+class KWAYLANDCLIENT_EXPORT PlasmaEffects : public QObject
+{
+ Q_OBJECT
+public:
+ enum class Location {
+ None,
+ Left,
+ Top,
+ Right,
+ Bottom
+ };
+
+ explicit PlasmaEffects(QObject *parent = Q_NULLPTR);
+ virtual ~PlasmaEffects();
+
+ bool isValid() const;
+
+ void setup(org_kde_plasma_effects *s);
+
+ void release();
+ void destroy();
+
+ void slide(wl_output *output, wl_surface *surface,
+ const Location &from, const QPoint &to);
+ void slide(Output *output, Surface *surface,
+ const Location &from, const QPoint &to);
+ void slide(QWindow *window,
+ const Location &from, const QPoint &to);
+
+ void enableBlurBehind(wl_surface *surface,
+ const QRegion &region);
+ void enableBlurBehind(Surface *surface,
+ const QRegion &region);
+ void enableBlurBehind(QWindow *window,
+ const QRegion &region);
+
+ void disableBlurBehind(wl_surface *surface);
+ void disableBlurBehind(Surface *surface);
+ void disableBlurBehind(QWindow *window);
+
+ void enableBackgroundContrast(wl_surface *surface, const QRegion &region,
+ qreal contrast, qreal intensity, qreal saturation);
+ void enableBackgroundContrast(Surface *surface, const QRegion &region,
+ qreal contrast, qreal intensity, qreal saturation);
+ void enableBackgroundContrast(QWindow *window, const QRegion &region,
+ qreal contrast, qreal intensity, qreal saturation);
+
+ void disableBackgroundContrast(wl_surface *surface);
+ void disableBackgroundContrast(Surface *surface);
+ void disableBackgroundContrast(QWindow *window);
+
+private:
+ class Private;
+ QScopedPointer<Private> d;
+};
+
+} // namespace Client
+} // namespace KWayland
+
+#endif // WAYLAND_PLASMA_EFFECTS_H
diff --git a/src/client/registry.cpp b/src/client/registry.cpp
index 192af78..541b1c5 100644
--- a/src/client/registry.cpp
+++ b/src/client/registry.cpp
@@ -24,6 +24,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include "event_queue.h"
#include "fullscreen_shell.h"
#include "output.h"
+#include "plasma_effects.h"
#include "plasma_shell.h"
#include "seat.h"
#include "shell.h"
@@ -36,6 +37,7 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <wayland-client-protocol.h>
#include <wayland-fullscreen-shell-client-protocol.h>
#include <wayland-plasma-shell-client-protocol.h>
+#include <wayland-plasma-effects-client-protocol.h>
namespace KWayland
{
@@ -215,6 +217,8 @@ static Registry::Interface nameToInterface(const char *interface)
return Registry::Interface::DataDeviceManager;
} else if (strcmp(interface, "org_kde_plasma_shell") == 0) {
return Registry::Interface::PlasmaShell;
+ } else if (strcmp(interface, "org_kde_plasma_effects") == 0) {
+ return Registry::Interface::PlasmaEffects;
}
return Registry::Interface::Unknown;
}
@@ -257,6 +261,9 @@ void Registry::Private::handleAnnounce(uint32_t name, const char *interface, uin
case Interface::PlasmaShell:
emit q->plasmaShellAnnounced(name, version);
break;
+ case Interface::PlasmaEffects:
+ emit q->plasmaEffectsAnnounced(name, version);
+ break;
case Interface::Unknown:
default:
// nothing
@@ -302,6 +309,9 @@ void Registry::Private::handleRemove(uint32_t name)
case Interface::PlasmaShell:
emit q->plasmaShellRemoved(data.name);
break;
+ case Interface::PlasmaEffects:
+ emit q->plasmaEffectsRemoved(data.name);
+ break;
case Interface::Unknown:
default:
// nothing
@@ -371,6 +381,11 @@ wl_data_device_manager *Registry::bindDataDeviceManager(uint32_t name, uint32_t
return d->bind<wl_data_device_manager>(Interface::DataDeviceManager, name, qMin(s_dataDeviceManagerMaxVersion, version));
}
+org_kde_plasma_effects *Registry::bindPlasmaEffects(uint32_t name, uint32_t version) const
+{
+ return d->bind<org_kde_plasma_effects>(Interface::PlasmaEffects, name, version);
+}
+
Compositor *Registry::createCompositor(quint32 name, quint32 version, QObject *parent)
{
Compositor *c = new Compositor(parent);
@@ -440,6 +455,13 @@ PlasmaShell *Registry::createPlasmaShell(quint32 name, quint32 version, QObject
return s;
}
+PlasmaEffects *Registry::createPlasmaEffects(quint32 name, quint32 version, QObject *parent)
+{
+ PlasmaEffects *e = new PlasmaEffects(parent);
+ e->setup(bindPlasmaEffects(name, version));
+ return e;
+}
+
static const wl_interface *wlInterface(Registry::Interface interface)
{
switch (interface) {
@@ -461,6 +483,8 @@ static const wl_interface *wlInterface(Registry::Interface interface)
return &wl_data_device_manager_interface;
case Registry::Interface::PlasmaShell:
return &org_kde_plasma_shell_interface;
+ case Registry::Interface::PlasmaEffects:
+ return &org_kde_plasma_effects_interface;
case Registry::Interface::Unknown:
default:
return nullptr;
diff --git a/src/client/registry.h b/src/client/registry.h
index 5fbb499..5ef2b97 100644
--- a/src/client/registry.h
+++ b/src/client/registry.h
@@ -36,6 +36,7 @@ struct wl_shm;
struct wl_subcompositor;
struct _wl_fullscreen_shell;
struct org_kde_plasma_shell;
+struct org_kde_plasma_effects;
namespace KWayland
{
@@ -48,6 +49,7 @@ class DataDeviceManager;
class EventQueue;
class FullscreenShell;
class Output;
+class PlasmaEffects;
class PlasmaShell;
class Seat;
class Shell;
@@ -95,6 +97,7 @@ public:
Seat, ///< Refers to the wl_seat interface
Shm, ///< Refers to the wl_shm interface
Output, ///< Refers to the wl_output interface
+ PlasmaEffects, ///< Refers to the org_kde_plasma_effects interface
PlasmaShell, ///< Refers to the org_kde_plasma_shell interface
FullscreenShell, ///< Refers to the _wl_fullscreen_shell interface
SubCompositor, ///< Refers to the wl_subcompositor interface;
@@ -231,6 +234,7 @@ public:
_wl_fullscreen_shell *bindFullscreenShell(uint32_t name, uint32_t version) const;
wl_data_device_manager *bindDataDeviceManager(uint32_t name, uint32_t version) const;
org_kde_plasma_shell *bindPlasmaShell(uint32_t name, uint32_t version) const;
+ org_kde_plasma_effects *bindPlasmaEffects(uint32_t name, uint32_t version) const;
/**
* Creates a Compositor and sets it up to manage the interface identified by
@@ -339,6 +343,7 @@ public:
FullscreenShell *createFullscreenShell(quint32 name, quint32 version, QObject *parent = nullptr);
DataDeviceManager *createDataDeviceManager(quint32 name, quint32 version, QObject *parent = nullptr);
PlasmaShell *createPlasmaShell(quint32 name, quint32 version, QObject *parent = nullptr);
+ PlasmaEffects *createPlasmaEffects(quint32 name, quint32 version, QObject *parent = nullptr);
operator wl_registry*();
operator wl_registry*() const;
@@ -382,6 +387,12 @@ Q_SIGNALS:
**/
void outputAnnounced(quint32 name, quint32 version);
/**
+ * Emitted whenever a org_kde_plasma_effects interface gets announced.
+ * @param name The name for the announced interface
+ * @param version The maximum supported version of the announced interface
+ **/
+ void plasmaEffectsAnnounced(quint32 name, quint32 version);
+ /**
* Emitted whenever a org_kde_plasma_shell interface gets announced.
* @param name The name for the announced interface
* @param version The maximum supported version of the announced interface
@@ -425,6 +436,11 @@ Q_SIGNALS:
**/
void outputRemoved(quint32 name);
/**
+ * Emitted whenever a org_kde_plasma_effects interface gets removed.
+ * @param name The name for the removed interface
+ **/
+ void plasmaEffectsRemoved(quint32 name);
+ /**
* Emitted whenever a org_kde_plasma_shell interface gets removed.
* @param name The name for the removed interface
**/
--
1.8.3.1

View File

@@ -1,845 +0,0 @@
From 690e2b1ae73ca69a14e111a779cae571a8fcf616 Mon Sep 17 00:00:00 2001
From: Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
Date: Fri, 17 Oct 2014 09:06:04 +0200
Subject: [PATCH 4/4] Server side interface
Conflicts:
src/server/CMakeLists.txt
+ names/loactions of generated header changed
---
autotests/client/test_plasma_shell.cpp | 358 +++++++++++++++++++++++++++++++++
src/server/CMakeLists.txt | 7 +
src/server/plasma_shell_interface.cpp | 331 ++++++++++++++++++++++++++++++
src/server/plasma_shell_interface.h | 84 ++++++++
4 files changed, 780 insertions(+)
create mode 100644 autotests/client/test_plasma_shell.cpp
create mode 100644 src/server/plasma_shell_interface.cpp
create mode 100644 src/server/plasma_shell_interface.h
diff --git a/autotests/client/test_plasma_shell.cpp b/autotests/client/test_plasma_shell.cpp
new file mode 100644
index 0000000..c9257ce
--- /dev/null
+++ b/autotests/client/test_plasma_shell.cpp
@@ -0,0 +1,358 @@
+/********************************************************************
+Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) version 3, or any
+later version accepted by the membership of KDE e.V. (or its
+successor approved by the membership of KDE e.V.), which shall
+act as a proxy defined in Section 6 of version 3 of the license.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+// Qt
+#include <QtTest/QtTest>
+// KWin
+#include "../../src/client/compositor.h"
+#include "../../src/client/connection_thread.h"
+#include "../../src/client/event_queue.h"
+#include "../../src/client/shell.h"
+#include "../../src/client/surface.h"
+#include "../../src/client/registry.h"
+#include "../../src/server/buffer_interface.h"
+#include "../../src/server/compositor_interface.h"
+#include "../../src/server/display.h"
+#include "../../src/server/shell_interface.h"
+#include "../../src/server/surface_interface.h"
+// Wayland
+#include <wayland-client-protocol.h>
+
+class TestPlasmaShell : public QObject
+{
+ Q_OBJECT
+public:
+ explicit TestPlasmaShell(QObject *parent = nullptr);
+private Q_SLOTS:
+ void init();
+ void cleanup();
+
+ void testFullscreen();
+ void testPing();
+ void testTitle();
+ void testWindowClass();
+ void testDestroy();
+ void testCast();
+
+private:
+ KWayland::Server::Display *m_display;
+ KWayland::Server::CompositorInterface *m_compositorInterface;
+ KWayland::Server::ShellInterface *m_shellInterface;
+ KWayland::Client::ConnectionThread *m_connection;
+ KWayland::Client::Compositor *m_compositor;
+ KWayland::Client::Shell *m_shell;
+ KWayland::Client::EventQueue *m_queue;
+ QThread *m_thread;
+};
+
+static const QString s_socketName = QStringLiteral("kwin-test-plasma-shell-0");
+
+TestPlasmaShell::TestPlasmaShell(QObject *parent)
+ : QObject(parent)
+ , m_display(nullptr)
+ , m_compositorInterface(nullptr)
+ , m_shellInterface(nullptr)
+ , m_connection(nullptr)
+ , m_compositor(nullptr)
+ , m_shell(nullptr)
+ , m_queue(nullptr)
+ , m_thread(nullptr)
+{
+}
+
+void TestPlasmaShell::init()
+{
+ using namespace KWayland::Server;
+ delete m_display;
+ m_display = new Display(this);
+ m_display->setSocketName(s_socketName);
+ m_display->start();
+ QVERIFY(m_display->isRunning());
+
+ m_compositorInterface = m_display->createCompositor(m_display);
+ QVERIFY(m_compositorInterface);
+ m_compositorInterface->create();
+ QVERIFY(m_compositorInterface->isValid());
+
+ m_shellInterface = m_display->createShell(m_display);
+ QVERIFY(m_shellInterface);
+ m_shellInterface->create();
+ QVERIFY(m_shellInterface->isValid());
+
+ // setup connection
+ m_connection = new KWayland::Client::ConnectionThread;
+ QSignalSpy connectedSpy(m_connection, SIGNAL(connected()));
+ m_connection->setSocketName(s_socketName);
+
+ m_thread = new QThread(this);
+ m_connection->moveToThread(m_thread);
+ m_thread->start();
+
+ m_connection->initConnection();
+ QVERIFY(connectedSpy.wait());
+
+ m_queue = new KWayland::Client::EventQueue(this);
+ QVERIFY(!m_queue->isValid());
+ m_queue->setup(m_connection);
+ QVERIFY(m_queue->isValid());
+
+ KWayland::Client::Registry registry;
+ QSignalSpy compositorSpy(&registry, SIGNAL(compositorAnnounced(quint32,quint32)));
+ QSignalSpy shellSpy(&registry, SIGNAL(shellAnnounced(quint32,quint32)));
+ QVERIFY(!registry.eventQueue());
+ registry.setEventQueue(m_queue);
+ QCOMPARE(registry.eventQueue(), m_queue);
+ registry.create(m_connection->display());
+ QVERIFY(registry.isValid());
+ registry.setup();
+ QVERIFY(compositorSpy.wait());
+
+ m_compositor = new KWayland::Client::Compositor(this);
+ m_compositor->setup(registry.bindCompositor(compositorSpy.first().first().value<quint32>(), compositorSpy.first().last().value<quint32>()));
+ QVERIFY(m_compositor->isValid());
+
+ if (shellSpy.isEmpty()) {
+ QVERIFY(shellSpy.wait());
+ }
+ m_shell = registry.createShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>(), this);
+ QVERIFY(m_shell->isValid());
+}
+
+void TestPlasmaShell::cleanup()
+{
+ if (m_shell) {
+ delete m_shell;
+ m_shell = nullptr;
+ }
+ if (m_compositor) {
+ delete m_compositor;
+ m_compositor = nullptr;
+ }
+ if (m_queue) {
+ delete m_queue;
+ m_queue = nullptr;
+ }
+ if (m_connection) {
+ m_connection->deleteLater();
+ m_connection = nullptr;
+ }
+ if (m_thread) {
+ m_thread->quit();
+ m_thread->wait();
+ delete m_thread;
+ m_thread = nullptr;
+ }
+
+ delete m_shellInterface;
+ m_shellInterface = nullptr;
+
+ delete m_compositorInterface;
+ m_compositorInterface = nullptr;
+
+ delete m_display;
+ m_display = nullptr;
+}
+
+void TestPlasmaShell::testFullscreen()
+{
+ using namespace KWayland::Server;
+ QScopedPointer<KWayland::Client::Surface> s(m_compositor->createSurface());
+ QVERIFY(!s.isNull());
+ QVERIFY(s->isValid());
+ KWayland::Client::ShellSurface *surface = m_shell->createSurface(s.data(), m_shell);
+ QSignalSpy sizeSpy(surface, SIGNAL(sizeChanged(QSize)));
+ QVERIFY(sizeSpy.isValid());
+ QCOMPARE(surface->size(), QSize());
+
+ QSignalSpy serverSurfaceSpy(m_shellInterface, SIGNAL(surfaceCreated(KWayland::Server::ShellSurfaceInterface*)));
+ QVERIFY(serverSurfaceSpy.isValid());
+ QVERIFY(serverSurfaceSpy.wait());
+ ShellSurfaceInterface *serverSurface = serverSurfaceSpy.first().first().value<ShellSurfaceInterface*>();
+ QVERIFY(serverSurface);
+
+ QSignalSpy fullscreenSpy(serverSurface, SIGNAL(fullscreenChanged(bool)));
+ QVERIFY(fullscreenSpy.isValid());
+
+ surface->setFullscreen();
+ QVERIFY(fullscreenSpy.wait());
+ QCOMPARE(fullscreenSpy.count(), 1);
+ QVERIFY(fullscreenSpy.first().first().toBool());
+ serverSurface->requestSize(QSize(1024, 768));
+
+ QVERIFY(sizeSpy.wait());
+ QCOMPARE(sizeSpy.count(), 1);
+ QCOMPARE(sizeSpy.first().first().toSize(), QSize(1024, 768));
+ QCOMPARE(surface->size(), QSize(1024, 768));
+
+ // set back to toplevel
+ fullscreenSpy.clear();
+ wl_shell_surface_set_toplevel(*surface);
+ QVERIFY(fullscreenSpy.wait());
+ QCOMPARE(fullscreenSpy.count(), 1);
+ QVERIFY(!fullscreenSpy.first().first().toBool());
+}
+
+void TestPlasmaShell::testPing()
+{
+ using namespace KWayland::Server;
+ QScopedPointer<KWayland::Client::Surface> s(m_compositor->createSurface());
+ QVERIFY(!s.isNull());
+ QVERIFY(s->isValid());
+ KWayland::Client::ShellSurface *surface = m_shell->createSurface(s.data(), m_shell);
+ QSignalSpy pingSpy(surface, SIGNAL(pinged()));
+
+ QSignalSpy serverSurfaceSpy(m_shellInterface, SIGNAL(surfaceCreated(KWayland::Server::ShellSurfaceInterface*)));
+ QVERIFY(serverSurfaceSpy.isValid());
+ QVERIFY(serverSurfaceSpy.wait());
+ ShellSurfaceInterface *serverSurface = serverSurfaceSpy.first().first().value<ShellSurfaceInterface*>();
+ QVERIFY(serverSurface);
+
+ QSignalSpy pingTimeoutSpy(serverSurface, SIGNAL(pingTimeout()));
+ QVERIFY(pingTimeoutSpy.isValid());
+ QSignalSpy pongSpy(serverSurface, SIGNAL(pongReceived()));
+ QVERIFY(pongSpy.isValid());
+
+ serverSurface->ping();
+ QVERIFY(pingSpy.wait());
+ wl_display_flush(m_connection->display());
+
+ if (pongSpy.isEmpty()) {
+ QVERIFY(pongSpy.wait());
+ }
+ QVERIFY(!pongSpy.isEmpty());
+ QVERIFY(pingTimeoutSpy.isEmpty());
+
+ // evil trick - timeout of zero will make it not get the pong
+ serverSurface->setPingTimeout(0);
+ pongSpy.clear();
+ pingTimeoutSpy.clear();
+ serverSurface->ping();
+ QTest::qWait(100);
+ if (pingTimeoutSpy.isEmpty()) {
+ QVERIFY(pingTimeoutSpy.wait());
+ }
+ QCOMPARE(pingTimeoutSpy.count(), 1);
+ QVERIFY(pongSpy.isEmpty());
+}
+
+void TestPlasmaShell::testTitle()
+{
+ using namespace KWayland::Server;
+ QScopedPointer<KWayland::Client::Surface> s(m_compositor->createSurface());
+ QVERIFY(!s.isNull());
+ QVERIFY(s->isValid());
+ KWayland::Client::ShellSurface *surface = m_shell->createSurface(s.data(), m_shell);
+
+ QSignalSpy serverSurfaceSpy(m_shellInterface, SIGNAL(surfaceCreated(KWayland::Server::ShellSurfaceInterface*)));
+ QVERIFY(serverSurfaceSpy.isValid());
+ QVERIFY(serverSurfaceSpy.wait());
+ ShellSurfaceInterface *serverSurface = serverSurfaceSpy.first().first().value<ShellSurfaceInterface*>();
+ QVERIFY(serverSurface);
+
+ QSignalSpy titleSpy(serverSurface, SIGNAL(titleChanged(QString)));
+ QVERIFY(titleSpy.isValid());
+ QString testTitle = QStringLiteral("fooBar");
+ QVERIFY(serverSurface->title().isNull());
+
+ wl_shell_surface_set_title(*(const KWayland::Client::ShellSurface *)surface, testTitle.toUtf8().constData());
+ QVERIFY(titleSpy.wait());
+ QCOMPARE(serverSurface->title(), testTitle);
+ QCOMPARE(titleSpy.first().first().toString(), testTitle);
+}
+
+void TestPlasmaShell::testWindowClass()
+{
+ using namespace KWayland::Server;
+ QScopedPointer<KWayland::Client::Surface> s(m_compositor->createSurface());
+ QVERIFY(!s.isNull());
+ QVERIFY(s->isValid());
+ KWayland::Client::ShellSurface *surface = m_shell->createSurface(s.data(), m_shell);
+
+ QSignalSpy serverSurfaceSpy(m_shellInterface, SIGNAL(surfaceCreated(KWayland::Server::ShellSurfaceInterface*)));
+ QVERIFY(serverSurfaceSpy.isValid());
+ QVERIFY(serverSurfaceSpy.wait());
+ ShellSurfaceInterface *serverSurface = serverSurfaceSpy.first().first().value<ShellSurfaceInterface*>();
+ QVERIFY(serverSurface);
+
+ QSignalSpy windowClassSpy(serverSurface, SIGNAL(windowClassChanged(QByteArray)));
+ QVERIFY(windowClassSpy.isValid());
+ QByteArray testClass = QByteArrayLiteral("fooBar");
+ QVERIFY(serverSurface->windowClass().isNull());
+
+ wl_shell_surface_set_class(*surface, testClass.constData());
+ QVERIFY(windowClassSpy.wait());
+ QCOMPARE(serverSurface->windowClass(), testClass);
+ QCOMPARE(windowClassSpy.first().first().toByteArray(), testClass);
+}
+
+void TestPlasmaShell::testDestroy()
+{
+ using namespace KWayland::Client;
+ QScopedPointer<Surface> s(m_compositor->createSurface());
+ QVERIFY(!s.isNull());
+ QVERIFY(s->isValid());
+ ShellSurface *surface = m_shell->createSurface(s.data(), m_shell);
+ QVERIFY(surface->isValid());
+
+ connect(m_connection, &ConnectionThread::connectionDied, m_shell, &Shell::destroy);
+ connect(m_connection, &ConnectionThread::connectionDied, m_compositor, &Compositor::destroy);
+ connect(m_connection, &ConnectionThread::connectionDied, s.data(), &Surface::destroy);
+ connect(m_connection, &ConnectionThread::connectionDied, m_queue, &EventQueue::destroy);
+
+ QSignalSpy connectionDiedSpy(m_connection, SIGNAL(connectionDied()));
+ QVERIFY(connectionDiedSpy.isValid());
+ delete m_display;
+ m_display = nullptr;
+ m_compositorInterface = nullptr;
+ m_shellInterface = nullptr;
+ QVERIFY(connectionDiedSpy.wait());
+
+ QVERIFY(!m_shell->isValid());
+ QVERIFY(!surface->isValid());
+
+ m_shell->destroy();
+ surface->destroy();
+}
+
+void TestPlasmaShell::testCast()
+{
+ using namespace KWayland::Client;
+ Registry registry;
+ QSignalSpy shellSpy(&registry, SIGNAL(shellAnnounced(quint32,quint32)));
+ registry.setEventQueue(m_queue);
+ registry.create(m_connection->display());
+ QVERIFY(registry.isValid());
+ registry.setup();
+ QVERIFY(shellSpy.wait());
+
+ Shell s;
+ auto wlShell = registry.bindShell(shellSpy.first().first().value<quint32>(), shellSpy.first().last().value<quint32>());
+ m_queue->addProxy(wlShell);
+ QVERIFY(wlShell);
+ QVERIFY(!s.isValid());
+ s.setup(wlShell);
+ QVERIFY(s.isValid());
+ QCOMPARE((wl_shell*)s, wlShell);
+
+ const Shell &s2(s);
+ QCOMPARE((wl_shell*)s2, wlShell);
+}
+
+QTEST_GUILESS_MAIN(TestPlasmaShell)
+#include "test_plasma_shell.moc"
diff --git a/src/server/CMakeLists.txt b/src/server/CMakeLists.txt
index 8363c37..4a0d895 100644
--- a/src/server/CMakeLists.txt
+++ b/src/server/CMakeLists.txt
@@ -7,6 +7,7 @@ set(SERVER_LIB_SRCS
dataoffer_interface.cpp
datasource_interface.cpp
display.cpp
+ plasma_shell_interface.cpp
global.cpp
keyboard_interface.cpp
output_interface.cpp
@@ -19,6 +20,11 @@ set(SERVER_LIB_SRCS
subcompositor_interface.cpp
)
+ecm_add_wayland_server_protocol(SERVER_LIB_SRCS
+ PROTOCOL ${KWAYLAND_SOURCE_DIR}//src/client/protocols/plasma-shell.xml
+ BASENAME plasma-shell
+)
+
add_library(KF5WaylandServer ${SERVER_LIB_SRCS})
generate_export_header(KF5WaylandServer
BASE_NAME
@@ -60,6 +66,7 @@ install(FILES
dataoffer_interface.h
datasource_interface.h
display.h
+ plasma_shell_interface.h
global.h
keyboard_interface.h
output_interface.h
diff --git a/src/server/plasma_shell_interface.cpp b/src/server/plasma_shell_interface.cpp
new file mode 100644
index 0000000..dfe6b2d
--- /dev/null
+++ b/src/server/plasma_shell_interface.cpp
@@ -0,0 +1,331 @@
+/********************************************************************
+Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) version 3, or any
+later version accepted by the membership of KDE e.V. (or its
+successor approved by the membership of KDE e.V.), which shall
+act as a proxy defined in Section 6 of version 3 of the license.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+#include "plasma_shell_interface.h"
+#include "display.h"
+#include "surface_interface.h"
+#include "output_interface.h"
+
+#include <QTimer>
+
+#include <wayland-server.h>
+#include "wayland-plasma-shell-server-protocol.h"
+
+namespace KWayland
+{
+namespace Server
+{
+
+static const quint32 s_version = 1;
+
+class PlasmaShellInterface::Private
+{
+public:
+ Private(PlasmaShellInterface *q, Display *d);
+ void create();
+
+ Display *display;
+ wl_global *shell = nullptr;
+ QList<PlasmaSurfaceInterface*> surfaces;
+
+private:
+ static void bind(wl_client *client, void *data, uint32_t version, uint32_t id);
+ static void createSurfaceCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface);
+ static void desktopReadyCallback(wl_client *client, wl_resource *resource);
+ static void presentCallback(wl_client *client, wl_resource *resource, wl_array *surfaces);
+ void bind(wl_client *client, uint32_t version, uint32_t id);
+ void createSurface(wl_client *client, uint32_t version, uint32_t id, SurfaceInterface *surface);
+ void desktopReady(wl_client *client);
+ void present(wl_client *client, wl_array *surfaces);
+
+ PlasmaShellInterface *q;
+ static const struct org_kde_plasma_shell_interface s_interface;
+};
+
+PlasmaShellInterface::Private::Private(PlasmaShellInterface *q, Display *d)
+ : display(d)
+ , q(q)
+{
+}
+
+void PlasmaShellInterface::Private::create()
+{
+ Q_ASSERT(!shell);
+ shell = wl_global_create(*display, &org_kde_plasma_shell_interface, s_version, this, &bind);
+}
+
+const struct org_kde_plasma_shell_interface PlasmaShellInterface::Private::s_interface = {
+ createSurfaceCallback,
+ desktopReadyCallback,
+ presentCallback
+};
+
+
+
+class PlasmaSurfaceInterface::Private
+{
+public:
+ Private(PlasmaSurfaceInterface *q, PlasmaShellInterface *shell, SurfaceInterface *surface);
+ void create(wl_client *client, quint32 version, quint32 id);
+
+ SurfaceInterface *surface;
+ PlasmaShellInterface *shell;
+ wl_resource *shellSurface = nullptr;
+ wl_client *client = nullptr;
+
+private:
+ static Private *cast(wl_resource *r) {
+ return reinterpret_cast<Private*>(wl_resource_get_user_data(r));
+ }
+
+ static void unbind(wl_resource *r);
+ // interface callbacks
+ static void destroyCallback(wl_client *client, wl_resource *resource);
+ static void setOutputCallback(wl_client *client, wl_resource *resource, wl_resource *output);
+ static void setPositionCallback(wl_client *client, wl_resource *resource,
+ int32_t x, int32_t y);
+ static void setRoleCallback(wl_client *client, wl_resource *resource, uint32_t role);
+ static void setFlagsCallback(wl_client *client, wl_resource *resource, uint32_t flags);
+ static void setScreenEdgeCallback(wl_client *client, wl_resource *resource, uint32_t edge);
+
+ PlasmaSurfaceInterface *q;
+ static const struct org_kde_plasma_surface_interface s_interface;
+};
+
+PlasmaShellInterface::PlasmaShellInterface(Display *display, QObject *parent)
+ : QObject(parent)
+ , d(new Private(this, display))
+{
+}
+
+PlasmaShellInterface::~PlasmaShellInterface()
+{
+ destroy();
+}
+
+void PlasmaShellInterface::create()
+{
+ d->create();
+}
+
+void PlasmaShellInterface::destroy()
+{
+ if (!d->shell) {
+ return;
+ }
+ wl_global_destroy(d->shell);
+ d->shell = nullptr;
+}
+
+void PlasmaShellInterface::Private::bind(wl_client *client, void *data, uint32_t version, uint32_t id)
+{
+ reinterpret_cast<PlasmaShellInterface::Private*>(data)->bind(client, version, id);
+}
+
+void PlasmaShellInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
+{
+ wl_resource *shell = wl_resource_create(client, &org_kde_plasma_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 PlasmaShellInterface::Private::createSurfaceCallback(wl_client *client, wl_resource *resource, uint32_t id, wl_resource *surface)
+{
+ auto s = reinterpret_cast<PlasmaShellInterface::Private*>(wl_resource_get_user_data(resource));
+ s->createSurface(client, wl_resource_get_version(resource), id, SurfaceInterface::get(surface));
+}
+
+void PlasmaShellInterface::Private::createSurface(wl_client *client, uint32_t version, uint32_t id, SurfaceInterface *surface)
+{
+ auto it = std::find_if(surfaces.constBegin(), surfaces.constEnd(),
+ [surface](PlasmaSurfaceInterface *s) {
+ return surface == s->surface();
+ }
+ );
+ if (it != surfaces.constEnd()) {
+ wl_resource_post_error(surface->resource(), WL_DISPLAY_ERROR_INVALID_OBJECT, "PlasmaSurface already created");
+ return;
+ }
+ PlasmaSurfaceInterface *shellSurface = new PlasmaSurfaceInterface(q, surface);
+ surfaces << shellSurface;
+ QObject::connect(shellSurface, &PlasmaSurfaceInterface::destroyed, q,
+ [this, shellSurface] {
+ surfaces.removeAll(shellSurface);
+ }
+ );
+ shellSurface->d->create(client, version, id);
+ emit q->surfaceCreated(shellSurface);
+}
+
+void PlasmaShellInterface::Private::desktopReadyCallback(wl_client *client, wl_resource *resource)
+{
+ auto s = reinterpret_cast<PlasmaShellInterface::Private*>(wl_resource_get_user_data(resource));
+ s->desktopReady(client);
+}
+
+void PlasmaShellInterface::Private::desktopReady(wl_client *client)
+{
+ Q_UNUSED(client);
+ emit q->ready();
+}
+
+void PlasmaShellInterface::Private::presentCallback(wl_client *client, wl_resource *resource, wl_array *surfaces)
+{
+ auto s = reinterpret_cast<PlasmaShellInterface::Private*>(wl_resource_get_user_data(resource));
+ s->present(client, surfaces);
+}
+
+void PlasmaShellInterface::Private::present(wl_client *client, wl_array *surfaces)
+{
+ Q_UNUSED(client);
+ Q_UNUSED(surfaces);
+ // TODO: implement
+}
+
+bool PlasmaShellInterface::isValid() const
+{
+ return d->shell != nullptr;
+}
+
+Display *PlasmaShellInterface::display() const
+{
+ return d->display;
+}
+
+/*********************************
+ * PlasmaSurfaceInterface
+ *********************************/
+PlasmaSurfaceInterface::Private::Private(PlasmaSurfaceInterface *q, PlasmaShellInterface *shell, SurfaceInterface *surface)
+ : surface(surface)
+ , shell(shell)
+ , q(q)
+{
+}
+
+const struct org_kde_plasma_surface_interface PlasmaSurfaceInterface::Private::s_interface = {
+ destroyCallback,
+ setOutputCallback,
+ setPositionCallback,
+ setRoleCallback,
+ setFlagsCallback,
+ setScreenEdgeCallback
+};
+
+PlasmaSurfaceInterface::PlasmaSurfaceInterface(PlasmaShellInterface *shell, SurfaceInterface *parent)
+ : QObject(parent)
+ , d(new Private(this, shell, parent))
+{
+}
+
+PlasmaSurfaceInterface::~PlasmaSurfaceInterface()
+{
+ if (d->shellSurface) {
+ wl_resource_destroy(d->shellSurface);
+ }
+}
+
+void PlasmaSurfaceInterface::Private::create(wl_client *c, quint32 version, quint32 id)
+{
+ Q_ASSERT(!client);
+ Q_ASSERT(!shellSurface);
+ shellSurface = wl_resource_create(c, &org_kde_plasma_surface_interface, version, id);
+ if (!shellSurface) {
+ wl_client_post_no_memory(c);
+ return;
+ }
+ client = c;
+
+ wl_resource_set_implementation(shellSurface, &s_interface, this, unbind);
+}
+
+void PlasmaSurfaceInterface::Private::unbind(wl_resource *r)
+{
+ auto s = cast(r);
+ s->shellSurface = nullptr;
+ s->q->deleteLater();
+}
+
+void PlasmaSurfaceInterface::Private::destroyCallback(wl_client *client, wl_resource *resource)
+{
+ Q_UNUSED(client);
+ unbind(resource);
+ auto s = cast(resource);
+ delete s;
+}
+
+void PlasmaSurfaceInterface::Private::setOutputCallback(wl_client *client, wl_resource *resource, wl_resource *output)
+{
+ Q_UNUSED(client);
+ Q_UNUSED(output)
+ auto s = cast(resource);
+ Q_ASSERT(client == s->client);
+ // TODO: implement
+}
+
+void PlasmaSurfaceInterface::Private::setPositionCallback(wl_client *client, wl_resource *resource,
+ int32_t x, int32_t y)
+{
+ Q_UNUSED(x)
+ Q_UNUSED(y)
+ auto s = cast(resource);
+ Q_ASSERT(client == s->client);
+ // TODO: implement
+}
+
+void PlasmaSurfaceInterface::Private::setRoleCallback(wl_client *client, wl_resource *resource, uint32_t role)
+{
+ Q_UNUSED(role)
+ auto s = cast(resource);
+ Q_ASSERT(client == s->client);
+ // TODO: implement
+}
+
+void PlasmaSurfaceInterface::Private::setFlagsCallback(wl_client *client, wl_resource *resource, uint32_t flags)
+{
+ Q_UNUSED(flags)
+ auto s = cast(resource);
+ Q_ASSERT(client == s->client);
+ // TODO: implement
+}
+
+void PlasmaSurfaceInterface::Private::setScreenEdgeCallback(wl_client *client, wl_resource *resource, uint32_t edge)
+{
+ auto s = cast(resource);
+ Q_ASSERT(client == s->client);
+ // TODO: implement
+}
+
+SurfaceInterface *PlasmaSurfaceInterface::surface() const {
+ return d->surface;
+}
+
+PlasmaShellInterface *PlasmaSurfaceInterface::shell() const {
+ return d->shell;
+}
+
+wl_resource *PlasmaSurfaceInterface::shellSurface() const {
+ return d->shellSurface;
+}
+
+}
+}
diff --git a/src/server/plasma_shell_interface.h b/src/server/plasma_shell_interface.h
new file mode 100644
index 0000000..169679d
--- /dev/null
+++ b/src/server/plasma_shell_interface.h
@@ -0,0 +1,84 @@
+/********************************************************************
+Copyright 2014 Pier Luigi Fiorini <pierluigi.fiorini@gmail.com>
+Copyright 2014 Martin Gräßlin <mgraesslin@kde.org>
+
+This library is free software; you can redistribute it and/or
+modify it under the terms of the GNU Lesser General Public
+License as published by the Free Software Foundation; either
+version 2.1 of the License, or (at your option) version 3, or any
+later version accepted by the membership of KDE e.V. (or its
+successor approved by the membership of KDE e.V.), which shall
+act as a proxy defined in Section 6 of version 3 of the license.
+
+This library is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+Lesser General Public License for more details.
+
+You should have received a copy of the GNU Lesser General Public
+License along with this library. If not, see <http://www.gnu.org/licenses/>.
+*********************************************************************/
+#ifndef WAYLAND_SERVER_PLASMA_SHELL_INTERFACE_H
+#define WAYLAND_SERVER_PLASMA_SHELL_INTERFACE_H
+
+#include <QObject>
+
+#include <KWayland/Server/kwaylandserver_export.h>
+
+struct wl_resource;
+
+namespace KWayland
+{
+namespace Server
+{
+
+class Display;
+class SurfaceInterface;
+class PlasmaSurfaceInterface;
+class OutputInterface;
+
+class KWAYLANDSERVER_EXPORT PlasmaShellInterface : public QObject
+{
+ Q_OBJECT
+public:
+ virtual ~PlasmaShellInterface();
+
+ void create();
+ void destroy();
+
+ bool isValid() const;
+
+ Display *display() const;
+
+Q_SIGNALS:
+ void surfaceCreated(KWayland::Server::PlasmaSurfaceInterface*);
+ void ready();
+
+private:
+ friend class Display;
+ explicit PlasmaShellInterface(Display *display, QObject *parent);
+ class Private;
+ QScopedPointer<Private> d;
+};
+
+class KWAYLANDSERVER_EXPORT PlasmaSurfaceInterface : public QObject
+{
+ Q_OBJECT
+public:
+ virtual ~PlasmaSurfaceInterface();
+
+ SurfaceInterface *surface() const;
+ PlasmaShellInterface *shell() const;
+ wl_resource *shellSurface() const;
+
+private:
+ friend class PlasmaShellInterface;
+ explicit PlasmaSurfaceInterface(PlasmaShellInterface *shell, SurfaceInterface *parent);
+ class Private;
+ QScopedPointer<Private> d;
+};
+
+}
+}
+
+#endif
--
1.8.3.1