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

Erroneous input events when hovering non-focused native window #69368

Closed
pkdawson opened this issue Nov 30, 2022 · 2 comments · Fixed by #69390
Closed

Erroneous input events when hovering non-focused native window #69368

pkdawson opened this issue Nov 30, 2022 · 2 comments · Fixed by #69390

Comments

@pkdawson
Copy link
Contributor

pkdawson commented Nov 30, 2022

Godot version

v4.0.beta6.mono.official [7f8ecff]

System information

Windows 11 22H2

Issue description

This is a platform-specific bug, because it behaves correctly on macOS 13. No idea about Linux.

In a project with multiple native windows:

  1. Have one window focused, and hover your mouse over another window.

  2. The focused window will receive InputEventMouseMotion events in _input, but with mouse coordinates from the non-focused window.

Or to look at it another way, the events are correct but the wrong window is receiving them.

Steps to reproduce

Run the MRP, observe output as you focus one window and hover over the other.

Minimal reproduction project

native_windows_hover.zip

@pkdawson
Copy link
Contributor Author

pkdawson commented Nov 30, 2022

This was apparently caused by an intentional change ("Send mouse move events to focused window instead of hovered window."), but I don't understand the intent. The result is just bad data: input events that say the mouse cursor is somewhere it isn't.

@Sauermann If you could explain the intended behavior, maybe I can fix this.

DisplayServer::WindowID receiving_window_id = _get_focused_window_or_popup();
if (receiving_window_id == INVALID_WINDOW_ID) {
receiving_window_id = window_id;
}
Ref<InputEventMouseMotion> mm;
mm.instantiate();
mm->set_window_id(receiving_window_id);

@Sauermann
Copy link
Contributor

Sauermann commented Nov 30, 2022

Thank you for bringing this issue to my attention: The focused window will receive InputEventMouseMotion events in _input, but with mouse coordinates from the non-focused window.
I can confirm this bug. Apparently I missed this corner case during my implementation. The behavior differs from linuxbsd, where the mouse-coordinates are relative to the focused window.
I believe, that the correct solution is to adjust the mouse position in the event and not adjust the window, that receives the input. I will investigate a solution for this.

"Send mouse move events to focused window instead of hovered window." is related to the special case of Popups that handle focus differently.

By the way: Before #67903, mouse move events outside of the focused window were simply dropped on Windows, when no Mouse-Drag-and-Drop was active.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants