[turbine/glfw] Treat close window event like other events with regard to a mandatory refresh period
All checks were successful
Build / build (push) Successful in 1m33s
All checks were successful
Build / build (push) Successful in 1m33s
This commit is contained in:
parent
94e1efee94
commit
18109f696d
@ -93,6 +93,14 @@ static void handleGlfwKeyEvent(GLFWwindow *window, int key, int, int action, int
|
||||
}
|
||||
}
|
||||
|
||||
static void handleGlfwWindowCloseEvent(GLFWwindow *window) noexcept {
|
||||
auto &ctx = *static_cast<Context*>(glfwGetWindowUserPointer(window));
|
||||
ctx.mandatoryRefreshPeriodEnd = ticksMs(ctx) + config::MandatoryRefreshPeriod;
|
||||
ctx.running = !ctx.shutdownHandler(ctx);
|
||||
glfwSetWindowShouldClose(window, !ctx.running);
|
||||
glfwPostEmptyEvent();
|
||||
}
|
||||
|
||||
#if TURBINE_USE_IMGUI
|
||||
static void themeImgui() noexcept {
|
||||
// Dark Ruda style by Raikiri from ImThemes
|
||||
@ -210,6 +218,7 @@ ox::Error initGfx(Context &ctx) noexcept {
|
||||
glfwSetCursorPosCallback(ctx.window, handleGlfwCursorPosEvent);
|
||||
glfwSetMouseButtonCallback(ctx.window, handleGlfwMouseButtonEvent);
|
||||
glfwSetKeyCallback(ctx.window, handleGlfwKeyEvent);
|
||||
glfwSetWindowCloseCallback(ctx.window, handleGlfwWindowCloseEvent);
|
||||
glfwSetWindowUserPointer(ctx.window, &ctx);
|
||||
glfwMakeContextCurrent(ctx.window);
|
||||
if (!gladLoadGLES2Loader(reinterpret_cast<GLADloadproc>(glfwGetProcAddress))) {
|
||||
|
@ -92,7 +92,7 @@ ox::Error run(Context &ctx) noexcept {
|
||||
ctx.wakeupTime = ticks + static_cast<unsigned>(st);
|
||||
sleepTime = static_cast<uint64_t>(st);
|
||||
} else {
|
||||
ctx.wakeupTime = ~uint64_t(0);
|
||||
ctx.wakeupTime = ~uint64_t{0};
|
||||
sleepTime = ctx.wakeupTime - ticks;
|
||||
}
|
||||
} else {
|
||||
@ -104,12 +104,6 @@ ox::Error run(Context &ctx) noexcept {
|
||||
if (realSleepTime && ctx.mandatoryRefreshPeriodEnd <= ticks) {
|
||||
glfwWaitEventsTimeout(static_cast<double>(realSleepTime) / 1000);
|
||||
}
|
||||
if (glfwWindowShouldClose(ctx.window)) {
|
||||
if (ctx.shutdownHandler(ctx)) {
|
||||
break;
|
||||
}
|
||||
glfwSetWindowShouldClose(ctx.window, false);
|
||||
}
|
||||
}
|
||||
shutdown(ctx);
|
||||
return {};
|
||||
|
Loading…
x
Reference in New Issue
Block a user