Native Window Message Loop

Godot Version



How do I create a Window with the typical behaviour of a native system window?

I’ve created a few Window nodes and turned off gui_embed subwindows. On launching the game, I now get additional system windows, with a system-styled title bar! It’s great! However, the windows don’t do anything.

I would like these system windows to act exactly like a typical system window, including these behaviours:

  • Minimizes on clicking the minimize button
  • Closes on clicking the close button
  • Resizable by the user
  • The user can drag the window to move it
  • The user can drag the window to the side of the screen, allowing some OS-specific thing to happen

Basically, I want this game to behave like a typical native application running on the user’s desktop OS. In Win32, you’d get most of this for free by calling DefWindowProc or returning TRUE from your window/dialog’s message loop.

Is there a way for me to do this in Godot? I see in the docs that you can sort of reinvent all this by responding to signals, but if possible I want to avoid badly replicating functionality that already exists.

No. This is out of scope for Godot. Godot uses a GPU-rendered canvas that, while it can behave like the OS, it is optimized for live-update applications. If you want to really get themeing and behaviour from the OS, you have to use a library like Qt or similar (im old, Ionly know the old ones), but godot has no facilities for this.
The most you can do is read -some- themeing variables from the system, but that’s not guaranteed to be there on all systems, specially linuxes.

If you just want a -recreation- you can definitely do that, but yes, it will be a lot of work. There may be a plugin to help, but I don’t know it.

1 Like

What do you mean? The only thing that the Window node does not handle by default is closing it which you need to do it manually by listening to the Window.close_requested signal like:

extends Node

@onready var window: Window = $Window

func _ready() -> void:
	window.close_requested.connect(func(): window.hide())

Everything else: minimizing, resizing, dragging,… is supported out of the box.

1 Like

You’re right, thanks so much!

Here was my problem, for future reference: by mistake, I had set popup_window to true on one of the windows. Since I didn’t make that window respond to close requests, it stayed open and blocked interaction all windows.

I’m pleased to report this feature really works! Creating multiple real-deal system windows is in scope for Godot!

To clarify this reply for future reference: it is out of scope to get cross-platform native UI inside the client rectangle.

Oh, that’s what you meant! Yeah, they are both named the same even tho they are different things. ;u;

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.