From 140dcba46b78def8ab6b81046744a309e375784e Mon Sep 17 00:00:00 2001 From: Sungyoon Cho Date: Wed, 15 May 2024 15:14:03 +0900 Subject: [PATCH] wl_seat: send frame event after pointer leave --- src/managers/SeatManager.cpp | 17 ++++++++++++++++- src/managers/SeatManager.hpp | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/managers/SeatManager.cpp b/src/managers/SeatManager.cpp index 3e2d595f654..b9590c42c26 100644 --- a/src/managers/SeatManager.cpp +++ b/src/managers/SeatManager.cpp @@ -186,10 +186,13 @@ void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) { } } + auto lastPointerFocusResource = state.pointerFocusResource; + state.pointerFocusResource.reset(); state.pointerFocus = surf; if (!surf) { + sendPointerFrame(lastPointerFocusResource); events.pointerFocusChange.emit(); return; } @@ -209,6 +212,11 @@ void CSeatManager::setPointerFocus(wlr_surface* surf, const Vector2D& local) { } } + if (state.pointerFocusResource != lastPointerFocusResource) + sendPointerFrame(lastPointerFocusResource); + + sendPointerFrame(); + hyprListener_pointerSurfaceDestroy.initCallback( &surf->events.destroy, [this](void* owner, void* data) { setPointerFocus(nullptr, {}); }, nullptr, "CSeatManager"); @@ -245,7 +253,14 @@ void CSeatManager::sendPointerFrame() { if (!state.pointerFocusResource) return; - for (auto& p : state.pointerFocusResource->pointers) { + sendPointerFrame(state.pointerFocusResource); +} + +void CSeatManager::sendPointerFrame(WP pResource) { + if (!pResource) + return; + + for (auto& p : pResource->pointers) { if (!p) continue; diff --git a/src/managers/SeatManager.hpp b/src/managers/SeatManager.hpp index f4efda70251..cf5e9216eea 100644 --- a/src/managers/SeatManager.hpp +++ b/src/managers/SeatManager.hpp @@ -63,6 +63,7 @@ class CSeatManager { void sendPointerMotion(uint32_t timeMs, const Vector2D& local); void sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_button_state state); void sendPointerFrame(); + void sendPointerFrame(WP pResource); void sendPointerAxis(uint32_t timeMs, wl_pointer_axis axis, double value, int32_t discrete, wl_pointer_axis_source source, wl_pointer_axis_relative_direction relative); void sendTouchDown(wlr_surface* surf, uint32_t timeMs, int32_t id, const Vector2D& local);