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

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.
parent a160876d
......@@ -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
***************************************/
......
......@@ -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);
......
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