Commit b243eea6 authored by Martin Flöser's avatar Martin Flöser
Browse files

Add createResource to ClientConnection

One place to rule all createResource calls.
parent fce51fb3
......@@ -95,6 +95,11 @@ void ClientConnection::flush()
wl_client_flush(d->client);
}
wl_resource *ClientConnection::createResource(const wl_interface *interface, quint32 version, quint32 id)
{
return wl_resource_create(d->client, interface, version, id);
}
wl_client *ClientConnection::client()
{
return d->client;
......
......@@ -25,6 +25,8 @@ License along with this library. If not, see <http://www.gnu.org/licenses/>.
#include <KWayland/Server/kwaylandserver_export.h>
struct wl_client;
struct wl_interface;
struct wl_resource;
namespace KWayland
{
......@@ -40,6 +42,7 @@ public:
virtual ~ClientConnection();
void flush();
wl_resource *createResource(const wl_interface *interface, quint32 version, quint32 id);
wl_client *client();
Display *display();
......
......@@ -72,7 +72,8 @@ CompositorInterface::~CompositorInterface() = default;
void CompositorInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
{
wl_resource *resource = wl_resource_create(client, &wl_compositor_interface, qMin(version, s_version), id);
auto c = display->getConnection(client);
wl_resource *resource = c->createResource(&wl_compositor_interface, qMin(version, s_version), id);
if (!resource) {
wl_client_post_no_memory(client);
return;
......
......@@ -65,7 +65,8 @@ DataDeviceManagerInterface::Private::Private(DataDeviceManagerInterface *q, Disp
void DataDeviceManagerInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
{
wl_resource *resource = wl_resource_create(client, &wl_data_device_manager_interface, qMin(version, s_version), id);
auto c = display->getConnection(client);
wl_resource *resource = c->createResource(&wl_data_device_manager_interface, qMin(version, s_version), id);
if (!resource) {
wl_client_post_no_memory(client);
return;
......
......@@ -256,7 +256,8 @@ int32_t OutputInterface::Private::toSubPixel() const
void OutputInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
{
wl_resource *resource = wl_resource_create(client, &wl_output_interface, qMin(version, s_version), id);
auto c = display->getConnection(client);
wl_resource *resource = c->createResource(&wl_output_interface, qMin(version, s_version), id);
if (!resource) {
wl_client_post_no_memory(client);
return;
......
......@@ -52,7 +52,7 @@ void Resource::Private::create(ClientConnection *c, quint32 version, quint32 id)
Q_ASSERT(!resource);
Q_ASSERT(!client);
client = c;
resource = wl_resource_create(*client, m_interface, version, id);
resource = client->createResource(m_interface, version, id);
if (!resource) {
return;
}
......
......@@ -114,7 +114,8 @@ ShellInterface::~ShellInterface() = default;
void ShellInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
{
wl_resource *shell = wl_resource_create(client, &wl_shell_interface, qMin(version, s_version), 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;
......
......@@ -66,7 +66,8 @@ SubCompositorInterface::Private::Private(SubCompositorInterface *q, Display *d)
void SubCompositorInterface::Private::bind(wl_client *client, uint32_t version, uint32_t id)
{
wl_resource *resource = wl_resource_create(client, &wl_subcompositor_interface, qMin(version, s_version), id);
auto c = display->getConnection(client);
wl_resource *resource = c->createResource(&wl_subcompositor_interface, qMin(version, s_version), id);
if (!resource) {
wl_client_post_no_memory(client);
return;
......
......@@ -236,7 +236,7 @@ void SurfaceInterface::Private::setTransform(OutputInterface::Transform transfor
void SurfaceInterface::Private::addFrameCallback(uint32_t callback)
{
wl_resource *r = wl_resource_create(*client, &wl_callback_interface, 1, callback);
wl_resource *r = client->createResource(&wl_callback_interface, 1, callback);
if (!r) {
wl_resource_post_no_memory(resource);
return;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment