Skip to content

Commit 10d4387

Browse files
committed
Code quality & Fix
1 parent 91c5e84 commit 10d4387

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
xmlns:vm="clr-namespace:Flow.Launcher.ViewModel"
1111
Name="FlowMainWindow"
1212
Title="Flow Launcher"
13-
Width="{Binding MainWindowWidth, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
13+
Width="{Binding MainWindowWidth, Mode=OneWay}"
1414
MinWidth="400"
1515
MinHeight="30"
1616
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"

Flow.Launcher/MainWindow.xaml.cs

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -455,23 +455,25 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
455455
{
456456
_initialWidth = (int)Width;
457457
_initialHeight = (int)Height;
458+
458459
handled = true;
459460
}
460461
else if (msg == Win32Helper.WM_EXITSIZEMOVE)
461462
{
462463
if (_initialHeight != (int)Height)
463464
{
464-
var shadowMargin = 0;
465-
var (_, useDropShadowEffect) = _theme.GetActualValue();
466-
if (useDropShadowEffect)
467-
{
468-
shadowMargin = 32;
469-
}
470-
471465
if (!_settings.KeepMaxResults)
472466
{
473-
var itemCount = (Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize;
467+
// Get shadow margin
468+
var shadowMargin = 0;
469+
var (_, useDropShadowEffect) = _theme.GetActualValue();
470+
if (useDropShadowEffect)
471+
{
472+
shadowMargin = 32;
473+
}
474474

475+
// Calculate max results to show
476+
var itemCount = (Height - (_settings.WindowHeightSize + 14) - shadowMargin) / _settings.ItemHeightSize;
475477
if (itemCount < 2)
476478
{
477479
_settings.MaxResultsToShow = 2;
@@ -483,11 +485,16 @@ private IntPtr WndProc(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref b
483485
}
484486

485487
SizeToContent = SizeToContent.Height;
486-
_viewModel.MainWindowWidth = Width;
487488
}
488489

489490
if (_initialWidth != (int)Width)
490491
{
492+
if (!_settings.KeepMaxResults)
493+
{
494+
// Update width
495+
_viewModel.MainWindowWidth = Width;
496+
}
497+
491498
SizeToContent = SizeToContent.Height;
492499
}
493500

0 commit comments

Comments
 (0)