diff --git a/src/Game.h b/src/Game.h index d351da717..d34d61540 100644 --- a/src/Game.h +++ b/src/Game.h @@ -30,7 +30,7 @@ extern int Game_NumLocalPlayers; #if defined CC_BUILD_N64 #define DEFAULT_VIEWDIST 20 -#elif defined CC_BUILD_NDS || defined CC_BUILD_PS1 +#elif defined CC_BUILD_NDS || defined CC_BUILD_PS1 || defined CC_BUILD_SATURN #define DEFAULT_VIEWDIST 192 #else #define DEFAULT_VIEWDIST 512 diff --git a/src/Input.c b/src/Input.c index c0dfd09b2..d7a6b3da1 100644 --- a/src/Input.c +++ b/src/Input.c @@ -1353,7 +1353,6 @@ static void OnInputDown(void* obj, int key, cc_bool was) { #endif if (InputHandler_IsShutdown(key)) { - /* TODO: Do we need a separate exit function in Game class? */ Window_RequestClose(); return; } else if (InputBind_Claims(BIND_SCREENSHOT, key) && !was) { Game_ScreenshotRequested = true; return; diff --git a/src/Menus.c b/src/Menus.c index 42ef076b4..17b410702 100644 --- a/src/Menus.c +++ b/src/Menus.c @@ -498,8 +498,13 @@ static struct PauseScreen { struct TextWidget title; } PauseScreen; -static void PauseScreenBase_Quit(void* a, void* b) { Window_RequestClose(); } -static void PauseScreenBase_Game(void* a, void* b) { Gui_Remove((struct Screen*)&PauseScreen); } +static void PauseScreenBase_Quit(void* a, void* b) { + Window_RequestClose(); +} + +static void PauseScreenBase_Game(void* a, void* b) { + Gui_Remove((struct Screen*)&PauseScreen); +} static void PauseScreenBase_ContextRecreated(struct PauseScreen* s, struct FontDesc* titleFont) { Screen_UpdateVb(s); diff --git a/src/Screens.c b/src/Screens.c index 54a5f012b..e7bb01d6b 100644 --- a/src/Screens.c +++ b/src/Screens.c @@ -2111,7 +2111,10 @@ static void DisconnectScreen_OnReconnect(void* s, void* w) { Gui_ShowDefault(); Server.BeginConnect(); } -static void DisconnectScreen_OnQuit(void* s, void* w) { Window_RequestClose(); } + +static void DisconnectScreen_OnQuit(void* s, void* w) { + Window_RequestClose(); +} static void DisconnectScreen_Init(void* screen) { struct DisconnectScreen* s = (struct DisconnectScreen*)screen; diff --git a/src/Window_BeOS.cpp b/src/Window_BeOS.cpp index 39a5206fb..42e59a1e0 100644 --- a/src/Window_BeOS.cpp +++ b/src/Window_BeOS.cpp @@ -465,8 +465,7 @@ void Window_SetSize(int width, int height) { } void Window_RequestClose(void) { - BMessage* msg = new BMessage(B_QUIT_REQUESTED); - app_handle->PostMessage(msg); + Event_RaiseVoid(&WindowEvents.Closing); } static const cc_uint8 key_map[] = { @@ -538,7 +537,7 @@ void Window_ProcessEvents(float delta) { break; case CC_WIN_QUIT: Window_Main.Exists = false; - Event_RaiseVoid(&WindowEvents.Closing); + Window_RequestClose(); break; case CC_RAW_MOUSE: if (Input.RawMode) Event_RaiseRawMove(&PointerEvents.RawMoved, event.v1.i32, event.v2.i32); diff --git a/src/Window_Win.c b/src/Window_Win.c index 3d09e8b19..6b0e13ef3 100644 --- a/src/Window_Win.c +++ b/src/Window_Win.c @@ -282,16 +282,12 @@ static LRESULT CALLBACK Window_Procedure(HWND handle, UINT message, WPARAM wPara break; case WM_CLOSE: - Event_RaiseVoid(&WindowEvents.Closing); - if (Window_Main.Exists) DestroyWindow(win_handle); Window_Main.Exists = false; - break; + Window_RequestClose(); + return 0; case WM_DESTROY: - Window_Main.Exists = false; UnregisterClassW(CC_WIN_CLASSNAME, win_instance); - - if (win_DC) ReleaseDC(win_handle, win_DC); break; } return is_ansiWindow ? DefWindowProcA(handle, message, wParam, lParam) @@ -404,7 +400,10 @@ static void DoCreateWindow(int width, int height) { void Window_Create2D(int width, int height) { DoCreateWindow(width, height); } void Window_Create3D(int width, int height) { DoCreateWindow(width, height); } -void Window_Destroy(void) { } +void Window_Destroy(void) { + if (win_DC) ReleaseDC(win_handle, win_DC); + DestroyWindow(win_handle); +} void Window_SetTitle(const cc_string* title) { cc_winstring str; @@ -544,7 +543,7 @@ void Window_SetSize(int width, int height) { } void Window_RequestClose(void) { - PostMessageA(win_handle, WM_CLOSE, 0, 0); + Event_RaiseVoid(&WindowEvents.Closing); } void Window_ProcessEvents(float delta) { diff --git a/src/Window_X11.c b/src/Window_X11.c index e003d4d40..8872271ec 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -513,15 +513,7 @@ void Window_SetSize(int width, int height) { } void Window_RequestClose(void) { - XEvent ev = { 0 }; - ev.type = ClientMessage; - ev.xclient.format = 32; - ev.xclient.display = win_display; - ev.xclient.window = win_handle; - ev.xclient.data.l[0] = wm_destroy; - - XSendEvent(win_display, win_handle, false, 0, &ev); - XFlush(win_display); + Event_RaiseVoid(&WindowEvents.Closing); } static int MapNativeMouse(int button) { diff --git a/src/interop_ios.m b/src/interop_ios.m index 4f9c6e3d6..cd4bf4d64 100644 --- a/src/interop_ios.m +++ b/src/interop_ios.m @@ -437,8 +437,7 @@ void Window_Show(void) { } void Window_RequestClose(void) { - Window_Main.Exists = false; - Event_RaiseVoid(&WindowEvents.Closing); + Event_RaiseVoid(&WindowEvents.Closing); } void Window_ProcessEvents(float delta) {