mirror of
https://github.com/HarbourMasters/Shipwright.git
synced 2025-08-22 14:23:44 -07:00
Fixed closing window issue on linux
This commit is contained in:
parent
076887e71f
commit
518373db23
2 changed files with 8 additions and 7 deletions
|
@ -156,6 +156,7 @@ static struct {
|
|||
Atom atom_wm_delete_window;
|
||||
|
||||
bool is_fullscreen;
|
||||
bool is_running = true;
|
||||
void (*on_fullscreen_changed)(bool is_now_fullscreen);
|
||||
|
||||
int keymap[256];
|
||||
|
@ -399,7 +400,7 @@ static void gfx_glx_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bo
|
|||
}
|
||||
|
||||
static void gfx_glx_main_loop(void (*run_one_game_iter)(void)) {
|
||||
while (1) {
|
||||
while (glx.is_running) {
|
||||
run_one_game_iter();
|
||||
}
|
||||
}
|
||||
|
@ -440,7 +441,7 @@ static void gfx_glx_handle_events(void) {
|
|||
}
|
||||
}
|
||||
if (xev.type == ClientMessage && (Atom)xev.xclient.data.l[0] == glx.atom_wm_delete_window) {
|
||||
exit(0);
|
||||
glx.is_running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,6 +37,7 @@ static int vsync_enabled = 0;
|
|||
static unsigned int window_width = DESIRED_SCREEN_WIDTH;
|
||||
static unsigned int window_height = DESIRED_SCREEN_HEIGHT;
|
||||
static bool fullscreen_state;
|
||||
static bool is_running = true;
|
||||
static void (*on_fullscreen_changed_callback)(bool is_now_fullscreen);
|
||||
static bool (*on_key_down_callback)(int scancode);
|
||||
static bool (*on_key_up_callback)(int scancode);
|
||||
|
@ -135,7 +136,7 @@ static void gfx_sdl_init(const char *game_name, bool start_in_fullscreen) {
|
|||
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
|
||||
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
|
||||
|
||||
#ifndef __linux
|
||||
#ifndef __linux__
|
||||
timer = CreateWaitableTimer(nullptr, false, nullptr);
|
||||
#endif
|
||||
|
||||
|
@ -194,14 +195,13 @@ static void gfx_sdl_set_keyboard_callbacks(bool (*on_key_down)(int scancode), bo
|
|||
}
|
||||
|
||||
static void gfx_sdl_main_loop(void (*run_one_game_iter)(void)) {
|
||||
while (1)
|
||||
{
|
||||
while(is_running) {
|
||||
run_one_game_iter();
|
||||
}
|
||||
}
|
||||
|
||||
static void gfx_sdl_get_dimensions(uint32_t *width, uint32_t *height) {
|
||||
*width = window_width;
|
||||
*width = window_width;
|
||||
*height = window_height;
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ static void gfx_sdl_handle_events(void) {
|
|||
}
|
||||
break;
|
||||
case SDL_QUIT:
|
||||
exit(0);
|
||||
is_running = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue