Move static unbind method from derived classes to Resource::Private
All classes had exactly the same implementation, so it's a good idea to share the implementation.
This commit is contained in:
parent
0fb42d102e
commit
cee32f902a
11 changed files with 8 additions and 56 deletions
|
@ -57,7 +57,6 @@ private:
|
|||
void setSelection(DataSourceInterface *dataSource);
|
||||
static void startDragCallback(wl_client *client, wl_resource *resource, wl_resource *source, wl_resource *origin, wl_resource *icon, uint32_t serial);
|
||||
static void setSelectionCallback(wl_client *client, wl_resource *resource, wl_resource *source, uint32_t serial);
|
||||
static void unbind(wl_resource *resource);
|
||||
|
||||
static const struct wl_data_device_interface s_interface;
|
||||
};
|
||||
|
@ -115,13 +114,6 @@ void DataDeviceInterface::Private::setSelection(DataSourceInterface *dataSource)
|
|||
}
|
||||
}
|
||||
|
||||
void DataDeviceInterface::Private::unbind(wl_resource *resource)
|
||||
{
|
||||
auto s = cast<Private>(resource);
|
||||
s->resource = nullptr;
|
||||
s->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
void DataDeviceInterface::Private::create(wl_client *client, quint32 version, quint32 id)
|
||||
{
|
||||
Q_ASSERT(!resource);
|
||||
|
|
|
@ -48,7 +48,6 @@ private:
|
|||
static void acceptCallback(wl_client *client, wl_resource *resource, uint32_t serial, const char *mimeType);
|
||||
static void receiveCallback(wl_client *client, wl_resource *resource, const char *mimeType, int32_t fd);
|
||||
static void destroyCallback(wl_client *client, wl_resource *resource);
|
||||
static void unbind(wl_resource *resource);
|
||||
|
||||
static const struct wl_data_offer_interface s_interface;
|
||||
};
|
||||
|
@ -104,13 +103,6 @@ void DataOfferInterface::Private::receive(const QString &mimeType, qint32 fd)
|
|||
source->requestData(mimeType, fd);
|
||||
}
|
||||
|
||||
void DataOfferInterface::Private::unbind(wl_resource *resource)
|
||||
{
|
||||
auto o = cast<Private>(resource);
|
||||
o->resource = nullptr;
|
||||
o->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
DataOfferInterface::DataOfferInterface(DataSourceInterface *source, DataDeviceInterface *parentInterface)
|
||||
: Resource(new Private(source, parentInterface, this), parentInterface)
|
||||
{
|
||||
|
|
|
@ -52,7 +52,6 @@ private:
|
|||
|
||||
static void offerCallback(wl_client *client, wl_resource *resource, const char *mimeType);
|
||||
static void destroyCallack(wl_client *client, wl_resource *resource);
|
||||
static void unbind(wl_resource *resource);
|
||||
|
||||
const static struct wl_data_source_interface s_interface;
|
||||
};
|
||||
|
@ -69,13 +68,6 @@ DataSourceInterface::Private::Private(DataSourceInterface *q, DataDeviceManagerI
|
|||
|
||||
DataSourceInterface::Private::~Private() = default;
|
||||
|
||||
void DataSourceInterface::Private::unbind(wl_resource *resource)
|
||||
{
|
||||
auto s = cast<Private>(resource);
|
||||
s->resource = nullptr;
|
||||
s->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
void DataSourceInterface::Private::destroyCallack(wl_client *client, wl_resource *resource)
|
||||
{
|
||||
Q_UNUSED(client)
|
||||
|
|
|
@ -45,7 +45,6 @@ private:
|
|||
void add(const QRect &rect);
|
||||
void subtract(const QRect &rect);
|
||||
|
||||
static void unbind(wl_resource *r);
|
||||
static void destroyCallback(wl_client *client, wl_resource *r);
|
||||
static void addCallback(wl_client *client, wl_resource *r, int32_t x, int32_t y, int32_t width, int32_t height);
|
||||
static void subtractCallback(wl_client *client, wl_resource *r, int32_t x, int32_t y, int32_t width, int32_t height);
|
||||
|
@ -101,13 +100,6 @@ void RegionInterface::Private::destroyCallback(wl_client *client, wl_resource *r
|
|||
cast<Private>(r)->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
void RegionInterface::Private::unbind(wl_resource *r)
|
||||
{
|
||||
auto region = cast<Private>(r);
|
||||
region->resource = nullptr;
|
||||
region->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
void RegionInterface::Private::create(wl_client *client, quint32 version, quint32 id)
|
||||
{
|
||||
Q_ASSERT(!resource);
|
||||
|
|
|
@ -40,6 +40,13 @@ Resource::Private::~Private()
|
|||
}
|
||||
}
|
||||
|
||||
void Resource::Private::unbind(wl_resource *r)
|
||||
{
|
||||
Private *p = cast<Private>(r);
|
||||
p->resource = nullptr;
|
||||
p->q->deleteLater();
|
||||
}
|
||||
|
||||
Resource::Resource(Resource::Private *d, QObject *parent)
|
||||
: QObject(parent)
|
||||
, d(d)
|
||||
|
|
|
@ -48,6 +48,7 @@ protected:
|
|||
"Derived must be derived from Resource::Private");
|
||||
return r ? reinterpret_cast<Derived*>(wl_resource_get_user_data(r)) : nullptr;
|
||||
}
|
||||
static void unbind(wl_resource *resource);
|
||||
|
||||
Resource *q;
|
||||
};
|
||||
|
|
|
@ -83,7 +83,6 @@ public:
|
|||
bool toplevel = false;
|
||||
|
||||
private:
|
||||
static void unbind(wl_resource *r);
|
||||
// interface callbacks
|
||||
static void pongCallback(wl_client *client, wl_resource *resource, uint32_t serial);
|
||||
static void moveCallback(wl_client *client, wl_resource *resource, wl_resource *seat, uint32_t serial);
|
||||
|
@ -222,13 +221,6 @@ void ShellSurfaceInterface::Private::create(wl_client *c, quint32 version, quint
|
|||
wl_resource_set_implementation(resource, &s_interface, this, unbind);
|
||||
}
|
||||
|
||||
void ShellSurfaceInterface::Private::unbind(wl_resource *r)
|
||||
{
|
||||
auto s = cast<Private>(r);
|
||||
s->resource = nullptr;
|
||||
s->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
void ShellSurfaceInterface::Private::pongCallback(wl_client *client, wl_resource *resource, uint32_t serial)
|
||||
{
|
||||
auto s = cast<Private>(resource);
|
||||
|
|
|
@ -179,13 +179,6 @@ void SubSurfaceInterface::Private::commit()
|
|||
}
|
||||
}
|
||||
|
||||
void SubSurfaceInterface::Private::unbind(wl_resource *r)
|
||||
{
|
||||
auto s = cast<Private>(r);
|
||||
s->resource = nullptr;
|
||||
s->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
void SubSurfaceInterface::Private::destroyCallback(wl_client *client, wl_resource *resource)
|
||||
{
|
||||
Q_UNUSED(client)
|
||||
|
|
|
@ -58,7 +58,6 @@ private:
|
|||
void placeAbove(SurfaceInterface *sibling);
|
||||
void placeBelow(SurfaceInterface *sibling);
|
||||
|
||||
static void unbind(wl_resource *r);
|
||||
static void destroyCallback(wl_client *client, wl_resource *resource);
|
||||
static void setPositionCallback(wl_client *client, wl_resource *resource, int32_t x, int32_t y);
|
||||
static void placeAboveCallback(wl_client *client, wl_resource *resource, wl_resource *sibling);
|
||||
|
|
|
@ -180,13 +180,6 @@ void SurfaceInterface::frameRendered(quint32 msec)
|
|||
}
|
||||
}
|
||||
|
||||
void SurfaceInterface::Private::unbind(wl_resource *r)
|
||||
{
|
||||
auto s = cast<Private>(r);
|
||||
s->resource = nullptr;
|
||||
s->q_func()->deleteLater();
|
||||
}
|
||||
|
||||
void SurfaceInterface::Private::destroy()
|
||||
{
|
||||
for (wl_resource *c : current.callbacks) {
|
||||
|
|
|
@ -78,7 +78,6 @@ private:
|
|||
void setOpaque(const QRegion ®ion);
|
||||
void setInput(const QRegion ®ion, bool isInfinite);
|
||||
|
||||
static void unbind(wl_resource *r);
|
||||
static void destroyFrameCallback(wl_resource *r);
|
||||
|
||||
static void destroyCallback(wl_client *client, wl_resource *resource);
|
||||
|
|
Loading…
Reference in a new issue