2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2015 Martin Gräßlin <mgraesslin@kde.org>
|
|
|
|
SPDX-FileCopyrightText: 2015 Marco Martin <mart@kde.org>
|
2020-05-25 17:49:00 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 David Edmundson <davidedmundson@kde.org>
|
2015-08-26 12:42:58 +00:00
|
|
|
|
2020-03-15 15:19:28 +00:00
|
|
|
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
|
|
|
|
*/
|
2015-08-26 12:42:58 +00:00
|
|
|
#include "blur_interface.h"
|
2021-03-10 21:33:40 +00:00
|
|
|
#include "region_interface_p.h"
|
2015-08-26 12:42:58 +00:00
|
|
|
#include "display.h"
|
|
|
|
#include "surface_interface_p.h"
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
#include "qwayland-server-blur.h"
|
2015-08-26 12:42:58 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
|
|
|
|
2020-10-02 06:59:57 +00:00
|
|
|
static const quint32 s_version = 1;
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
class BlurManagerInterfacePrivate : public QtWaylandServer::org_kde_kwin_blur_manager
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-05-25 17:49:00 +00:00
|
|
|
BlurManagerInterfacePrivate(BlurManagerInterface *q, Display *d);
|
2015-08-26 12:42:58 +00:00
|
|
|
|
|
|
|
BlurManagerInterface *q;
|
2015-09-10 07:23:36 +00:00
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
protected:
|
2021-05-02 14:46:13 +00:00
|
|
|
void org_kde_kwin_blur_manager_destroy_global() override;
|
2020-08-05 12:21:04 +00:00
|
|
|
void org_kde_kwin_blur_manager_create(Resource *resource, uint32_t id, wl_resource *surface) override;
|
|
|
|
void org_kde_kwin_blur_manager_unset(Resource *resource, wl_resource *surface) override;
|
2015-08-26 12:42:58 +00:00
|
|
|
};
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
BlurManagerInterfacePrivate::BlurManagerInterfacePrivate(BlurManagerInterface *_q, Display *d)
|
|
|
|
: QtWaylandServer::org_kde_kwin_blur_manager(*d, s_version)
|
|
|
|
, q(_q)
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-05-02 14:46:13 +00:00
|
|
|
void BlurManagerInterfacePrivate::org_kde_kwin_blur_manager_destroy_global()
|
|
|
|
{
|
|
|
|
delete q;
|
|
|
|
}
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
void BlurManagerInterfacePrivate::org_kde_kwin_blur_manager_unset(Resource *resource, wl_resource *surface)
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
2020-05-25 17:49:00 +00:00
|
|
|
Q_UNUSED(resource);
|
2015-08-26 12:42:58 +00:00
|
|
|
SurfaceInterface *s = SurfaceInterface::get(surface);
|
|
|
|
if (!s) {
|
|
|
|
return;
|
|
|
|
}
|
2020-07-04 07:51:33 +00:00
|
|
|
SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(s);
|
|
|
|
surfacePrivate->setBlur(QPointer<BlurInterface>());
|
2015-08-26 12:42:58 +00:00
|
|
|
}
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
|
|
|
|
void BlurManagerInterfacePrivate::org_kde_kwin_blur_manager_create(Resource *resource, uint32_t id, wl_resource *surface)
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
|
|
|
SurfaceInterface *s = SurfaceInterface::get(surface);
|
|
|
|
if (!s) {
|
2020-05-25 17:49:00 +00:00
|
|
|
wl_resource_post_error(resource->handle, 0, "Invalid surface");
|
2015-08-26 12:42:58 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-05-25 17:49:00 +00:00
|
|
|
wl_resource *blur_resource = wl_resource_create(resource->client(), &org_kde_kwin_blur_interface, resource->version(), id);
|
|
|
|
if (!blur_resource) {
|
|
|
|
wl_client_post_no_memory(resource->client());
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
auto blur = new BlurInterface(blur_resource);
|
2020-07-04 07:51:33 +00:00
|
|
|
SurfaceInterfacePrivate *surfacePrivate = SurfaceInterfacePrivate::get(s);
|
|
|
|
surfacePrivate->setBlur(blur);
|
2015-08-26 12:42:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
BlurManagerInterface::BlurManagerInterface(Display *display, QObject *parent)
|
2020-05-25 17:49:00 +00:00
|
|
|
: QObject(parent)
|
|
|
|
, d(new BlurManagerInterfacePrivate(this, display))
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2021-01-29 13:25:54 +00:00
|
|
|
BlurManagerInterface::~BlurManagerInterface()
|
2021-05-02 14:46:13 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void BlurManagerInterface::remove()
|
2021-01-29 13:25:54 +00:00
|
|
|
{
|
|
|
|
d->globalRemove();
|
|
|
|
}
|
2015-08-26 12:42:58 +00:00
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
class BlurInterfacePrivate : public QtWaylandServer::org_kde_kwin_blur
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-05-25 17:49:00 +00:00
|
|
|
BlurInterfacePrivate(BlurInterface *q, wl_resource *resource);
|
2015-08-26 12:42:58 +00:00
|
|
|
QRegion pendingRegion;
|
|
|
|
QRegion currentRegion;
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
BlurInterface *q;
|
2015-08-26 12:42:58 +00:00
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
protected:
|
2020-08-05 12:21:04 +00:00
|
|
|
void org_kde_kwin_blur_destroy_resource(Resource *resource) override;
|
|
|
|
void org_kde_kwin_blur_commit(Resource *resource) override;
|
|
|
|
void org_kde_kwin_blur_set_region(Resource *resource, wl_resource *region) override;
|
|
|
|
void org_kde_kwin_blur_release(Resource *resource) override;
|
2015-08-26 12:42:58 +00:00
|
|
|
};
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
void BlurInterfacePrivate::org_kde_kwin_blur_commit(Resource *resource)
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
2020-05-25 17:49:00 +00:00
|
|
|
Q_UNUSED(resource)
|
2015-08-26 12:42:58 +00:00
|
|
|
currentRegion = pendingRegion;
|
|
|
|
}
|
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
void BlurInterfacePrivate::org_kde_kwin_blur_set_region(Resource *resource, wl_resource *region)
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
2020-05-25 17:49:00 +00:00
|
|
|
Q_UNUSED(resource)
|
2015-08-26 12:42:58 +00:00
|
|
|
RegionInterface *r = RegionInterface::get(region);
|
|
|
|
if (r) {
|
2020-05-25 17:49:00 +00:00
|
|
|
pendingRegion = r->region();
|
2015-08-26 12:42:58 +00:00
|
|
|
} else {
|
2020-05-25 17:49:00 +00:00
|
|
|
pendingRegion = QRegion();
|
2015-08-26 12:42:58 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-08-05 12:21:04 +00:00
|
|
|
void BlurInterfacePrivate::org_kde_kwin_blur_release(Resource *resource)
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
2020-05-25 17:49:00 +00:00
|
|
|
wl_resource_destroy(resource->handle);
|
2015-08-26 12:42:58 +00:00
|
|
|
}
|
|
|
|
|
2020-08-05 12:21:04 +00:00
|
|
|
void BlurInterfacePrivate::org_kde_kwin_blur_destroy_resource(Resource *resource)
|
2020-05-25 17:49:00 +00:00
|
|
|
{
|
|
|
|
Q_UNUSED(resource)
|
|
|
|
delete q;
|
|
|
|
}
|
2015-08-26 12:42:58 +00:00
|
|
|
|
2020-05-25 17:49:00 +00:00
|
|
|
BlurInterfacePrivate::BlurInterfacePrivate(BlurInterface *_q, wl_resource *resource)
|
|
|
|
: QtWaylandServer::org_kde_kwin_blur(resource)
|
|
|
|
, q(_q)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BlurInterface::BlurInterface(wl_resource *resource)
|
|
|
|
: QObject()
|
|
|
|
, d(new BlurInterfacePrivate(this, resource))
|
2015-08-26 12:42:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
BlurInterface::~BlurInterface() = default;
|
|
|
|
|
|
|
|
QRegion BlurInterface::region()
|
|
|
|
{
|
|
|
|
return d->currentRegion;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|