Skip to content

Commit

Permalink
wl_seat: send frame event after pointer leave
Browse files Browse the repository at this point in the history
  • Loading branch information
sungyoonc committed May 15, 2024
1 parent 94c20a1 commit bcf5d01
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/managers/SeatManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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");

Expand Down Expand Up @@ -242,10 +250,14 @@ void CSeatManager::sendPointerButton(uint32_t timeMs, uint32_t key, wl_pointer_b
}

void CSeatManager::sendPointerFrame() {
if (!state.pointerFocusResource)
sendPointerFrame(state.pointerFocusResource);
}

void CSeatManager::sendPointerFrame(WP<CWLSeatResource> pResource) {
if (!pResource)
return;

for (auto& p : state.pointerFocusResource->pointers) {
for (auto& p : pResource->pointers) {
if (!p)
continue;

Expand Down
1 change: 1 addition & 0 deletions src/managers/SeatManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<CWLSeatResource> 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);
Expand Down

0 comments on commit bcf5d01

Please sign in to comment.