godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.66k stars 20.11k forks source link

`Input.warp_mouse()` is not working on WindowMode `WINDOW_MODE_MINIMIZED` #73461

Open MikeSchulze opened 1 year ago

MikeSchulze commented 1 year ago

Godot version

v4.0.rc1.official [8843d9ad3]

System information

Windows 10

Issue description

I working on my unit testing API and run into this issue.

The API provides a scene runner to simulate interactions like key/mouse events During testing the implementation i found out the Input.warp_mouse() is not working when set the display mode to WINDOW_MODE_MINIMIZED I set the display mode by default to minimized to hide the test runner scene.

On Godot3 it was working in the minimized mode but is broken on Godot4

Steps to reproduce

load the attache example project

Minimal reproduction project

warp_mouse.zip

AThousandShips commented 1 year ago

What way is it supposed to work when minimized, with no window or area to wrap in?

Calinou commented 1 year ago

What way is it supposed to work when minimized, with no window or area to wrap in?

As I understand it, warp_mouse() should teleport the cursor to absolute coordinates on screen when the window is minimized.

cc @bruvzg

Sauermann commented 1 year ago

I can confirm this Issue on Windows. Linux X11 Xfce doesn't have this problem, so it is likely that this is a Windows-only behavior.

Input knows about the currently focused window, but knows nothing about screen coordinates. So Input.warp_mouse() is always relative to the position of the currently focused window. For this it relies on the DisplayServer-interpretation, where the focused windows is.

chutchinson commented 1 year ago

@Calinou the latest documentation doesn't say anything about warping to absolute screen coordinates (it speaks in terms of the currently focused window); are you suggesting the behavior should be amended to warp to absolute screen coordinates in the case of the window being minimized (or not otherwise visible)? Not a problem, just making sure that's the intent. I have a fix for this issue already, but looking for verification of this behavior.

Calinou commented 1 year ago

@Calinou the latest documentation doesn't say anything about warping to absolute screen coordinates (it speaks in terms of the currently focused window); are you suggesting the behavior should be amended to warp to absolute screen coordinates in the case of the window being minimized (or not otherwise visible)? Not a problem, just making sure that's the intent. I have a fix for this issue already, but looking for verification of this behavior.

I wouldn't change existing behavior when the window is visible in the interest of backwards compatibility. When the window is invisible however, we need to create behavior that makes sense, as I don't think this ever worked properly in the past.

alvinseptiano commented 5 months ago

I can confirm this Issue on Windows. Linux X11 Xfce doesn't have this problem, so it is likely that this is a Windows-only behavior.

Input knows about the currently focused window, but knows nothing about screen coordinates. So Input.warp_mouse() is always relative to the position of the currently focused window. For this it relies on the DisplayServer-interpretation, where the focused windows is.

Is not Windows only problem, but also happening in Wayland.

Riteo commented 5 months ago

Is not Windows only problem, but also happening in Wayland.

Regarding the Wayland part, we can do nothing about it by design. See #90213.