kwin/src/wayland/compositor_interface.cpp
Vlad Zahorodnii 16db81b5cc Make RegionInterface private
If a Wayland protocol deals with regions, they will be exposed as
QRegion objects in public API. Therefore, it makes sense to make
RegionInterface private as it's an implementation detail and it's
not intended to be used in public api.

The corresponding test was dropped because the CompositorInterface
no longer emits a signal to indicate that a wl_region has been created.
It should be also noted that wl_region stuff is already tested via
other means, e.g. surface damage, etc.
2021-03-15 16:28:30 +00:00

76 lines
2.2 KiB
C++

/*
SPDX-FileCopyrightText: 2014 Martin Gräßlin <mgraesslin@kde.org>
SPDX-FileCopyrightText: 2020 Vlad Zahorodnii <vlad.zahorodnii@kde.org>
SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "compositor_interface.h"
#include "display.h"
#include "region_interface_p.h"
#include "surface_interface.h"
#include "qwayland-server-wayland.h"
namespace KWaylandServer
{
static const int s_version = 4;
class CompositorInterfacePrivate : public QtWaylandServer::wl_compositor
{
public:
CompositorInterfacePrivate(CompositorInterface *q, Display *display);
CompositorInterface *q;
Display *display;
protected:
void compositor_create_surface(Resource *resource, uint32_t id) override;
void compositor_create_region(Resource *resource, uint32_t id) override;
};
CompositorInterfacePrivate::CompositorInterfacePrivate(CompositorInterface *q, Display *display)
: QtWaylandServer::wl_compositor(*display, s_version)
, q(q)
, display(display)
{
}
void CompositorInterfacePrivate::compositor_create_surface(Resource *resource, uint32_t id)
{
wl_resource *surfaceResource = wl_resource_create(resource->client(), &wl_surface_interface,
resource->version(), id);
if (!surfaceResource) {
wl_resource_post_no_memory(resource->handle);
return;
}
emit q->surfaceCreated(new SurfaceInterface(q, surfaceResource));
}
void CompositorInterfacePrivate::compositor_create_region(Resource *resource, uint32_t id)
{
wl_resource *regionResource = wl_resource_create(resource->client(), &wl_region_interface,
resource->version(), id);
if (!regionResource) {
wl_resource_post_no_memory(resource->handle);
return;
}
new RegionInterface(regionResource);
}
CompositorInterface::CompositorInterface(Display *display, QObject *parent)
: QObject(parent)
, d(new CompositorInterfacePrivate(this, display))
{
}
CompositorInterface::~CompositorInterface()
{
}
Display *CompositorInterface::display() const
{
return d->display;
}
} // namespace KWaylandServer