Fix X11 error when closing the game on Linux

This commit is contained in:
UnknownShadow200 2024-06-26 19:53:19 +10:00
parent 9607fa2cf1
commit 79a996d6cd
29 changed files with 66 additions and 8 deletions

View File

@ -852,4 +852,5 @@ void Game_Run(int width, int height, const cc_string* title) {
frameStart = Stopwatch_Measure();
Game_RunLoop();
Window_Destroy();
}

View File

@ -297,6 +297,7 @@ void Launcher_Run(void) {
cc_result res = Updater_Start(&action);
if (res) Logger_SysWarn(res, action);
}
Window_Destroy();
}

View File

@ -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);

View File

@ -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) { }

View File

@ -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 */

View File

@ -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);

View File

@ -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) { }

View File

@ -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);
}

View File

@ -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
}

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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;

View File

@ -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) { }

View File

@ -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

View File

@ -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) { }

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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
}

View File

@ -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];

View File

@ -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);
}

View File

@ -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);

View File

@ -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;
}

View File

@ -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) { }

View File

@ -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) { }

View File

@ -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;

View File

@ -722,6 +722,8 @@ void Window_Create3D(int width, int height) {
Init3DLayer();
}
void Window_Destroy(void) { }
/*########################################################################################################################*
*--------------------------------------------------------GLContext--------------------------------------------------------*