diff --git a/src/GestureManager.cpp b/src/GestureManager.cpp index 7e8a848..e5bc91a 100644 --- a/src/GestureManager.cpp +++ b/src/GestureManager.cpp @@ -272,7 +272,7 @@ void GestureManager::sendCancelEventsToWindows() { for (const auto& touch : this->touchedResources.all()) { const auto t = touch.lock(); - if (t.impl_) { // FIXME: idk how to check weak pointer validity + if (t.get()) { t->sendCancel(); } } @@ -366,16 +366,23 @@ bool GestureManager::onTouchUp(ITouch::SUpEvent ev) { if (**SEND_CANCEL) { const auto surface = g_pInputManager->m_sTouchData.touchFocusSurface; + if (!surface.valid()) { + return true; + } + wl_client* client = surface.get()->client(); - if (client) { - SP seat = g_pSeatManager->seatResourceForClient(client); + if (!client) { + return true; + } - if (seat) { - auto touches = seat.get()->touches; - for (const auto& touch : touches) { - this->touchedResources.remove(touch); - } - } + SP seat = g_pSeatManager->seatResourceForClient(client); + if (!seat.get()) { + return true; + } + + auto touches = seat.get()->touches; + for (const auto& touch : touches) { + this->touchedResources.remove(touch); } return BLOCK;