diff --git a/src/Game.c b/src/Game.c index 145c74901..7ff1cdb7c 100644 --- a/src/Game.c +++ b/src/Game.c @@ -852,4 +852,5 @@ void Game_Run(int width, int height, const cc_string* title) { frameStart = Stopwatch_Measure(); Game_RunLoop(); + Window_Destroy(); } diff --git a/src/Launcher.c b/src/Launcher.c index eeace9ecd..d15dda6a1 100644 --- a/src/Launcher.c +++ b/src/Launcher.c @@ -297,6 +297,7 @@ void Launcher_Run(void) { cc_result res = Updater_Start(&action); if (res) Logger_SysWarn(res, action); } + Window_Destroy(); } diff --git a/src/Window.h b/src/Window.h index 23dc63988..53ea6add7 100644 --- a/src/Window.h +++ b/src/Window.h @@ -117,6 +117,9 @@ void Window_Create2D(int width, int height); /* Creates a window of the given size at centre of the screen. */ /* NOTE: The created window is compatible with 3D rendering */ void Window_Create3D(int width, int height); +/* Destroys the window. */ +void Window_Destroy(void); + /* Sets the text of the titlebar above the window. */ CC_API void Window_SetTitle(const cc_string* title); diff --git a/src/Window_3DS.c b/src/Window_3DS.c index 1c08ac342..8e19a7a4e 100644 --- a/src/Window_3DS.c +++ b/src/Window_3DS.c @@ -75,6 +75,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_Android.c b/src/Window_Android.c index 434a13000..b513b6374 100644 --- a/src/Window_Android.c +++ b/src/Window_Android.c @@ -340,6 +340,8 @@ static void DoCreateWindow(void) { void Window_Create2D(int width, int height) { DoCreateWindow(); } void Window_Create3D(int width, int height) { DoCreateWindow(); } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { /* TODO: Implement this somehow */ /* Maybe https://stackoverflow.com/questions/2198410/how-to-change-title-of-activity-in-android */ diff --git a/src/Window_BeOS.cpp b/src/Window_BeOS.cpp index ff5f6d11c..81f8144d5 100644 --- a/src/Window_BeOS.cpp +++ b/src/Window_BeOS.cpp @@ -375,6 +375,9 @@ void Window_Create3D(int width, int height) { win_handle->AddChild(view_handle); } +void Window_Destroy(void) { +} + void Window_SetTitle(const cc_string* title) { char raw[NATIVE_STR_LEN]; String_EncodeUtf8(raw, title); diff --git a/src/Window_Dreamcast.c b/src/Window_Dreamcast.c index 78c5c8ffc..1f6fe9fdf 100644 --- a/src/Window_Dreamcast.c +++ b/src/Window_Dreamcast.c @@ -62,6 +62,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_GCWii.c b/src/Window_GCWii.c index 55796d0cb..be20637b5 100644 --- a/src/Window_GCWii.c +++ b/src/Window_GCWii.c @@ -102,6 +102,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_RequestClose(void) { Event_RaiseVoid(&WindowEvents.Closing); } diff --git a/src/Window_MacClassic.c b/src/Window_MacClassic.c index 7bdc534d1..59ee050ca 100644 --- a/src/Window_MacClassic.c +++ b/src/Window_MacClassic.c @@ -216,6 +216,8 @@ 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_SetTitle(const cc_string* title) { // TODO } diff --git a/src/Window_N64.c b/src/Window_N64.c index f7cacab4f..8ae2104bf 100644 --- a/src/Window_N64.c +++ b/src/Window_N64.c @@ -65,6 +65,8 @@ void Window_Free(void) { } void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_NDS.c b/src/Window_NDS.c index 3cef377a0..4bf6f9497 100644 --- a/src/Window_NDS.c +++ b/src/Window_NDS.c @@ -175,6 +175,8 @@ void Window_Create3D(int width, int height) { videoSetMode(MODE_0_3D); } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_PS1.c b/src/Window_PS1.c index eb6417910..ab7b375a0 100644 --- a/src/Window_PS1.c +++ b/src/Window_PS1.c @@ -58,10 +58,15 @@ void Window_Init(void) { void Window_Free(void) { } +void Window_Create2D(int width, int height) { + launcherMode = true; +} void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } @@ -145,10 +150,6 @@ void Window_ProcessGamepads(float delta) { /*########################################################################################################################* *------------------------------------------------------Framebuffer--------------------------------------------------------* *#########################################################################################################################*/ -void Window_Create2D(int width, int height) { - launcherMode = true; -} - static DISPENV disp; static cc_uint16* fb; diff --git a/src/Window_PS2.c b/src/Window_PS2.c index ab976e977..98df03426 100644 --- a/src/Window_PS2.c +++ b/src/Window_PS2.c @@ -125,6 +125,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_PS3.c b/src/Window_PS3.c index 78a7a1c65..a8dd56ad1 100644 --- a/src/Window_PS3.c +++ b/src/Window_PS3.c @@ -82,6 +82,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } // TODO sceClipboardGetText void Clipboard_SetText(const cc_string* value) { } // TODO sceClipboardSetText diff --git a/src/Window_PSP.c b/src/Window_PSP.c index ed48ba248..f0f39fb34 100644 --- a/src/Window_PSP.c +++ b/src/Window_PSP.c @@ -53,6 +53,8 @@ void Window_Free(void) { } void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_PSVita.c b/src/Window_PSVita.c index a1f418ead..c246ab2ca 100644 --- a/src/Window_PSVita.c +++ b/src/Window_PSVita.c @@ -70,6 +70,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } // TODO sceClipboardGetText void Clipboard_SetText(const cc_string* value) { } // TODO sceClipboardSetText diff --git a/src/Window_SDL.c b/src/Window_SDL.c index e08c009ae..f9e033059 100644 --- a/src/Window_SDL.c +++ b/src/Window_SDL.c @@ -106,6 +106,8 @@ void Window_Create3D(int width, int height) { DoCreateWindow(width, height, SDL_ void Window_Create3D(int width, int height) { DoCreateWindow(width, height, 0); } #endif +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { char str[NATIVE_STR_LEN]; String_EncodeUtf8(str, title); diff --git a/src/Window_SDL3.c b/src/Window_SDL3.c index 792ad94e4..2404d304d 100644 --- a/src/Window_SDL3.c +++ b/src/Window_SDL3.c @@ -90,6 +90,8 @@ void Window_Create3D(int width, int height) { DoCreateWindow(width, height, SDL_ void Window_Create3D(int width, int height) { DoCreateWindow(width, height, 0); } #endif +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { char str[NATIVE_STR_LEN]; String_EncodeUtf8(str, title); diff --git a/src/Window_Saturn.c b/src/Window_Saturn.c index a8f186ce0..3dd4f26d4 100644 --- a/src/Window_Saturn.c +++ b/src/Window_Saturn.c @@ -61,6 +61,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_Switch.c b/src/Window_Switch.c index 2fdd11ff8..41e093673 100644 --- a/src/Window_Switch.c +++ b/src/Window_Switch.c @@ -92,6 +92,8 @@ void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_Terminal.c b/src/Window_Terminal.c index 82b898544..05de9aa0b 100644 --- a/src/Window_Terminal.c +++ b/src/Window_Terminal.c @@ -433,6 +433,8 @@ 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_SetTitle(const cc_string* title) { // TODO } diff --git a/src/Window_Web.c b/src/Window_Web.c index f4f7085e9..17d25cd56 100644 --- a/src/Window_Web.c +++ b/src/Window_Web.c @@ -439,6 +439,8 @@ static void DoCreateWindow(void) { void Window_Create2D(int width, int height) { DoCreateWindow(); } void Window_Create3D(int width, int height) { DoCreateWindow(); } +void Window_Destroy(void) { } + extern void interop_SetPageTitle(const char* title); void Window_SetTitle(const cc_string* title) { char str[NATIVE_STR_LEN]; diff --git a/src/Window_WiiU.cpp b/src/Window_WiiU.cpp index 028108391..b14125bb8 100644 --- a/src/Window_WiiU.cpp +++ b/src/Window_WiiU.cpp @@ -136,6 +136,8 @@ void Window_Create3D(int width, int height) { Event_Unregister_(&WindowEvents.InactiveChanged, NULL, LauncherInactiveChanged); } +void Window_Destroy(void) { } + void Window_RequestClose(void) { Event_RaiseVoid(&WindowEvents.Closing); } diff --git a/src/Window_Win.c b/src/Window_Win.c index 40169aa8f..de042a45b 100644 --- a/src/Window_Win.c +++ b/src/Window_Win.c @@ -404,6 +404,8 @@ 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_SetTitle(const cc_string* title) { cc_winstring str; Platform_EncodeString(&str, title); diff --git a/src/Window_X11.c b/src/Window_X11.c index f56a5f43a..49ad7170c 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -404,6 +404,13 @@ 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) { + /* sync and discard all events queued */ + XSync(win_display, true); + XDestroyWindow(win_display, win_handle); + Window_Main.Exists = false; +} + void Window_SetTitle(const cc_string* title) { char str[NATIVE_STR_LEN]; String_EncodeUtf8(str, title); @@ -567,10 +574,6 @@ static Bool FilterEvent(Display* d, XEvent* e, XPointer w) { static void HandleWMDestroy(void) { Platform_LogConst("Exit message received."); Event_RaiseVoid(&WindowEvents.Closing); - - /* sync and discard all events queued */ - XSync(win_display, true); - XDestroyWindow(win_display, win_handle); Window_Main.Exists = false; } diff --git a/src/Window_Xbox.c b/src/Window_Xbox.c index d439f8a51..dc6e5a5ed 100644 --- a/src/Window_Xbox.c +++ b/src/Window_Xbox.c @@ -97,6 +97,8 @@ void Window_Free(void) { usbh_core_deinit(); } void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_Xbox360.c b/src/Window_Xbox360.c index 0b0d4e6c1..467da0041 100644 --- a/src/Window_Xbox360.c +++ b/src/Window_Xbox360.c @@ -56,6 +56,8 @@ void Window_Free(void) { } void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } +void Window_Destroy(void) { } + void Window_SetTitle(const cc_string* title) { } void Clipboard_GetText(cc_string* value) { } void Clipboard_SetText(const cc_string* value) { } diff --git a/src/Window_cocoa.m b/src/Window_cocoa.m index 4cb04d0f6..589fa7096 100644 --- a/src/Window_cocoa.m +++ b/src/Window_cocoa.m @@ -395,6 +395,8 @@ 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_SetTitle(const cc_string* title) { char raw[NATIVE_STR_LEN]; NSString* str; diff --git a/src/interop_ios.m b/src/interop_ios.m index df3e344e3..60d851df3 100644 --- a/src/interop_ios.m +++ b/src/interop_ios.m @@ -722,6 +722,8 @@ void Window_Create3D(int width, int height) { Init3DLayer(); } +void Window_Destroy(void) { } + /*########################################################################################################################* *--------------------------------------------------------GLContext--------------------------------------------------------*