Skip to content

Commit b5272dd

Browse files
committed
allow main query window's width to be dynamic
1 parent aa34a02 commit b5272dd

File tree

6 files changed

+24
-5
lines changed

6 files changed

+24
-5
lines changed

Flow.Launcher.Core/Resource/Theme.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ public class Theme
3030

3131
public bool BlurEnabled { get; set; }
3232

33+
private double mainWindowWidth;
34+
3335
public Theme()
3436
{
3537
_themeDirectories.Add(DirectoryPath);
@@ -187,6 +189,21 @@ public ResourceDictionary GetResourceDictionary()
187189
Array.ForEach(new[] { resultItemStyle, resultSubItemStyle, resultItemSelectedStyle, resultSubItemSelectedStyle }, o => Array.ForEach(setters, p => o.Setters.Add(p)));
188190
}
189191

192+
var windowStyle = dict["WindowStyle"] as Style;
193+
194+
var width = windowStyle?.Setters.OfType<Setter>().Where(x => x.Property.Name == "Width")
195+
.Select(x => x.Value).FirstOrDefault();
196+
197+
if (width == null)
198+
{
199+
windowStyle = dict["BaseWindowStyle"] as Style;
200+
201+
width = windowStyle?.Setters.OfType<Setter>().Where(x => x.Property.Name == "Width")
202+
.Select(x => x.Value).FirstOrDefault();
203+
}
204+
205+
mainWindowWidth = (double)width;
206+
190207
return dict;
191208
}
192209

@@ -354,8 +371,11 @@ private bool IsBlurTheme()
354371
private void SetWindowAccent(Window w, AccentState state)
355372
{
356373
var windowHelper = new WindowInteropHelper(w);
357-
w.Width = 750;
374+
375+
// this determines the width of the main query window
376+
w.Width = mainWindowWidth;
358377
windowHelper.EnsureHandle();
378+
359379
var accent = new AccentPolicy { AccentState = state };
360380
var accentStructSize = Marshal.SizeOf(accent);
361381

Flow.Launcher/MainWindow.xaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
<KeyBinding Key="D8" Modifiers="{Binding OpenResultCommandModifiers}" Command="{Binding OpenResultCommand}" CommandParameter="7"></KeyBinding>
6161
<KeyBinding Key="D9" Modifiers="{Binding OpenResultCommandModifiers}" Command="{Binding OpenResultCommand}" CommandParameter="8"></KeyBinding>
6262
</Window.InputBindings>
63-
<Grid Width="750">
63+
<Grid>
6464
<Border Style="{DynamicResource WindowBorderStyle}" MouseDown="OnMouseDown" CornerRadius="5" >
6565
<StackPanel Orientation="Vertical">
6666
<Grid>

Flow.Launcher/Themes/Base.xaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@
4646
<Setter Property="Padding" Value="8 10 8 8" />
4747
</Style>
4848
<Style x:Key="BaseWindowStyle" TargetType="{x:Type Window}">
49+
<Setter Property="Width" Value="750" />
50+
<Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
4951
</Style>
5052

5153
<Style x:Key="BasePendingLineStyle" TargetType="{x:Type Line}">

Flow.Launcher/Themes/BlurBlack Darker.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
</Style>
2626

2727
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
28-
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
2928
<Setter Property="Background">
3029
<Setter.Value>
3130
<SolidColorBrush Color="Black" Opacity="0.6"/>

Flow.Launcher/Themes/BlurBlack.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
</Style>
2626

2727
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
28-
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
2928
<Setter Property="Background">
3029
<Setter.Value>
3130
<SolidColorBrush Color="Black" Opacity="0.3"/>

Flow.Launcher/Themes/BlurWhite.xaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
</Style>
2424

2525
<Style x:Key="WindowStyle" BasedOn="{StaticResource BaseWindowStyle}" TargetType="{x:Type Window}">
26-
<Setter Property="Width" Value="750" /> <!-- This is used to set the blur width only -->
2726
<Setter Property="Background">
2827
<Setter.Value>
2928
<SolidColorBrush Color="White" Opacity="0.5"/>

0 commit comments

Comments
 (0)