Skip to content
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

Fix mouse state persists on display server after app loses focus #92455

Closed
Show file tree
Hide file tree
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
4 changes: 4 additions & 0 deletions platform/linuxbsd/wayland/display_server_wayland.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,10 @@ void DisplayServerWayland::process_events() {
} else if (winev_msg->event == WINDOW_EVENT_FOCUS_OUT) {
if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT);
{
MutexLock mutex_lock(wayland_thread.mutex);
wayland_thread.pointer_clear_button_mask();
}
}
}
}
Expand Down
7 changes: 7 additions & 0 deletions platform/linuxbsd/wayland/wayland_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3504,6 +3504,13 @@
return BitField<MouseButtonMask>();
}

void WaylandThread::pointer_clear_button_mask() {
SeatState *ss = wl_seat_get_seat_state(wl_seat_current);
if (ss) {
ss->pointer_data_buffer.pressed_button_mask.clear()

Check failure on line 3510 in platform/linuxbsd/wayland/wayland_thread.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor w/ Mono (target=editor)

expected ';' before '}' token

Check failure on line 3510 in platform/linuxbsd/wayland/wayland_thread.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with doubles and GCC sanitizers (target=editor, tests=yes, dev_build=yes, scu_build=yes, precision=double, use_asan=yes, use_ubsan=yes, linker=gold)

expected ';' before '}' token

Check failure on line 3510 in platform/linuxbsd/wayland/wayland_thread.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with clang sanitizers (target=editor, tests=yes, dev_build=yes, use_asan=yes, use_ubsan=yes, use_llvm=yes, linker=lld)

expected ';' after expression

Check failure on line 3510 in platform/linuxbsd/wayland/wayland_thread.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Editor with ThreadSanitizer (target=editor, tests=yes, dev_build=yes, use_tsan=yes, use_llvm=yes, linker=lld)

expected ';' after expression

Check failure on line 3510 in platform/linuxbsd/wayland/wayland_thread.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Template w/ Mono (target=template_release)

expected ';' before '}' token

Check failure on line 3510 in platform/linuxbsd/wayland/wayland_thread.cpp

View workflow job for this annotation

GitHub Actions / 🐧 Linux / Minimal template (target=template_release, everything disabled)

expected ';' before '}' token
}
}

Error WaylandThread::init() {
#ifdef SOWRAP_ENABLED
#ifdef DEBUG_ENABLED
Expand Down
1 change: 1 addition & 0 deletions platform/linuxbsd/wayland/wayland_thread.h
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,7 @@ class WaylandThread {
PointerConstraint pointer_get_constraint() const;
DisplayServer::WindowID pointer_get_pointed_window_id() const;
BitField<MouseButtonMask> pointer_get_button_mask() const;
void pointer_clear_button_mask();

void cursor_hide();
void cursor_set_shape(DisplayServer::CursorShape p_cursor_shape);
Expand Down
1 change: 1 addition & 0 deletions platform/linuxbsd/x11/display_server_x11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4310,6 +4310,7 @@ void DisplayServerX11::process_events() {
if (OS::get_singleton()->get_main_loop()) {
DEBUG_LOG_X11("All focus lost, triggering NOTIFICATION_APPLICATION_FOCUS_OUT\n");
OS::get_singleton()->get_main_loop()->notification(MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT);
last_button_state.clear();
}
app_focused = false;
}
Expand Down
3 changes: 3 additions & 0 deletions platform/windows/display_server_windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3774,6 +3774,9 @@ LRESULT DisplayServerWindows::WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARA
app_focused = new_app_focused;
if (OS::get_singleton()->get_main_loop()) {
OS::get_singleton()->get_main_loop()->notification(app_focused ? MainLoop::NOTIFICATION_APPLICATION_FOCUS_IN : MainLoop::NOTIFICATION_APPLICATION_FOCUS_OUT);
if (!app_focused) {
last_button_state.clear();
}
}
} break;
case WM_ACTIVATE: {
Expand Down
Loading