Hey all, as my first project in Godot I am attempting to build a Windows 98-like interface. I made my File Explorer window out of the window node, as the click-and-drag movement, close button, and window resizing all work out of the box, so I figure it would be the simplest solution.

However, my Window node is drawing above everything else in my scene, regardless of its position in the scene tree, it's culling mask, or its layer when made the child of a CanvasLayer node. I figure this is probably just some property of Window/Viewport nodes that I'm missing how to change. Is there some third, secret layer system that I'm missing somewhere?

Any help is appreciated!

Alright I've found a way to do it. Funny enough, it still involves gui_embed_subwindows. So here is my scene tree:

and I have the following script attached to the SubViewport:

extends SubViewport

func _ready() -> void:
	gui_embed_subwindows = true;
	add_child(preload("res://subwindow_test.tscn").instantiate())

The subwindow_test scene is just a Window I have saved as a scene, but you can add Windows however you were planning on doing it. The important thing is to set gui_embed_subwindows = true on the SubViewport before you do so. SubViewports have that set to false by default. Setting it to true tells its children, i.e. the Windows we're adding, to embed themselves within the SubViewport rather than our root Viewport. This way, the SubViewportContainer can sort all of the Window draws behind our other elements in the tree.

One more important thing to add: make sure to turn on transparent_bg for the SubViewport if you intend to bring its Windows to the front or to have some kind of background behind it.

Dude, thanks so much! This has been my biggest headscratcher since starting my project :') and this has fixed it completely!

On another note, now my cursor no longer changes to the "side arrows" when over the edges of the window to indicate clicking & dragging will resize it. The window can still resize all the same, the cursor change is now gone. Additionally, it seems the boundaries for resizing are much smaller and harder to click. I will look into it and get back if I can find anything