wayland: Do not allocate a full list just to check if there's values
This commit is contained in:
parent
40044f21e1
commit
c73444dd12
3 changed files with 9 additions and 3 deletions
|
@ -1081,7 +1081,7 @@ void SeatInterface::notifyTouchDown(qint32 id, const QPointF &globalPosition)
|
||||||
|
|
||||||
if (id == 0 && hasPointer() && focusedTouchSurface()) {
|
if (id == 0 && hasPointer() && focusedTouchSurface()) {
|
||||||
TouchInterfacePrivate *touchPrivate = TouchInterfacePrivate::get(d->touch.data());
|
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
|
// If the client did not bind the touch interface fall back
|
||||||
// to at least emulating touch through pointer events.
|
// to at least emulating touch through pointer events.
|
||||||
d->pointer->sendEnter(focusedTouchSurface(), pos, serial);
|
d->pointer->sendEnter(focusedTouchSurface(), pos, serial);
|
||||||
|
@ -1117,7 +1117,7 @@ void SeatInterface::notifyTouchMotion(qint32 id, const QPointF &globalPosition)
|
||||||
|
|
||||||
if (hasPointer() && focusedTouchSurface()) {
|
if (hasPointer() && focusedTouchSurface()) {
|
||||||
TouchInterfacePrivate *touchPrivate = TouchInterfacePrivate::get(d->touch.data());
|
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.
|
// Client did not bind touch, fall back to emulating with pointer events.
|
||||||
d->pointer->sendMotion(pos);
|
d->pointer->sendMotion(pos);
|
||||||
d->pointer->sendFrame();
|
d->pointer->sendFrame();
|
||||||
|
@ -1148,7 +1148,7 @@ void SeatInterface::notifyTouchUp(qint32 id)
|
||||||
|
|
||||||
if (id == 0 && hasPointer() && focusedTouchSurface()) {
|
if (id == 0 && hasPointer() && focusedTouchSurface()) {
|
||||||
TouchInterfacePrivate *touchPrivate = TouchInterfacePrivate::get(d->touch.data());
|
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.
|
// Client did not bind touch, fall back to emulating with pointer events.
|
||||||
const quint32 serial = display()->nextSerial();
|
const quint32 serial = display()->nextSerial();
|
||||||
d->pointer->sendButton(BTN_LEFT, PointerButtonState::Released, serial);
|
d->pointer->sendButton(BTN_LEFT, PointerButtonState::Released, serial);
|
||||||
|
|
|
@ -35,6 +35,11 @@ QList<TouchInterfacePrivate::Resource *> TouchInterfacePrivate::touchesForClient
|
||||||
return resourceMap().values(client->client());
|
return resourceMap().values(client->client());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TouchInterfacePrivate::hasTouchesForClient(ClientConnection *client) const
|
||||||
|
{
|
||||||
|
return resourceMap().contains(client->client());
|
||||||
|
}
|
||||||
|
|
||||||
TouchInterface::TouchInterface(SeatInterface *seat)
|
TouchInterface::TouchInterface(SeatInterface *seat)
|
||||||
: d(new TouchInterfacePrivate(this, seat))
|
: d(new TouchInterfacePrivate(this, seat))
|
||||||
{
|
{
|
||||||
|
|
|
@ -21,6 +21,7 @@ public:
|
||||||
TouchInterfacePrivate(TouchInterface *q, SeatInterface *seat);
|
TouchInterfacePrivate(TouchInterface *q, SeatInterface *seat);
|
||||||
|
|
||||||
QList<Resource *> touchesForClient(ClientConnection *client) const;
|
QList<Resource *> touchesForClient(ClientConnection *client) const;
|
||||||
|
bool hasTouchesForClient(ClientConnection *client) const;
|
||||||
|
|
||||||
TouchInterface *q;
|
TouchInterface *q;
|
||||||
QPointer<SurfaceInterface> focusedSurface;
|
QPointer<SurfaceInterface> focusedSurface;
|
||||||
|
|
Loading…
Reference in a new issue