Commit c73444dd authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

wayland: Do not allocate a full list just to check if there's values

parent 40044f21
......@@ -1081,7 +1081,7 @@ void SeatInterface::notifyTouchDown(qint32 id, const QPointF &globalPosition)
if (id == 0 && hasPointer() && focusedTouchSurface()) {
TouchInterfacePrivate *touchPrivate = TouchInterfacePrivate::get(d->touch.data());
if (touchPrivate->touchesForClient(focusedTouchSurface()->client()).isEmpty()) {
if (!touchPrivate->hasTouchesForClient(focusedTouchSurface()->client())) {
// If the client did not bind the touch interface fall back
// to at least emulating touch through pointer events.
d->pointer->sendEnter(focusedTouchSurface(), pos, serial);
......@@ -1117,7 +1117,7 @@ void SeatInterface::notifyTouchMotion(qint32 id, const QPointF &globalPosition)
if (hasPointer() && focusedTouchSurface()) {
TouchInterfacePrivate *touchPrivate = TouchInterfacePrivate::get(d->touch.data());
if (touchPrivate->touchesForClient(focusedTouchSurface()->client()).isEmpty()) {
if (!touchPrivate->hasTouchesForClient(focusedTouchSurface()->client())) {
// Client did not bind touch, fall back to emulating with pointer events.
d->pointer->sendMotion(pos);
d->pointer->sendFrame();
......@@ -1148,7 +1148,7 @@ void SeatInterface::notifyTouchUp(qint32 id)
if (id == 0 && hasPointer() && focusedTouchSurface()) {
TouchInterfacePrivate *touchPrivate = TouchInterfacePrivate::get(d->touch.data());
if (touchPrivate->touchesForClient(focusedTouchSurface()->client()).isEmpty()) {
if (!touchPrivate->hasTouchesForClient(focusedTouchSurface()->client())) {
// Client did not bind touch, fall back to emulating with pointer events.
const quint32 serial = display()->nextSerial();
d->pointer->sendButton(BTN_LEFT, PointerButtonState::Released, serial);
......
......@@ -35,6 +35,11 @@ QList<TouchInterfacePrivate::Resource *> TouchInterfacePrivate::touchesForClient
return resourceMap().values(client->client());
}
bool TouchInterfacePrivate::hasTouchesForClient(ClientConnection *client) const
{
return resourceMap().contains(client->client());
}
TouchInterface::TouchInterface(SeatInterface *seat)
: d(new TouchInterfacePrivate(this, seat))
{
......
......@@ -21,6 +21,7 @@ public:
TouchInterfacePrivate(TouchInterface *q, SeatInterface *seat);
QList<Resource *> touchesForClient(ClientConnection *client) const;
bool hasTouchesForClient(ClientConnection *client) const;
TouchInterface *q;
QPointer<SurfaceInterface> focusedSurface;
......
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