mirror of
https://github.com/ocornut/imgui.git
synced 2025-01-19 01:34:08 +01:00
Viewports: Fixed moving accross monitors when io.ConfigWindowsMoveFromTitleBarOnly is set. (#7299, #3071)
This commit is contained in:
parent
59c8db69eb
commit
30ba3c347c
@ -81,6 +81,7 @@ Docking+Viewports Branch:
|
||||
- Added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to automatically make a dockspace connect
|
||||
the focus route of its docked window. This is provided a convenience in case you have windows
|
||||
where a connection is not explicit. (#6798)
|
||||
- Viewports: Fixed moving accross monitors when io.ConfigWindowsMoveFromTitleBarOnly is set. (#7299, #3071)
|
||||
- Backends: OSX: Fixed not submitting Monitors info when viewports are not enabled, leading to
|
||||
missing e.g. DpiScale info. (#7257) [@actboy168]
|
||||
|
||||
|
25
imgui.cpp
25
imgui.cpp
@ -7172,10 +7172,19 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
||||
}
|
||||
else if (window->ViewportOwned && g.PlatformIO.Monitors.Size > 0)
|
||||
{
|
||||
// Lost windows (e.g. a monitor disconnected) will naturally moved to the fallback/dummy monitor aka the main viewport.
|
||||
const ImGuiPlatformMonitor* monitor = GetViewportPlatformMonitor(window->Viewport);
|
||||
visibility_rect.Min = monitor->WorkPos + visibility_padding;
|
||||
visibility_rect.Max = monitor->WorkPos + monitor->WorkSize - visibility_padding;
|
||||
if (g.MovingWindow != NULL && window->RootWindowDockTree == g.MovingWindow->RootWindowDockTree)
|
||||
{
|
||||
// While moving windows we allow them to straddle monitors (#7299, #3071)
|
||||
visibility_rect = g.PlatformMonitorsFullWorkRect;
|
||||
}
|
||||
else
|
||||
{
|
||||
// When not moving ensure visible in its monitor
|
||||
// Lost windows (e.g. a monitor disconnected) will naturally moved to the fallback/dummy monitor aka the main viewport.
|
||||
const ImGuiPlatformMonitor* monitor = GetViewportPlatformMonitor(window->Viewport);
|
||||
visibility_rect = ImRect(monitor->WorkPos, monitor->WorkPos + monitor->WorkSize);
|
||||
}
|
||||
visibility_rect.Expand(-visibility_padding);
|
||||
ClampWindowPos(window, visibility_rect);
|
||||
}
|
||||
}
|
||||
@ -14818,6 +14827,7 @@ static void ImGui::UpdateViewportsNewFrame()
|
||||
}
|
||||
|
||||
// Update fallback monitor
|
||||
g.PlatformMonitorsFullWorkRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||
if (g.PlatformIO.Monitors.Size == 0)
|
||||
{
|
||||
ImGuiPlatformMonitor* monitor = &g.FallbackMonitor;
|
||||
@ -14826,6 +14836,13 @@ static void ImGui::UpdateViewportsNewFrame()
|
||||
monitor->WorkPos = main_viewport->WorkPos;
|
||||
monitor->WorkSize = main_viewport->WorkSize;
|
||||
monitor->DpiScale = main_viewport->DpiScale;
|
||||
g.PlatformMonitorsFullWorkRect.Add(monitor->WorkPos);
|
||||
g.PlatformMonitorsFullWorkRect.Add(monitor->WorkPos + monitor->WorkSize);
|
||||
}
|
||||
for (ImGuiPlatformMonitor& monitor : g.PlatformIO.Monitors)
|
||||
{
|
||||
g.PlatformMonitorsFullWorkRect.Add(monitor.WorkPos);
|
||||
g.PlatformMonitorsFullWorkRect.Add(monitor.WorkPos + monitor.WorkSize);
|
||||
}
|
||||
|
||||
if (!viewports_enabled)
|
||||
|
@ -2230,6 +2230,7 @@ struct ImGuiContext
|
||||
ImGuiViewportP* MouseLastHoveredViewport; // Last known viewport that was hovered by mouse (even if we are not hovering any viewport any more) + honoring the _NoInputs flag.
|
||||
ImGuiID PlatformLastFocusedViewportId;
|
||||
ImGuiPlatformMonitor FallbackMonitor; // Virtual monitor used as fallback if backend doesn't provide monitor information.
|
||||
ImRect PlatformMonitorsFullWorkRect; // Bounding box of all platform monitors
|
||||
int ViewportCreatedCount; // Unique sequential creation counter (mostly for testing/debugging)
|
||||
int PlatformWindowsCreatedCount; // Unique sequential creation counter (mostly for testing/debugging)
|
||||
int ViewportFocusedStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter
|
||||
|
Loading…
x
Reference in New Issue
Block a user