2020-03-15 15:19:28 +00:00
|
|
|
/*
|
|
|
|
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
|
2020-07-04 08:54:47 +00:00
|
|
|
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
|
2014-08-28 07:52:35 +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
|
|
|
|
*/
|
2014-08-28 07:52:35 +00:00
|
|
|
#include "compositor_interface.h"
|
|
|
|
#include "display.h"
|
2021-03-10 21:33:40 +00:00
|
|
|
#include "region_interface_p.h"
|
2014-08-28 07:52:35 +00:00
|
|
|
#include "surface_interface.h"
|
2020-07-04 08:54:47 +00:00
|
|
|
|
|
|
|
#include "qwayland-server-wayland.h"
|
2014-08-28 07:52:35 +00:00
|
|
|
|
2020-04-29 14:56:38 +00:00
|
|
|
namespace KWaylandServer
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
static const int s_version = 4;
|
|
|
|
|
|
|
|
class CompositorInterfacePrivate : public QtWaylandServer::wl_compositor
|
2014-09-18 13:31:01 +00:00
|
|
|
{
|
|
|
|
public:
|
2020-07-04 08:54:47 +00:00
|
|
|
CompositorInterfacePrivate(CompositorInterface *q, Display *display);
|
2014-09-18 13:31:01 +00:00
|
|
|
|
|
|
|
CompositorInterface *q;
|
2020-07-04 08:54:47 +00:00
|
|
|
Display *display;
|
2015-09-10 07:23:36 +00:00
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
protected:
|
|
|
|
void compositor_create_surface(Resource *resource, uint32_t id) override;
|
|
|
|
void compositor_create_region(Resource *resource, uint32_t id) override;
|
2014-08-28 07:52:35 +00:00
|
|
|
};
|
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
CompositorInterfacePrivate::CompositorInterfacePrivate(CompositorInterface *q, Display *display)
|
|
|
|
: QtWaylandServer::wl_compositor(*display, s_version)
|
|
|
|
, q(q)
|
|
|
|
, display(display)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
void CompositorInterfacePrivate::compositor_create_surface(Resource *resource, uint32_t id)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2020-07-04 08:54:47 +00:00
|
|
|
wl_resource *surfaceResource = wl_resource_create(resource->client(), &wl_surface_interface,
|
|
|
|
resource->version(), id);
|
|
|
|
if (!surfaceResource) {
|
|
|
|
wl_resource_post_no_memory(resource->handle);
|
2014-08-28 07:52:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2020-07-04 08:54:47 +00:00
|
|
|
emit q->surfaceCreated(new SurfaceInterface(q, surfaceResource));
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
void CompositorInterfacePrivate::compositor_create_region(Resource *resource, uint32_t id)
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
2020-07-04 08:54:47 +00:00
|
|
|
wl_resource *regionResource = wl_resource_create(resource->client(), &wl_region_interface,
|
|
|
|
resource->version(), id);
|
|
|
|
if (!regionResource) {
|
|
|
|
wl_resource_post_no_memory(resource->handle);
|
2014-08-28 07:52:35 +00:00
|
|
|
return;
|
|
|
|
}
|
2021-03-10 21:33:40 +00:00
|
|
|
new RegionInterface(regionResource);
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
CompositorInterface::CompositorInterface(Display *display, QObject *parent)
|
|
|
|
: QObject(parent)
|
|
|
|
, d(new CompositorInterfacePrivate(this, display))
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
CompositorInterface::~CompositorInterface()
|
2014-08-28 07:52:35 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2020-07-04 08:54:47 +00:00
|
|
|
Display *CompositorInterface::display() const
|
|
|
|
{
|
|
|
|
return d->display;
|
2014-08-28 07:52:35 +00:00
|
|
|
}
|
2020-07-04 08:54:47 +00:00
|
|
|
|
|
|
|
} // namespace KWaylandServer
|