Merge SeatInterface::Private::pointerForSurface and ::keyboardForSurface
templated helper method.
This commit is contained in:
parent
6504e067bc
commit
7baf5896be
1 changed files with 11 additions and 13 deletions
|
@ -255,32 +255,30 @@ SeatInterface::Private *SeatInterface::Private::cast(wl_resource *r)
|
||||||
return r ? reinterpret_cast<SeatInterface::Private*>(wl_resource_get_user_data(r)) : nullptr;
|
return r ? reinterpret_cast<SeatInterface::Private*>(wl_resource_get_user_data(r)) : nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
PointerInterface *SeatInterface::Private::pointerForSurface(SurfaceInterface *surface) const
|
template <typename T>
|
||||||
|
static
|
||||||
|
T *interfaceForSurface(SurfaceInterface *surface, const QVector<T*> &interfaces)
|
||||||
{
|
{
|
||||||
if (!surface) {
|
if (!surface) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto it = pointers.begin(); it != pointers.end(); ++it) {
|
for (auto it = interfaces.begin(); it != interfaces.end(); ++it) {
|
||||||
if (wl_resource_get_client((*it)->resource()) == *surface->client()) {
|
if ((*it)->client() == surface->client()) {
|
||||||
return (*it);
|
return (*it);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
PointerInterface *SeatInterface::Private::pointerForSurface(SurfaceInterface *surface) const
|
||||||
|
{
|
||||||
|
return interfaceForSurface(surface, pointers);
|
||||||
|
}
|
||||||
|
|
||||||
KeyboardInterface *SeatInterface::Private::keyboardForSurface(SurfaceInterface *surface) const
|
KeyboardInterface *SeatInterface::Private::keyboardForSurface(SurfaceInterface *surface) const
|
||||||
{
|
{
|
||||||
if (!surface) {
|
return interfaceForSurface(surface, keyboards);
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (auto it = keyboards.begin(); it != keyboards.end(); ++it) {
|
|
||||||
if ((*it)->client() == surface->client()) {
|
|
||||||
return (*it);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void SeatInterface::setHasKeyboard(bool has)
|
void SeatInterface::setHasKeyboard(bool has)
|
||||||
|
|
Loading…
Reference in a new issue