Add static SeatInterface *SeatInterface::get(wl_resource*)

No auto-test for it as we don't track the created resources which
makes testing difficult. Implicit testing will be added through
DataDeviceInterface.
This commit is contained in:
Martin Gräßlin 2014-11-05 15:29:18 +01:00
parent a160876d05
commit 435c88f1e0
2 changed files with 16 additions and 1 deletions

View file

@ -58,6 +58,11 @@ public:
PointerInterface *pointerInterface;
KeyboardInterface *keyboardInterface;
static SeatInterface *get(wl_resource *native) {
auto s = cast(native);
return s ? s->q : nullptr;
}
private:
static Private *cast(wl_resource *r);
static void bind(wl_client *client, void *data, uint32_t version, uint32_t id);
@ -68,12 +73,15 @@ private:
static void getKeyboardCallback(wl_client *client, wl_resource *resource, uint32_t id);
static void getTouchCallback(wl_client *client, wl_resource *resource, uint32_t id);
static const struct wl_seat_interface s_interface;
SeatInterface *q;
};
SeatInterface::Private::Private(SeatInterface *q, Display *d)
: display(d)
, pointerInterface(new PointerInterface(d, q))
, keyboardInterface(new KeyboardInterface(d, q))
, q(q)
{
}
@ -181,7 +189,7 @@ void SeatInterface::Private::sendCapabilities(wl_resource *r)
SeatInterface::Private *SeatInterface::Private::cast(wl_resource *r)
{
return reinterpret_cast<SeatInterface::Private*>(wl_resource_get_user_data(r));
return r ? reinterpret_cast<SeatInterface::Private*>(wl_resource_get_user_data(r)) : nullptr;
}
void SeatInterface::setHasKeyboard(bool has)
@ -271,6 +279,11 @@ KeyboardInterface *SeatInterface::keyboard()
return d->keyboardInterface;
}
SeatInterface *SeatInterface::get(wl_resource *native)
{
return Private::get(native);
}
/****************************************
* PointerInterface
***************************************/

View file

@ -64,6 +64,8 @@ public:
void setHasKeyboard(bool has);
void setHasTouch(bool has);
static SeatInterface *get(wl_resource *native);
Q_SIGNALS:
void nameChanged(const QString&);
void hasPointerChanged(bool);