Setting Window borderless=true and resizable=false prevents application grabbing focus
Godot version
v4.2.beta.custom_build [b1371806a], v4.1.2.stable
System information
Godot v4.2.beta (b1371806a) - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce GTX 1080 Ti (NVIDIA; 31.0.15.3623) - AMD Ryzen Threadripper 1950X 16-Core Processor (32 Threads)
Issue description
The combination of display/window/size/borderless=true and display/window/size/resizable=false in project settings will cause the application to silently fail to automatically grab focus when it starts. Calling Window::grab_focus() will not grab focus either. Window::has_focus() will lie to you and return true. Only actually clicking on the window will give the application focus.
Issue occurs in editor and in exported release.
Issue potentially may be platform-specific (Windows 10)
Issue may be avoided by setting borderless directly via GDScript in scene
Steps to reproduce
In Project Settings: Set display/window/size/borderless=true Set display/window/size/resizable=false
Minimal reproduction project
This project contains a node with a script which prints ui_up, down, left, and right when they are pressed. Launch the game and observe that the printouts do not occur when hitting the arrow keys. Focus the game by clicking on the screen and observe that the printouts now do occur when hitting the arrow keys.
Yeah, this bug was reported as solved but it is happening on Fullscreen or Exclusive fullscreen if you have resizable off. It is an old issue that was closed #80350.
PS: I am on Windows 11
Yeah, this bug was reported as solved but it is happening on Fullscreen or Exclusive fullscreen if you have resizable off. It is an old issue that was closed #80350.
PS: I am on Windows 11
Same experience here. Borderless doesn't seem to influence it.
I'm experiencing this with v4.2.2.stable.mono.official [15073afe3] - if resizable is off, the window is not focused on start.
I've run into this issue as well using Godot v4.2.1.stable.official [b09f793f5] on Windows 10. However, I have done some experimenting and figured out a couple interesting things:
- It really is tied to having borderless AND non-resizable. For instance, running fullscreen (exclusive or not) with resizable set to true will capture focus correctly, OR if you run in a window that doesn't take up the full screen and is both borderless and not resizable the focus will not be captured correctly.
- Using get_window().grab_focus() fails to capture the focus since Godot already thinks it has it and thus doesn't even make an attempt to re-grab it.
EDIT: Also, I thought I had a workaround but testing it again it actually doesn't work, thus I've got a different workaround now: Leave resizable set in the project settings no matter what and turn it off AFTER the main window is created:
get_window().set_flag(Window.FLAG_RESIZE_DISABLED,true)
Reproduced on v4.3.stable.mono.official.77dcf97d8
In fullsceen, borderless does not affect anything, only resizeable.