Skip to content

Commit aa8e09d

Browse files
dougbinksocornut
authored andcommitted
Backends: GLFW: workaround for cases where glfwGetMonitorWorkarea fails (ocornut#3457)
1 parent 36c331f commit aa8e09d

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

examples/imgui_impl_glfw.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -442,16 +442,16 @@ static void ImGui_ImplGlfw_UpdateMonitors()
442442
int x, y;
443443
glfwGetMonitorPos(glfw_monitors[n], &x, &y);
444444
const GLFWvidmode* vid_mode = glfwGetVideoMode(glfw_monitors[n]);
445+
monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y);
446+
monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
445447
#if GLFW_HAS_MONITOR_WORK_AREA
446-
monitor.MainPos = ImVec2((float)x, (float)y);
447-
monitor.MainSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
448448
int w, h;
449449
glfwGetMonitorWorkarea(glfw_monitors[n], &x, &y, &w, &h);
450-
monitor.WorkPos = ImVec2((float)x, (float)y);;
451-
monitor.WorkSize = ImVec2((float)w, (float)h);
452-
#else
453-
monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y);
454-
monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
450+
if (w > 0 && h > 0) // Workaround a small GLFW issue reporting zero on monitor changes: https://github.com/glfw/glfw/pull/1761
451+
{
452+
monitor.WorkPos = ImVec2((float)x, (float)y);
453+
monitor.WorkSize = ImVec2((float)w, (float)h);
454+
}
455455
#endif
456456
#if GLFW_HAS_PER_MONITOR_DPI
457457
// Warning: the validity of monitor DPI information on Windows depends on the application DPI awareness settings, which generally needs to be set in the manifest or at runtime.

0 commit comments

Comments
 (0)