fix(claude-do): merge Open diff viewer and merge window as independent top-level w
ClaudeDo-Task: 29564718-d27e-40ad-a61e-9e2b79ede53d
This commit is contained in:
@@ -161,7 +161,8 @@ public partial class DetailsIslandView : UserControl
|
|||||||
var window = new DiffViewerView { DataContext = diffVm };
|
var window = new DiffViewerView { DataContext = diffVm };
|
||||||
window.Closed += (_, _) => _diffViewerWindow = null;
|
window.Closed += (_, _) => _diffViewerWindow = null;
|
||||||
_diffViewerWindow = window;
|
_diffViewerWindow = window;
|
||||||
window.Show(owner);
|
window.CenterOn(owner);
|
||||||
|
window.Show(); // no owner: an owned window would be pinned above the main window
|
||||||
return System.Threading.Tasks.Task.CompletedTask;
|
return System.Threading.Tasks.Task.CompletedTask;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
WindowDecorations="BorderOnly"
|
WindowDecorations="BorderOnly"
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
ExtendClientAreaTitleBarHeightHint="-1"
|
ExtendClientAreaTitleBarHeightHint="-1"
|
||||||
WindowStartupLocation="CenterOwner"
|
|
||||||
Background="{DynamicResource SurfaceBrush}">
|
Background="{DynamicResource SurfaceBrush}">
|
||||||
|
|
||||||
<Window.KeyBindings>
|
<Window.KeyBindings>
|
||||||
|
|||||||
@@ -11,7 +11,6 @@
|
|||||||
WindowDecorations="BorderOnly"
|
WindowDecorations="BorderOnly"
|
||||||
ExtendClientAreaToDecorationsHint="True"
|
ExtendClientAreaToDecorationsHint="True"
|
||||||
ExtendClientAreaTitleBarHeightHint="-1"
|
ExtendClientAreaTitleBarHeightHint="-1"
|
||||||
WindowStartupLocation="CenterOwner"
|
|
||||||
Background="{DynamicResource SurfaceBrush}">
|
Background="{DynamicResource SurfaceBrush}">
|
||||||
|
|
||||||
<Window.KeyBindings>
|
<Window.KeyBindings>
|
||||||
|
|||||||
@@ -41,7 +41,9 @@ public partial class MergeModalView : Window
|
|||||||
OpenWindows.Remove(vm.TaskId);
|
OpenWindows.Remove(vm.TaskId);
|
||||||
window._closed.TrySetResult();
|
window._closed.TrySetResult();
|
||||||
};
|
};
|
||||||
window.Show(owner);
|
// Independent top-level (no owner): an owned window is pinned above its owner by the OS.
|
||||||
|
window.CenterOn(owner);
|
||||||
|
window.Show();
|
||||||
return window._closed.Task;
|
return window._closed.Task;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -143,7 +143,8 @@ public sealed class WindowDialogService : IDialogService
|
|||||||
diffVm.CloseAction = () => diffDlg.Close();
|
diffVm.CloseAction = () => diffDlg.Close();
|
||||||
diffDlg.Closed += (_, _) => _diffViewerWindow = null;
|
diffDlg.Closed += (_, _) => _diffViewerWindow = null;
|
||||||
_diffViewerWindow = diffDlg;
|
_diffViewerWindow = diffDlg;
|
||||||
diffDlg.Show(_owner);
|
diffDlg.CenterOn(_owner);
|
||||||
|
diffDlg.Show(); // no owner: an owned window would be pinned above the main window
|
||||||
};
|
};
|
||||||
vm.ConfirmAction = message => ConfirmAsync(message);
|
vm.ConfirmAction = message => ConfirmAsync(message);
|
||||||
if (Shell is { } shell)
|
if (Shell is { } shell)
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
using Avalonia;
|
||||||
|
using Avalonia.Controls;
|
||||||
|
|
||||||
|
namespace ClaudeDo.Ui.Views;
|
||||||
|
|
||||||
|
internal static class WindowPlacement
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Centres a not-yet-shown window on <paramref name="owner"/>, clamped to the owner's screen.
|
||||||
|
/// Replaces <c>CenterOwner</c> for windows shown without an owner (which the OS would pin above it).
|
||||||
|
/// </summary>
|
||||||
|
public static void CenterOn(this Window window, Window owner)
|
||||||
|
{
|
||||||
|
var scale = owner.DesktopScaling;
|
||||||
|
var ownerSize = owner.FrameSize ?? owner.ClientSize;
|
||||||
|
var x = owner.Position.X + (int)((ownerSize.Width - window.Width) * scale / 2);
|
||||||
|
var y = owner.Position.Y + (int)((ownerSize.Height - window.Height) * scale / 2);
|
||||||
|
|
||||||
|
if (owner.Screens.ScreenFromWindow(owner)?.WorkingArea is { } area)
|
||||||
|
{
|
||||||
|
x = Math.Max(area.X, Math.Min(x, area.Right - (int)(window.Width * scale)));
|
||||||
|
y = Math.Max(area.Y, Math.Min(y, area.Bottom - (int)(window.Height * scale)));
|
||||||
|
}
|
||||||
|
|
||||||
|
window.WindowStartupLocation = WindowStartupLocation.Manual;
|
||||||
|
window.Position = new PixelPoint(x, y);
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user