1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

macOS: Embedded window can be dismissed by clicking close

- Installed a SIGINT handler to terminate the application gracefully.
- Handle varying display scaling
This commit is contained in:
Stuart Carnie
2025-05-08 18:51:28 +10:00
parent 19bb18716e
commit f658161619
12 changed files with 144 additions and 70 deletions

View File

@@ -131,6 +131,8 @@ static void _setup_clock() {
}
#endif
struct sigaction old_action;
static void handle_interrupt(int sig) {
if (!EngineDebugger::is_active()) {
return;
@@ -138,6 +140,11 @@ static void handle_interrupt(int sig) {
EngineDebugger::get_script_debugger()->set_depth(-1);
EngineDebugger::get_script_debugger()->set_lines_left(1);
// Ensure we call the old action if it was configured.
if (old_action.sa_handler && old_action.sa_handler != SIG_IGN && old_action.sa_handler != SIG_DFL) {
old_action.sa_handler(sig);
}
}
void OS_Unix::initialize_debugging() {
@@ -145,7 +152,7 @@ void OS_Unix::initialize_debugging() {
struct sigaction action;
memset(&action, 0, sizeof(action));
action.sa_handler = handle_interrupt;
sigaction(SIGINT, &action, nullptr);
sigaction(SIGINT, &action, &old_action);
}
}