Skip to content

Commit 45dd84a

Browse files
committed
Adjust Code
1 parent ae0ec8e commit 45dd84a

File tree

1 file changed

+50
-42
lines changed

1 file changed

+50
-42
lines changed

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 50 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -307,53 +307,61 @@ private void InitializePosition()
307307
double currentScreenWidth = screen.WorkingArea.Width;
308308
double currentScreenHeight = screen.WorkingArea.Height;
309309

310-
if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0)
311-
{
312-
double widthRatio = currentScreenWidth / _previousScreenWidth;
313-
double heightRatio = currentScreenHeight / _previousScreenHeight;
314-
double dpiXRatio = currentDpi.X / _previousDpiX;
315-
double dpiYRatio = currentDpi.Y / _previousDpiY;
310+
if (!(
311+
_previousScreenWidth == currentScreenWidth &&
312+
_previousScreenHeight == currentScreenHeight &&
313+
_previousDpiX == currentDpi.X &&
314+
_previousDpiY == currentDpi.Y
315+
))
316+
{
317+
if (_previousScreenWidth != 0 && _previousScreenHeight != 0 && _previousDpiX != 0 && _previousDpiY != 0)
318+
{
319+
double widthRatio = currentScreenWidth / _previousScreenWidth;
320+
double heightRatio = currentScreenHeight / _previousScreenHeight;
321+
double dpiXRatio = currentDpi.X / _previousDpiX;
322+
double dpiYRatio = currentDpi.Y / _previousDpiY;
316323

317-
_settings.WindowLeft *= widthRatio * dpiXRatio;
318-
_settings.WindowTop *= heightRatio * dpiYRatio;
319-
}
324+
_settings.WindowLeft *= widthRatio * dpiXRatio;
325+
_settings.WindowTop *= heightRatio * dpiYRatio;
326+
}
320327

321-
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
322-
{
323-
Top = _settings.WindowTop;
324-
Left = _settings.WindowLeft;
325-
}
326-
else
327-
{
328-
switch (_settings.SearchWindowAlign)
328+
if (_settings.SearchWindowScreen == SearchWindowScreens.RememberLastLaunchLocation)
329329
{
330-
case SearchWindowAligns.Center:
331-
Left = HorizonCenter(screen);
332-
Top = VerticalCenter(screen);
333-
break;
334-
case SearchWindowAligns.CenterTop:
335-
Left = HorizonCenter(screen);
336-
Top = VerticalTop(screen);
337-
break;
338-
case SearchWindowAligns.LeftTop:
339-
Left = HorizonLeft(screen);
340-
Top = VerticalTop(screen);
341-
break;
342-
case SearchWindowAligns.RightTop:
343-
Left = HorizonRight(screen);
344-
Top = VerticalTop(screen);
345-
break;
346-
case SearchWindowAligns.Custom:
347-
Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X;
348-
Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y;
349-
break;
330+
Top = _settings.WindowTop;
331+
Left = _settings.WindowLeft;
332+
}
333+
else
334+
{
335+
switch (_settings.SearchWindowAlign)
336+
{
337+
case SearchWindowAligns.Center:
338+
Left = HorizonCenter(screen);
339+
Top = VerticalCenter(screen);
340+
break;
341+
case SearchWindowAligns.CenterTop:
342+
Left = HorizonCenter(screen);
343+
Top = VerticalTop(screen);
344+
break;
345+
case SearchWindowAligns.LeftTop:
346+
Left = HorizonLeft(screen);
347+
Top = VerticalTop(screen);
348+
break;
349+
case SearchWindowAligns.RightTop:
350+
Left = HorizonRight(screen);
351+
Top = VerticalTop(screen);
352+
break;
353+
case SearchWindowAligns.Custom:
354+
Left = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X + _settings.CustomWindowLeft, 0).X;
355+
Top = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y + _settings.CustomWindowTop).Y;
356+
break;
357+
}
350358
}
351-
}
352359

353-
_previousScreenWidth = currentScreenWidth;
354-
_previousScreenHeight = currentScreenHeight;
355-
_previousDpiX = currentDpi.X;
356-
_previousDpiY = currentDpi.Y;
360+
_previousScreenWidth = currentScreenWidth;
361+
_previousScreenHeight = currentScreenHeight;
362+
_previousDpiX = currentDpi.X;
363+
_previousDpiY = currentDpi.Y;
364+
}
357365
}
358366

359367
private void UpdateNotifyIconText()

0 commit comments

Comments
 (0)