Skip to content

Commit

Permalink
Backends: GLFW: workaround for cases where glfwGetMonitorWorkarea fai…
Browse files Browse the repository at this point in the history
…ls (ocornut#3457)
  • Loading branch information
dougbinks authored and ocornut committed Sep 7, 2020
1 parent 36c331f commit aa8e09d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions examples/imgui_impl_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -442,16 +442,16 @@ static void ImGui_ImplGlfw_UpdateMonitors()
int x, y;
glfwGetMonitorPos(glfw_monitors[n], &x, &y);
const GLFWvidmode* vid_mode = glfwGetVideoMode(glfw_monitors[n]);
monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y);
monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
#if GLFW_HAS_MONITOR_WORK_AREA
monitor.MainPos = ImVec2((float)x, (float)y);
monitor.MainSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
int w, h;
glfwGetMonitorWorkarea(glfw_monitors[n], &x, &y, &w, &h);
monitor.WorkPos = ImVec2((float)x, (float)y);;
monitor.WorkSize = ImVec2((float)w, (float)h);
#else
monitor.MainPos = monitor.WorkPos = ImVec2((float)x, (float)y);
monitor.MainSize = monitor.WorkSize = ImVec2((float)vid_mode->width, (float)vid_mode->height);
if (w > 0 && h > 0) // Workaround a small GLFW issue reporting zero on monitor changes: https://github.com/glfw/glfw/pull/1761
{
monitor.WorkPos = ImVec2((float)x, (float)y);
monitor.WorkSize = ImVec2((float)w, (float)h);
}
#endif
#if GLFW_HAS_PER_MONITOR_DPI
// 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.
Expand Down

0 comments on commit aa8e09d

Please sign in to comment.