MOUSE_MODE_CONFINED + clicking header issue

Godot Version

4.2.1 stable


In a project I’m working on, the mouse must stay confined to the window space, and this works fine with MOUSE_MODE_CONFINED. The game can be played in windowed or fullscreen. When in windowed mode, tabbing out and clicking on the header of the window will result in the window being dragged to the bottom of the monitor with no way to bring it back. Resizing the window also results in similar glitchy buggies. I cannot think of or find any viable solutions to these issues.

edit: found a github post about this problem with no solution

As a temporary workaround, you can disable “Show window contents while dragging” in the Windows performance options. This causes the window to only repaint once (at the end of the drag), which avoids the uncontrollable sliding behavior for both dragging and resizing.

This isn’t a viable solution for me since its outside of Godot and a personalized workaround, but I appreciate the help.

There could be a potential solution utilizing DisplayServer.window_set_rect_changed_callback()
however this isn’t working properly for me. It won’t call the callback despite receiving the correct window_id (defaults 0 anyways). I can tell it’s working up to a point, because when I attempted to use DisplayServer.window_set_input_event_callback() it disabled all my inputs, however did not utilize the callback which was a simple print.

If these were working, they could be combined with RenderingServer.render_loop_enabled to get my desired solution. Pretty frustrating that they’re not working!!!

FWIW I commented on the linked Github issue with a proposed direction for a fix in the display server, along with a working (but non-robust) code sample. Essentially the display server needs to be disabling the cursor clip while a move/resize operation is active. It’s already consuming the relevant WM events, so it’s certainly fixable there.

1 Like

thanks for doing that! I was looking through the source last night but c++ makes my eyes glaze over.

1 Like