diff --git a/src/Program.c b/src/Program.c index ffb930315..474ebac54 100644 --- a/src/Program.c +++ b/src/Program.c @@ -144,6 +144,8 @@ int main(int argc, char** argv) { while (WindowInfo.Exists) { RunProgram(argc, argv); } + + Window_Free(); return 0; } #else diff --git a/src/Window.h b/src/Window.h index 972e3df73..2092fb6a1 100644 --- a/src/Window.h +++ b/src/Window.h @@ -86,8 +86,10 @@ CC_VAR extern struct _WinData { cc_bool Inactive; } WindowInfo; -/* Initialises state for window. Also sets Display_ members. */ +/* Initialises state for window, input, and display. */ void Window_Init(void); +/* Potentially frees/resets state for window, input, and display. */ +void Window_Free(void); /* Creates a window of the given size at centre of the screen. */ /* NOTE: The created window is compatible with 2D drawing */ void Window_Create2D(int width, int height); diff --git a/src/Window_3DS.c b/src/Window_3DS.c index 8f3dfcf90..977667faf 100644 --- a/src/Window_3DS.c +++ b/src/Window_3DS.c @@ -54,6 +54,8 @@ void Window_Init(void) { irrst_result = irrstInit(); } +void Window_Free(void) { irrstExit(); } + void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } @@ -130,8 +132,8 @@ void Window_ProcessEvents(double delta) { /* TODO implement */ if (!aptMainLoop()) { - Event_RaiseVoid(&WindowEvents.Closing); WindowInfo.Exists = false; + Window_RequestClose(); return; } diff --git a/src/Window_Android.c b/src/Window_Android.c index 16b55f88d..e374cc1fb 100644 --- a/src/Window_Android.c +++ b/src/Window_Android.c @@ -289,6 +289,8 @@ void Window_Init(void) { DisplayInfo.ScaleY = JavaICall_Float(env, JAVA_getDpiY, NULL); } +void Window_Free(void) { } + static void RemakeWindowSurface(void) { JNIEnv* env; JavaGetCurrentEnv(env); diff --git a/src/Window_Carbon.c b/src/Window_Carbon.c index 8b9efd994..3aaf82ec5 100644 --- a/src/Window_Carbon.c +++ b/src/Window_Carbon.c @@ -439,6 +439,8 @@ static void HookEvents(void) { *#########################################################################################################################*/ void Window_Init(void) { Window_CommonInit(); } +void Window_Free(void) { } + /* Private CGS/CGL stuff */ typedef int CGSConnectionID; typedef int CGSWindowID; diff --git a/src/Window_Dreamcast.c b/src/Window_Dreamcast.c index 1f2d4c7fc..10382f2ed 100644 --- a/src/Window_Dreamcast.c +++ b/src/Window_Dreamcast.c @@ -36,6 +36,8 @@ void Window_Init(void) { DisplayInfo.ContentOffsetY = 20; } +void Window_Free(void) { } + void Window_Create2D(int width, int height) { launcherMode = true; vid_set_mode(DEFAULT_VID_MODE, PM_RGB888); diff --git a/src/Window_GCWii.c b/src/Window_GCWii.c index 25e4962f4..ce2274f34 100644 --- a/src/Window_GCWii.c +++ b/src/Window_GCWii.c @@ -87,6 +87,8 @@ void Window_Init(void) { PAD_Init(); } +void Window_Free(void) { } + void Window_Create2D(int width, int height) { needsFBUpdate = true; launcherMode = true; diff --git a/src/Window_N64.c b/src/Window_N64.c index dea2aff6e..5448c0ad0 100644 --- a/src/Window_N64.c +++ b/src/Window_N64.c @@ -38,9 +38,11 @@ void Window_Init(void) { Input.Sources = INPUT_SOURCE_GAMEPAD; DisplayInfo.ContentOffsetX = 10; DisplayInfo.ContentOffsetY = 10; - joypad_init(); + joypad_init(); } +void Window_Free(void) { } + void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } diff --git a/src/Window_PS2.c b/src/Window_PS2.c index c6dfc4455..03600946a 100644 --- a/src/Window_PS2.c +++ b/src/Window_PS2.c @@ -50,6 +50,8 @@ void Window_Init(void) { padPortOpen(0, 0, padBuf); } +void Window_Free(void) { } + static cc_bool hasCreated; static void ResetGfxState(void) { if (!hasCreated) { hasCreated = true; return; } diff --git a/src/Window_PS3.c b/src/Window_PS3.c index 22f40792f..053b8c4a1 100644 --- a/src/Window_PS3.c +++ b/src/Window_PS3.c @@ -68,6 +68,8 @@ void Window_Init(void) { ioKbGetConfiguration(0, &kb_config); } +void Window_Free(void) { } + void Window_Create2D(int width, int height) { launcherMode = true; Gfx_Create(); // launcher also uses RSX to draw diff --git a/src/Window_PSP.c b/src/Window_PSP.c index 52bff6927..4becc0bac 100644 --- a/src/Window_PSP.c +++ b/src/Window_PSP.c @@ -42,6 +42,8 @@ void Window_Init(void) { sceCtrlSetSamplingMode(PSP_CTRL_MODE_ANALOG); } +void Window_Free(void) { } + void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } diff --git a/src/Window_PSVita.c b/src/Window_PSVita.c index ea8209213..60b08b707 100644 --- a/src/Window_PSVita.c +++ b/src/Window_PSVita.c @@ -56,6 +56,8 @@ void Window_Init(void) { Gfx_AllocFramebuffers(); } +void Window_Free(void) { } + void Window_Create2D(int width, int height) { launcherMode = true; DQ_OnNextFrame = DQ_OnNextFrame2D; diff --git a/src/Window_SDL.c b/src/Window_SDL.c index 34bfb0fe6..7460ef51a 100644 --- a/src/Window_SDL.c +++ b/src/Window_SDL.c @@ -38,6 +38,8 @@ void Window_Init(void) { DisplayInfo.ScaleY = 1; } +void Window_Free(void) { } + static void DoCreateWindow(int width, int height, int flags) { int x = Display_CentreX(width); int y = Display_CentreY(height); diff --git a/src/Window_Web.c b/src/Window_Web.c index 99ff73987..675185f6e 100644 --- a/src/Window_Web.c +++ b/src/Window_Web.c @@ -394,6 +394,8 @@ void Window_Init(void) { interop_ForceTouchPageLayout(); } +void Window_Free(void) { } + extern void interop_InitContainer(void); static void DoCreateWindow(void) { WindowInfo.Exists = true; diff --git a/src/Window_Win.c b/src/Window_Win.c index 2a3a57e0b..499758f78 100644 --- a/src/Window_Win.c +++ b/src/Window_Win.c @@ -307,6 +307,8 @@ void Window_Init(void) { DisplayInfo.Depth *= GetDeviceCaps(hdc, PLANES); } +void Window_Free(void) { } + static ATOM DoRegisterClass(void) { ATOM atom; WNDCLASSEXW wc = { 0 }; diff --git a/src/Window_X11.c b/src/Window_X11.c index 033aba7cf..f57dea3e0 100644 --- a/src/Window_X11.c +++ b/src/Window_X11.c @@ -270,6 +270,8 @@ void Window_Init(void) { DisplayInfo.ScaleY = 1; } +void Window_Free(void) { } + #ifdef CC_BUILD_ICON /* See misc/linux_icon_gen.cs for how to generate this file */ #include "_CCIcon_X11.h" diff --git a/src/Window_Xbox.c b/src/Window_Xbox.c index fad75b4e3..0e7a0cfed 100644 --- a/src/Window_Xbox.c +++ b/src/Window_Xbox.c @@ -85,6 +85,8 @@ void Window_Init(void) { OnDeviceChanged(NULL, 0); // TODO useless call? } +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; } diff --git a/src/Window_Xbox360.c b/src/Window_Xbox360.c index 71a02903a..fb61ac093 100644 --- a/src/Window_Xbox360.c +++ b/src/Window_Xbox360.c @@ -54,6 +54,8 @@ void Window_Init(void) { //xenon_atapi_init(); } +void Window_Free(void) { } + void Window_Create2D(int width, int height) { launcherMode = true; } void Window_Create3D(int width, int height) { launcherMode = false; } diff --git a/src/interop_BeOS.cpp b/src/interop_BeOS.cpp index abf658989..0985096b8 100644 --- a/src/interop_BeOS.cpp +++ b/src/interop_BeOS.cpp @@ -394,6 +394,8 @@ void Window_Init(void) { DisplayInfo.ScaleY = 1; } +void Window_Free(void) { } + static void DoCreateWindow(int width, int height) { // https://www.haiku-os.org/docs/api/classBRect.html#details // right/bottom coordinates are inclusive of the coordinates, diff --git a/src/interop_cocoa.m b/src/interop_cocoa.m index af5c864fe..1bde3e049 100644 --- a/src/interop_cocoa.m +++ b/src/interop_cocoa.m @@ -205,6 +205,8 @@ void Window_Init(void) { NSSetUncaughtExceptionHandler(LogUnhandledNSErrors); } +void Window_Free(void) { } + /*########################################################################################################################* *-----------------------------------------------------------Window--------------------------------------------------------* diff --git a/src/interop_ios.m b/src/interop_ios.m index 4a80efe87..95baca88a 100644 --- a/src/interop_ios.m +++ b/src/interop_ios.m @@ -373,6 +373,8 @@ void Window_Init(void) { DisplayInfo.ScaleY = 1; // TODO dpi scale } +void Window_Free(void) { } + static UIColor* CalcBackgroundColor(void) { // default to purple if no themed background color yet if (!Launcher_Theme.BackgroundColor)