Skip to content

Commit

Permalink
Viewports: added void* ImGuiPlatformMonitor::PlatformHandle field (ba…
Browse files Browse the repository at this point in the history
…ckend-dependant).
  • Loading branch information
ocornut committed Apr 21, 2023
1 parent 07e0703 commit 86af182
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions backends/imgui_impl_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -906,6 +906,7 @@ static void ImGui_ImplGlfw_UpdateMonitors()
glfwGetMonitorContentScale(glfw_monitors[n], &x_scale, &y_scale);
monitor.DpiScale = x_scale;
#endif
monitor.PlatformHandle = (void*)glfw_monitors[n]; // [...] GLFW doc states: "guaranteed to be valid only until the monitor configuration changes"
platform_io.Monitors.push_back(monitor);
}
}
Expand Down
1 change: 1 addition & 0 deletions backends/imgui_impl_osx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1048,6 +1048,7 @@ static void ImGui_ImplOSX_UpdateMonitors()
imgui_monitor.WorkPos = ImVec2(visibleFrame.origin.x, visibleFrame.origin.y);
imgui_monitor.WorkSize = ImVec2(visibleFrame.size.width, visibleFrame.size.height);
imgui_monitor.DpiScale = screen.backingScaleFactor;
imgui_monitor.PlatformHandle = (void*)screen;

platform_io.Monitors.push_back(imgui_monitor);
}
Expand Down
1 change: 1 addition & 0 deletions backends/imgui_impl_sdl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -718,6 +718,7 @@ static void ImGui_ImplSDL2_UpdateMonitors()
if (!SDL_GetDisplayDPI(n, &dpi, nullptr, nullptr))
monitor.DpiScale = dpi / 96.0f;
#endif
monitor.PlatformHandle = (void*)(intptr_t)n;
platform_io.Monitors.push_back(monitor);
}
}
Expand Down
1 change: 1 addition & 0 deletions backends/imgui_impl_sdl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,7 @@ static void ImGui_ImplSDL3_UpdateMonitors()
// DpiScale to cocoa_window.backingScaleFactor here.
const SDL_DisplayMode* display_mode = SDL_GetCurrentDisplayMode(display_id);
monitor.DpiScale = display_mode->display_scale;
monitor.PlatformHandle = (void*)(intptr_t)n;
platform_io.Monitors.push_back(monitor);
}
}
Expand Down
1 change: 1 addition & 0 deletions backends/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -404,6 +404,7 @@ static BOOL CALLBACK ImGui_ImplWin32_UpdateMonitors_EnumFunc(HMONITOR monitor, H
imgui_monitor.WorkPos = ImVec2((float)info.rcWork.left, (float)info.rcWork.top);
imgui_monitor.WorkSize = ImVec2((float)(info.rcWork.right - info.rcWork.left), (float)(info.rcWork.bottom - info.rcWork.top));
imgui_monitor.DpiScale = ImGui_ImplWin32_GetDpiScaleForMonitor(monitor);
imgui_monitor.PlatformHandle = (void*)monitor;
ImGuiPlatformIO& io = ImGui::GetPlatformIO();
if (info.dwFlags & MONITORINFOF_PRIMARY)
io.Monitors.push_front(imgui_monitor);
Expand Down
5 changes: 5 additions & 0 deletions docs/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,11 @@ Other changes:
- Examples: Added native Win32+OpenGL3 example. We don't recommend using this setup but we
provide it for completeness. (#3218, #5170, #6086, #2772, #2600, #2359, #2022, #1553) [@learn-more]

Docking+Viewports Branch:

- Viewports: added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant),
for usage by user code.


-----------------------------------------------------------------------
VERSION 1.89.5 (Released 2023-04-13)
Expand Down
3 changes: 2 additions & 1 deletion imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -3250,7 +3250,8 @@ struct ImGuiPlatformMonitor
ImVec2 MainPos, MainSize; // Coordinates of the area displayed on this monitor (Min = upper left, Max = bottom right)
ImVec2 WorkPos, WorkSize; // Coordinates without task bars / side bars / menu bars. Used to avoid positioning popups/tooltips inside this region. If you don't have this info, please copy the value for MainPos/MainSize.
float DpiScale; // 1.0f = 96 DPI
ImGuiPlatformMonitor() { MainPos = MainSize = WorkPos = WorkSize = ImVec2(0, 0); DpiScale = 1.0f; }
void* PlatformHandle; // Backend dependant data (e.g. HMONITOR, GLFWmonitor*, SDL Display Index, NSScreen*)
ImGuiPlatformMonitor() { MainPos = MainSize = WorkPos = WorkSize = ImVec2(0, 0); DpiScale = 1.0f; PlatformHandle = NULL; }
};

// (Optional) Support for IME (Input Method Editor) via the io.SetPlatformImeDataFn() function.
Expand Down

0 comments on commit 86af182

Please sign in to comment.