Fix GLFW3 not handling exit event while not focussed
This commit is contained in:
parent
8549fa561e
commit
fd0733f6e7
4 changed files with 13 additions and 15 deletions
|
@ -25,8 +25,6 @@
|
||||||
keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \
|
keyboard_state[BACKEND_KEY] = action == GLFW_PRESS; \
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BOOL bActive = TRUE;
|
|
||||||
|
|
||||||
static BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
static BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
|
|
||||||
static GLFWcursor* cursor;
|
static GLFWcursor* cursor;
|
||||||
|
@ -272,7 +270,7 @@ void PlaybackBackend_EnableDragAndDrop(void)
|
||||||
glfwSetDropCallback(window, DragAndDropCallback);
|
glfwSetDropCallback(window, DragAndDropCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Backend_SystemTask(void)
|
BOOL Backend_SystemTask(BOOL active)
|
||||||
{
|
{
|
||||||
if (glfwWindowShouldClose(window))
|
if (glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
@ -280,9 +278,9 @@ BOOL Backend_SystemTask(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (active)
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
|
else
|
||||||
while (!bActive)
|
|
||||||
glfwWaitEvents();
|
glfwWaitEvents();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
|
|
@ -84,8 +84,6 @@ enum
|
||||||
BACKEND_KEYBOARD_TOTAL
|
BACKEND_KEYBOARD_TOTAL
|
||||||
};
|
};
|
||||||
|
|
||||||
extern BOOL bActive;
|
|
||||||
|
|
||||||
BOOL Backend_Init(void);
|
BOOL Backend_Init(void);
|
||||||
void Backend_Deinit(void);
|
void Backend_Deinit(void);
|
||||||
void Backend_PostWindowCreation(void);
|
void Backend_PostWindowCreation(void);
|
||||||
|
@ -94,7 +92,7 @@ void Backend_HideMouse(void);
|
||||||
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
||||||
void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
||||||
void PlaybackBackend_EnableDragAndDrop(void);
|
void PlaybackBackend_EnableDragAndDrop(void);
|
||||||
BOOL Backend_SystemTask(void);
|
BOOL Backend_SystemTask(BOOL active);
|
||||||
void Backend_GetKeyboardState(BOOL *keyboard_state);
|
void Backend_GetKeyboardState(BOOL *keyboard_state);
|
||||||
void Backend_ShowMessageBox(const char *title, const char *message);
|
void Backend_ShowMessageBox(const char *title, const char *message);
|
||||||
ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintError(const char *format, ...);
|
ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintError(const char *format, ...);
|
||||||
|
|
|
@ -23,8 +23,6 @@
|
||||||
keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \
|
keyboard_state[BACKEND_KEY] = event.key.type == SDL_KEYDOWN; \
|
||||||
break;
|
break;
|
||||||
|
|
||||||
BOOL bActive = TRUE;
|
|
||||||
|
|
||||||
static BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
static BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
|
|
||||||
static unsigned char *cursor_surface_pixels;
|
static unsigned char *cursor_surface_pixels;
|
||||||
|
@ -157,9 +155,9 @@ void PlaybackBackend_EnableDragAndDrop(void)
|
||||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL Backend_SystemTask(void)
|
BOOL Backend_SystemTask(BOOL active)
|
||||||
{
|
{
|
||||||
while (SDL_PollEvent(NULL) || !bActive)
|
if (SDL_PollEvent(NULL) || !active)
|
||||||
{
|
{
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
|
|
||||||
|
|
|
@ -33,6 +33,7 @@ BOOL gbUseJoystick = FALSE;
|
||||||
|
|
||||||
int gJoystickButtonTable[8];
|
int gJoystickButtonTable[8];
|
||||||
|
|
||||||
|
static BOOL bActive = TRUE;
|
||||||
static BOOL bFps = FALSE;
|
static BOOL bFps = FALSE;
|
||||||
|
|
||||||
static int windowWidth;
|
static int windowWidth;
|
||||||
|
@ -388,8 +389,11 @@ BOOL SystemTask(void)
|
||||||
{
|
{
|
||||||
static BOOL previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
static BOOL previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
|
|
||||||
if (!Backend_SystemTask())
|
do
|
||||||
|
{
|
||||||
|
if (!Backend_SystemTask(bActive))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
} while(!bActive);
|
||||||
|
|
||||||
BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
BOOL keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
Backend_GetKeyboardState(keyboard_state);
|
Backend_GetKeyboardState(keyboard_state);
|
||||||
|
|
Loading…
Add table
Reference in a new issue