mirror of
https://github.com/ocornut/imgui.git
synced 2026-05-30 05:45:29 +08:00
Viewports: Fixed moving accross monitors when io.ConfigWindowsMoveFromTitleBarOnly is set. (#7299, #3071)
This commit is contained in:
@@ -81,6 +81,7 @@ Docking+Viewports Branch:
|
|||||||
- Added ImGuiDockNodeFlags_DockedWindowsInFocusRoute to automatically make a dockspace connect
|
- 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
|
the focus route of its docked window. This is provided a convenience in case you have windows
|
||||||
where a connection is not explicit. (#6798)
|
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
|
- Backends: OSX: Fixed not submitting Monitors info when viewports are not enabled, leading to
|
||||||
missing e.g. DpiScale info. (#7257) [@actboy168]
|
missing e.g. DpiScale info. (#7257) [@actboy168]
|
||||||
|
|
||||||
|
|||||||
@@ -7172,10 +7172,19 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags)
|
|||||||
}
|
}
|
||||||
else if (window->ViewportOwned && g.PlatformIO.Monitors.Size > 0)
|
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.
|
if (g.MovingWindow != NULL && window->RootWindowDockTree == g.MovingWindow->RootWindowDockTree)
|
||||||
const ImGuiPlatformMonitor* monitor = GetViewportPlatformMonitor(window->Viewport);
|
{
|
||||||
visibility_rect.Min = monitor->WorkPos + visibility_padding;
|
// While moving windows we allow them to straddle monitors (#7299, #3071)
|
||||||
visibility_rect.Max = monitor->WorkPos + monitor->WorkSize - visibility_padding;
|
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);
|
ClampWindowPos(window, visibility_rect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14818,6 +14827,7 @@ static void ImGui::UpdateViewportsNewFrame()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Update fallback monitor
|
// Update fallback monitor
|
||||||
|
g.PlatformMonitorsFullWorkRect = ImRect(+FLT_MAX, +FLT_MAX, -FLT_MAX, -FLT_MAX);
|
||||||
if (g.PlatformIO.Monitors.Size == 0)
|
if (g.PlatformIO.Monitors.Size == 0)
|
||||||
{
|
{
|
||||||
ImGuiPlatformMonitor* monitor = &g.FallbackMonitor;
|
ImGuiPlatformMonitor* monitor = &g.FallbackMonitor;
|
||||||
@@ -14826,6 +14836,13 @@ static void ImGui::UpdateViewportsNewFrame()
|
|||||||
monitor->WorkPos = main_viewport->WorkPos;
|
monitor->WorkPos = main_viewport->WorkPos;
|
||||||
monitor->WorkSize = main_viewport->WorkSize;
|
monitor->WorkSize = main_viewport->WorkSize;
|
||||||
monitor->DpiScale = main_viewport->DpiScale;
|
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)
|
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.
|
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;
|
ImGuiID PlatformLastFocusedViewportId;
|
||||||
ImGuiPlatformMonitor FallbackMonitor; // Virtual monitor used as fallback if backend doesn't provide monitor information.
|
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 ViewportCreatedCount; // Unique sequential creation counter (mostly for testing/debugging)
|
||||||
int PlatformWindowsCreatedCount; // 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
|
int ViewportFocusedStampCount; // Every time the front-most window changes, we stamp its viewport with an incrementing counter
|
||||||
|
|||||||
Reference in New Issue
Block a user