Skip to content

Commit 7107386

Browse files
committed
- Fix First Launch Position to Center
- Move HideStartup code to MainWindow from app.xaml.cs
1 parent e8e1393 commit 7107386

File tree

2 files changed

+25
-12
lines changed

2 files changed

+25
-12
lines changed

Flow.Launcher/App.xaml.cs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -100,16 +100,6 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
100100
AutoUpdates();
101101

102102
API.SaveAppAllSettings();
103-
104-
if (_settings.HideOnStartup)
105-
{
106-
_mainVM.Hide();
107-
}
108-
else
109-
{
110-
window.WindowAnimator();
111-
}
112-
113103
Log.Info("|App.OnStartup|End Flow Launcher startup ---------------------------------------------------- ");
114104
});
115105
}

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ private void OnInitialized(object sender, EventArgs e)
6464

6565
private void OnLoaded(object sender, RoutedEventArgs _)
6666
{
67+
HideStartup();
6768
// show notify icon when flowlauncher is hidden
6869
InitializeNotifyIcon();
6970
WindowsInteropHelper.DisableControlBox(this);
@@ -335,6 +336,8 @@ private void UpdatePosition()
335336
{
336337
Left = WindowLeft();
337338
Top = WindowTop();
339+
_settings.WindowLeft = Left;
340+
_settings.WindowTop = Top;
338341
}
339342
}
340343

@@ -350,7 +353,27 @@ private void OnLocationChanged(object sender, EventArgs e)
350353
}
351354
}
352355

353-
private double WindowLeft()
356+
public void HideStartup()
357+
{
358+
if (_settings.HideOnStartup)
359+
{
360+
_viewModel.Hide();
361+
}
362+
else
363+
{
364+
if (!_settings.HideOnStartup && _settings.WindowLeft == 0 && _settings.WindowTop == 0) /* First Launch */
365+
{
366+
Left = WindowLeft();
367+
Top = WindowTop();
368+
_settings.WindowLeft = Left;
369+
_settings.WindowTop = Top;
370+
}
371+
_viewModel.Show();
372+
}
373+
374+
}
375+
376+
public double WindowLeft()
354377
{
355378
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
356379
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, screen.WorkingArea.X, 0);
@@ -359,7 +382,7 @@ private double WindowLeft()
359382
return left;
360383
}
361384

362-
private double WindowTop()
385+
public double WindowTop()
363386
{
364387
var screen = Screen.FromPoint(System.Windows.Forms.Cursor.Position);
365388
var dip1 = WindowsInteropHelper.TransformPixelsToDIP(this, 0, screen.WorkingArea.Y);

0 commit comments

Comments
 (0)