Viewports: added void* ImGuiPlatformMonitor::PlatformHandle field (backend-dependant).

This commit is contained in:
ocornut 2023-04-21 15:10:44 +02:00
parent 07e07030a6
commit adf693c061
7 changed files with 12 additions and 1 deletions

View File

@ -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);
}
}

View File

@ -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 = (__bridge_retained void*)screen;
platform_io.Monitors.push_back(imgui_monitor);
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);

View File

@ -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)

View File

@ -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.