mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-09-15 10:35:11 -04:00
Simplify window closing
This commit is contained in:
parent
89e47e7a2a
commit
2f4eeb6aec
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user