[macOS] Always use "Regular" activation policy for GUI, and headless main loop for command line only tools.

This commit is contained in:
Pāvels Nadtočajevs 2025-08-20 10:07:33 +03:00
parent 28bd72a7e1
commit 6e76a9467f
No known key found for this signature in database
GPG key ID: 8413210218EF35D2
3 changed files with 22 additions and 4 deletions

View file

@ -1860,7 +1860,6 @@ void DisplayServerMacOS::show_window(WindowID p_id) {
WindowData &wd = windows[p_id];
if (p_id == MAIN_WINDOW_ID) {
[GodotApp setActivationPolicy:NSApplicationActivationPolicyRegular];
[GodotApp activateApplication];
}

View file

@ -58,6 +58,21 @@ int main(int argc, char **argv) {
bool is_embedded = false;
bool is_headless = false;
const char *headless_args[] = {
"--headless",
"-h",
"--help",
"/?",
"--version",
"--dump-gdextension-interface",
"--dump-extension-api",
"--dump-extension-api-with-docs",
"--validate-extension-api",
"--convert-3to4",
"--validate-conversion-3to4",
"--doctool",
};
for (int i = 0; i < argc; i++) {
if (strcmp("-NSDocumentRevisionsDebugMode", argv[i]) == 0) {
// remove "-NSDocumentRevisionsDebugMode" and the next argument
@ -76,9 +91,13 @@ int main(int argc, char **argv) {
if (strcmp("--embedded", argv[i]) == 0) {
is_embedded = true;
}
if (strcmp("--headless", argv[i]) == 0 || strcmp("--doctool", argv[i]) == 0) {
for (size_t j = 0; j < std::size(headless_args); j++) {
if (strcmp(headless_args[j], argv[i]) == 0) {
is_headless = true;
break;
}
}
if (i < argc - 1 && strcmp("--display-driver", argv[i]) == 0 && strcmp("headless", argv[i + 1]) == 0) {
is_headless = true;
}

View file

@ -1153,7 +1153,7 @@ OS_MacOS_NSApp::OS_MacOS_NSApp(const char *p_execpath, int p_argc, char **p_argv
[GodotApplication sharedApplication];
// In case we are unbundled, make us a proper UI application.
[NSApp setActivationPolicy:NSApplicationActivationPolicyAccessory];
[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
// Menu bar setup must go between sharedApplication above and
// finishLaunching below, in order to properly emulate the behavior