mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Improve window drag behavior when transitioning from maximized state
This commit is contained in:
parent
c6ed0bdc2a
commit
08038dec94
1 changed files with 46 additions and 1 deletions
|
|
@ -465,7 +465,52 @@ namespace Flow.Launcher
|
||||||
|
|
||||||
private void OnMouseDown(object sender, MouseButtonEventArgs e)
|
private void OnMouseDown(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (e.ChangedButton == MouseButton.Left) DragMove();
|
if (e.ChangedButton == MouseButton.Left)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (WindowState == WindowState.Maximized)
|
||||||
|
{
|
||||||
|
// 최대화된 창의 크기 기준으로 비율 계산
|
||||||
|
double maxWidth = this.ActualWidth;
|
||||||
|
double maxHeight = this.ActualHeight;
|
||||||
|
var mousePos = e.GetPosition(this);
|
||||||
|
double xRatio = mousePos.X / maxWidth;
|
||||||
|
double yRatio = mousePos.Y / maxHeight;
|
||||||
|
|
||||||
|
// 현재 모니터 정보
|
||||||
|
var screen = Screen.FromHandle(new WindowInteropHelper(this).Handle);
|
||||||
|
var workingArea = screen.WorkingArea;
|
||||||
|
var screenLeftTop = Win32Helper.TransformPixelsToDIP(this, workingArea.X, workingArea.Y);
|
||||||
|
|
||||||
|
// Normal로 전환
|
||||||
|
WindowState = WindowState.Normal;
|
||||||
|
|
||||||
|
Dispatcher.BeginInvoke(new Action(() =>
|
||||||
|
{
|
||||||
|
double normalWidth = Width;
|
||||||
|
double normalHeight = Height;
|
||||||
|
|
||||||
|
// 최대화된 창 크기와 Normal 창 크기 차이만큼 비율 적용
|
||||||
|
Left = screenLeftTop.X + (maxWidth - normalWidth) * xRatio;
|
||||||
|
Top = screenLeftTop.Y + (maxHeight - normalHeight) * yRatio;
|
||||||
|
|
||||||
|
if (Mouse.LeftButton == MouseButtonState.Pressed)
|
||||||
|
{
|
||||||
|
DragMove();
|
||||||
|
}
|
||||||
|
}), DispatcherPriority.ApplicationIdle);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DragMove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException)
|
||||||
|
{
|
||||||
|
// 무시
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue