Skip to content

Wayland: Fix stuck pointer buttons on window leave #106414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions platform/linuxbsd/wayland/wayland_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1692,16 +1692,28 @@ void WaylandThread::_wl_pointer_on_frame(void *data, struct wl_pointer *wl_point
}
}

if (pd.pointed_id == DisplayServer::INVALID_WINDOW_ID) {
WindowState *ws = nullptr;

// NOTE: At least on sway, with wl_pointer version 5 or greater,
// wl_pointer::leave might be emitted with other events (like
// wl_pointer::button) within the same wl_pointer::frame. Because of this, we
// need to account for when the currently pointed window might be invalid
// (third-party or even none) and fall back to the old one.
if (pd.pointed_id != DisplayServer::INVALID_WINDOW_ID) {
ws = ss->wayland_thread->window_get_state(pd.pointed_id);
ERR_FAIL_NULL(ws);
} else if (old_pd.pointed_id != DisplayServer::INVALID_WINDOW_ID) {
ws = ss->wayland_thread->window_get_state(old_pd.pointed_id);
ERR_FAIL_NULL(ws);
}

if (ws == nullptr) {
// We're probably on a decoration or some other third-party thing. Let's
// "commit" the data and call it a day.
old_pd = pd;
return;
}

WindowState *ws = ss->wayland_thread->window_get_state(pd.pointed_id);
ERR_FAIL_NULL(ws);

double scale = window_state_get_scale_factor(ws);

wayland_thread->_set_current_seat(ss->wl_seat);
Expand Down