Godot: Create floating game window by default (for tiled WMs)

Created on 18 Jun 2016  路  9Comments  路  Source: godotengine/godot

Godot works great on WMs like i3, which is very cool and makes development a lot faster.

Game windows, however, would benefit from being floating by default, even on tiled WMs, unless it's specified otherwise in Project Settings > Display.

This is because:

  1. Nobody plays games (except maybe roguelikes) in tiled mode. This means that even for tiled WM users, it would make more sense to test the game as most users would play it
  2. Games that aren't coded with resizability in mind will break (the most important reason, IMHO)
feature proposal core

Most helpful comment

I also use i3wm.
This is side note of how I managed to configure i3wm in order to have the godot editor in tiled mode and the game window in floating mode.
Basically I use those 2 lines in my i3 config file:

for_window [class="Godot"] floating enable
for_window [title=".*Godot Engine*."] floating disable

All 9 comments

As I understand it that can only be achieved by changing the window type of the game window (https://faq.i3wm.org/question/61/forcing-windows-as-always-floating.1.html).

If that answer is still correct that would require us to set the game's window type to dialog, utility, toolbar or splash, none of which fit game windows, so that would be a workaround that is risking a lot of bugs since it's based on an obviously wrong setting. It would have to be expected that other window managers react to those flags in a different way that might result in all Godot games being displayed in the toolbar or as a modal window.

As much as I sympathize (I am an i3 user as well) I think changing your own i3 setting so your game launches on a new workspace or in floating mode is the better solution. After all I would expect that if a gamer really uses i3 they would just start games on a fresh workspace without any other windows.

@Warlaan I tried to run xprop on a program which runs floating on i3 (PokerTH). Apparently it's done via the I3_FLOATING_WINDOW atom, which is not suitable for all cases, but then I did not find any mention of I3_FLOATING_WINDOW in PokerTH's source code.

In order to make the player windows easily configurable, they should have this WM_CLASS:

WM_CLASS(STRING) = "Godot_Player", "Godot"

Instead of this:

WM_CLASS(STRING) = "Godot", "Godot"

which would affect editor windows as well.

It would also be more consistent, since the editor has this WM_CLASS:

WM_CLASS(STRING) = "Godot_Editor", "Godot"

And the Project List has this WM_CLASS:

WM_CLASS(STRING) = "Godot_ProjectList", "Godot"

Not to mention that I haven't tried running xprop on an exported game but it should have the game name as the WM_CLASS.

Should I open a separate issue for this or just rename this one?

I also use i3wm.
This is side note of how I managed to configure i3wm in order to have the godot editor in tiled mode and the game window in floating mode.
Basically I use those 2 lines in my i3 config file:

for_window [class="Godot"] floating enable
for_window [title=".*Godot Engine*."] floating disable

@ni-code But that's a workaround, not a long term solution.

What about naming the default window Godot_Engine instead of Godot (which would be the class)? This way game windows will have two different WM_CLASSES ("Godot_Engine", "Godot" and not "Godot", "Godot", which is redundant anyway), much like Gvim for example ("gvim", "Gvim"; it's pretty common among other programs as well) but with the difference that it will be easier to filter Godot windows just via

for_window [class="Godot_Engine"] floating enable

It will also be possible on WMs with less capable filtering than i3. This can be achieved by modifying line 347 in platform/x11/os_x11.cpp to:

        classHint->res_name = (char *)"Godot_Engine";

The editor won't be affected because its WM_CLASS will be "Godot_Editor", "Godot", much like the project list.

Anyone willing to consider merging this (I hereby release all code I posted in this comment into the public domain, just in case)?

PR welcome :)

Hey, just in case someone wants to configure i3 to automatically switch Godot game window to floating mode.

@Ghost made a little mistake. The correct way would be to add the following line to the i3 config file:

for_window [instance="Godot_Engine"] floating enable

If you try to filter by class, i3 will only match against the second part of the WM_CLASS attribute. Since this is "Godot", it will switch all Godot windows to floating mode.

The issue is already closed, so hopefully this isn't off-topic or anything (I don't have much experience in GitHub).

Has there been a regression? I can't quite tell why, but Godot editor is now showing up as "Godot_Engine" in v3.1.stable.official. Potentially the context isn't correct somehow, but I haven't gone all the way down the rabbit hole yet.

In the recent versions @ni-code 's solution stopped working for some reason. Can someone please help me figure out how to make it work now?

Thanks to the advice from a redditor I have the solution:

for_window [instance="Godot_Engine"] floating enable
for_window [instance="Godot_Editor"] floating disable
Was this page helpful?
0 / 5 - 0 ratings