Skip to content

Commit 5602a6d

Browse files
authored
Merge pull request #49 from zao/fix/check-cfg-window-size
fix: clamp saved window size to minimum size
2 parents 6f8c80b + f32d325 commit 5602a6d

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

engine/core/core_video.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ void core_video_c::Apply(bool shown)
9292
set.flags|= VID_MAXIMIZE;
9393
} else if (vid_resizable->intVal == 3) {
9494
if (sscanf(vid_last->strVal.c_str(), "%d,%d,%d,%d,%d", set.save.size + 0, set.save.size + 1, set.save.pos + 0, set.save.pos + 1, (int*)&set.save.maximised) == 5) {
95+
// Clamp saved window size as it may be persisted as zero before.
96+
set.save.size[0] = (std::max)(CFG_VID_MINWIDTH, set.save.size[0]);
97+
set.save.size[1] = (std::max)(CFG_VID_MINHEIGHT, set.save.size[1]);
9598
set.flags|= VID_USESAVED;
9699
} else {
97100
set.flags|= VID_MAXIMIZE;

engine/system/win/sys_video.cpp

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -604,15 +604,21 @@ void sys_video_c::FramebufferSizeChanged(int width, int height) {
604604

605605
void sys_video_c::SizeChanged(int width, int height, bool max)
606606
{
607-
vid.size[0] = width;
608-
vid.size[1] = height;
609-
vid.maximised = max;
607+
// Avoid persisting an invalid window size from being minimized.
608+
if (!glfwGetWindowAttrib(wnd, GLFW_ICONIFIED)) {
609+
vid.size[0] = width;
610+
vid.size[1] = height;
611+
vid.maximised = max;
612+
}
610613
}
611614

612615
void sys_video_c::PosChanged(int x, int y)
613616
{
614-
vid.pos[0] = x;
615-
vid.pos[1] = y;
617+
// Avoid persisting an invalid window location from being minimized.
618+
if (!glfwGetWindowAttrib(wnd, GLFW_ICONIFIED)) {
619+
vid.pos[0] = x;
620+
vid.pos[1] = y;
621+
}
616622
}
617623

618624
void sys_video_c::GetMinSize(int& width, int& height)

0 commit comments

Comments
 (0)