Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement no-window mode for X11 and MacOS (3.2) #42276

Merged
merged 1 commit into from
Nov 10, 2020

Conversation

RandomShaper
Copy link
Member

@RandomShaper RandomShaper commented Sep 23, 2020

This adds support for --no-window to MacOS and X11.

It also makes the non-windowed and non-overridden versions of OS::alert() include the title as well.

The credit for the MacOS support goes to a developer called Anton Breusov, on top of which I applied minimal changes. It seems that on Mac we can't get perfect hidden window behavior (it's still shown in the dock, though unpickable) and we need stronger measures to have it working as closer to expected as possible, as the code changes show.

NOTE: There's no version of this for 4.0, since, as far as I've checked, 4.0 still doesn't implement --no-window at all. Therefore, I believe that a good plan is that when it's implemented there the 3.2 version is more platform-complete so it gets everything at once.

Bugsquad edit: Fixes #43325.


This code is generously donated by IMVU.

main/main.cpp Outdated Show resolved Hide resolved
@capnm
Copy link
Contributor

capnm commented Sep 23, 2020

I think --no-window could be a default by --script.
In the other few cases, you could use the --window option.

@RandomShaper
Copy link
Member Author

I think --no-window could be a default by --script.
In the other few cases, you could use the --window option.

That's a good idea, but I would leave 3.x as it is to avoid surprising changes. For 4.0 it's fine, I think.

@capnm
Copy link
Contributor

capnm commented Sep 23, 2020

That's a good idea, but I would leave 3.x as it is to avoid surprising changes. For 4.0 it's fine, I think.

For --gdnative-generate-json-api, etc. too.

I would keep it the same to avoid a chaos;)
You could probably print a warnig or let also the --no-window option for compatibility reasons?

FYI I've made it the default wherever it's been useful and added both options:

-	OS::get_singleton()->print("  --no-window                      Disable window creation (Windows only). Useful together with --script.\n");
+	OS::get_singleton()->print("  --window, --no-window            Run with or without opening a window. Useful with --script.\n");

@capnm
Copy link
Contributor

capnm commented Sep 23, 2020

Some notes:
Edit: sorry Godot seems to ignore unknown arguments;)

godot-32x --no-window -s test.gd runs a gdscript w/o window and keeps hanging...

Maybe the comment could mention that you need to explicitly call the quit() function.

-s, --script <script> Run a script.

Copy link
Contributor

@pouleyKetchoupp pouleyKetchoupp left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The X11 part looks fine and seems to work well.

Copy link
Member

@bruvzg bruvzg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works OK on macOS, but App icon will appear in the Dock.

platform/osx/os_osx.mm Show resolved Hide resolved
platform/osx/os_osx.mm Outdated Show resolved Hide resolved
platform/osx/os_osx.mm Outdated Show resolved Hide resolved
@akien-mga
Copy link
Member

@RandomShaper See review comments from @bruvzg, once amended this should be good to go.

Bonus: Homogeinize and improve OS::alert() for no-window mode
@akien-mga akien-mga merged commit 8a3be0e into godotengine:3.2 Nov 10, 2020
@akien-mga
Copy link
Member

Thanks!

@RandomShaper RandomShaper deleted the no_window_3.2 branch November 10, 2020 07:49
@Xrayez
Copy link
Contributor

Xrayez commented May 15, 2021

I think --no-window could be a default by --script.
In the other few cases, you could use the --window option.

That's a good idea, but I would leave 3.x as it is to avoid surprising changes. For 4.0 it's fine, I think.

There are definitely use cases where having a Window is necessary when running with --script, like for running unit tests. See also godotengine/godot-proposals#1760.

As far as I know, it's not just a "script" which is run by Godot, it's a MainLoop derived script which just overrides the main loop implementation.

This is just to be aware if you do decide to make it a default, adding another --windowed option would be absolutely necessary.

Xrayez added a commit to goostengine/goost that referenced this pull request May 15, 2021
All editor platforms have `--no-window` option now: godotengine/godot#42276.

[ci skip]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

8 participants