godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.05k stars 65 forks source link

Implementing a window_suppress_attention method #9677

Open mopifish opened 2 weeks ago

mopifish commented 2 weeks ago

Describe the project you are working on

I'm working on a desktop pet that often hides and shows windows while the game isn't focused.

Describe the problem or limitation you are having in your project

Whenever a window is shown, and the game isn't in focus, it'll request attention: image

Currently, there is no way to suppress this attention. I'd like to suppress this attention so windows wont be constantly flashing for the user.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I'd like to implement a window_suppress_attention method in DisplayServer as a counterpart to window_request_attention

By calling window_suppress_attention after a window is shown, it would prevent the user from being flashed by shown windows.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

window_request_attention uses a call to FlashWindowEx with FLASHWINFO's dwFlag set to FLASHW_ALL. FLASHWINFO also has a FLASHW_STOP flag, which can be used in place of FLASHW_ALL to stop the windows flashing on Windows platforms

credit to u/graydoubt on the godot subreddit for this explanation

If this enhancement will not be used often, can it be worked around with a few lines of script?

It should be possible to write a C# plugin that uses Windows API to suppress the windows flashing manually.

Is there a reason why this should be core and not an add-on in the asset library?

It mirrors and compliments existing functionality, and would be easier to add to the core engine than it would be to make a plugin.