Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
f6d25aa
Code cleanup: Flow.Launcher.Plugin.BrowserBookmark
Yusyuriv Apr 16, 2024
6373778
Fix Firefox bookmark SQL query formatting
Yusyuriv Apr 16, 2024
7393b27
Fix a typo in variable name in FirefoxBookmarkLoader.cs
Yusyuriv Apr 16, 2024
148afc4
Add a hyphen in a word inside a comment in BrowserBookmark/Main.cs
Yusyuriv Apr 17, 2024
73de9a7
Testing
onesounds Apr 29, 2024
80c8647
test2
onesounds Apr 29, 2024
420446d
Update expect.txt
VictoriousRaptor Apr 30, 2024
507a126
Try to add terms in allow.txt
VictoriousRaptor May 1, 2024
3554136
Merge pull request #2652 from Flow-Launcher/code-cleanup/Flow.Launche…
VictoriousRaptor May 1, 2024
abe187a
Use keyboard keys markup
VictoriousRaptor May 2, 2024
5678790
Remove outdated info
VictoriousRaptor May 2, 2024
c500e39
Refactor installation guide
VictoriousRaptor May 2, 2024
c1ffd1c
Add language list
VictoriousRaptor May 2, 2024
79eaef5
Update wording & add description
VictoriousRaptor May 2, 2024
48384a8
collapsed language list
VictoriousRaptor May 2, 2024
28c2612
Fix double key
VictoriousRaptor May 2, 2024
8ea7812
Update Hotkeys guide
VictoriousRaptor May 3, 2024
95eeb61
Add default hotkey for prev/next page command
VictoriousRaptor May 3, 2024
fc6de49
Use desc in scoop
VictoriousRaptor May 3, 2024
31561be
Merge new features into features
VictoriousRaptor May 3, 2024
4667bda
Use "Previous" instead of "Prev"
VictoriousRaptor May 3, 2024
f93da00
Fix gamemode hotkey and add requery hotkey
VictoriousRaptor May 3, 2024
ab8b298
Merge pull request #2685 from Flow-Launcher/improve-readme
onesounds May 3, 2024
dd6da77
Merge pull request #2686 from Flow-Launcher/fix-hotkey-guide
onesounds May 3, 2024
44fb850
Fix README.md typo
jjw24 May 3, 2024
106760c
Merge pull request #2687 from Flow-Launcher/readme_typo
jjw24 May 3, 2024
be1c3f7
Block Mouse Hover
onesounds May 16, 2024
b9b3422
Merge pull request #2697 from onesounds/240516BlockHoverWhenKeyboardU…
jjw24 May 17, 2024
c94e47b
- Adjust Themes
onesounds May 18, 2024
2b14bc4
Fix font Size
onesounds May 18, 2024
446f50a
Merge
onesounds May 18, 2024
f55d71f
Merge
onesounds May 18, 2024
0d32d0f
Move the Blur code to Theme
onesounds May 20, 2024
edf3626
Add BlurTheme Logic
onesounds May 20, 2024
1670de1
Add Tint Color Logic
onesounds May 20, 2024
1988458
Adjust Theme
onesounds May 21, 2024
1d6ef7d
- Fix Preview
onesounds May 22, 2024
3c1d97f
Fix Dark Mode check by elven
onesounds May 22, 2024
011a43f
Adjust Auto Colors
onesounds May 22, 2024
0313f4d
Adjust GlassFrame
onesounds May 22, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@ https
ssh
ubuntu
runcount
Firefox
Português
Português (Brasil)
1 change: 1 addition & 0 deletions .github/actions/spelling/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ WCA_ACCENT_POLICY
HGlobal
dopusrt
firefox
Firefox
msedge
svgc
ime
Expand Down
164 changes: 111 additions & 53 deletions Flow.Launcher.Core/Resource/Theme.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
using Flow.Launcher.Infrastructure.Logger;
using Flow.Launcher.Infrastructure.UserSettings;

using static Flow.Launcher.Core.Resource.Theme.ParameterTypes;

namespace Flow.Launcher.Core.Resource
{
public class Theme
Expand All @@ -27,13 +29,14 @@ public class Theme
private const string Extension = ".xaml";
private string DirectoryPath => Path.Combine(Constant.ProgramDirectory, Folder);
private string UserDirectoryPath => Path.Combine(DataLocation.DataDirectory(), Folder);

public bool BlurEnabled { get; set; }

private double mainWindowWidth;
private Func<bool> _isDarkTheme;

public Theme()
public Theme(Func<bool> isDarkTheme)
{
_isDarkTheme = isDarkTheme;
_themeDirectories.Add(DirectoryPath);
_themeDirectories.Add(UserDirectoryPath);
MakeSureThemeDirectoriesExist();
Expand Down Expand Up @@ -94,11 +97,12 @@ public bool ChangeTheme(string theme)
}

BlurEnabled = IsBlurTheme();
SetBlurForWindow();

if (Settings.UseDropShadowEffect && !BlurEnabled)
if (Settings.UseDropShadowEffect && BlurEnabled == false)
AddDropShadowEffectToCurrentTheme();

SetBlurForWindow();

}
catch (DirectoryNotFoundException)
{
Expand Down Expand Up @@ -272,7 +276,6 @@ public void AddDropShadowEffectToCurrentTheme()
}

windowBorderStyle.Setters.Add(effectSetter);

UpdateResourceDictionary(dict);
}

Expand Down Expand Up @@ -302,59 +305,123 @@ public void RemoveDropShadowEffectFromCurrentTheme()
UpdateResourceDictionary(dict);
}


#region Blur Handling
/*
Found on https://github.com/riverar/sample-win10-aeroglass
*/
private enum AccentState
public class ParameterTypes
{
ACCENT_DISABLED = 0,
ACCENT_ENABLE_GRADIENT = 1,
ACCENT_ENABLE_TRANSPARENTGRADIENT = 2,
ACCENT_ENABLE_BLURBEHIND = 3,
ACCENT_INVALID_STATE = 4
}

[StructLayout(LayoutKind.Sequential)]
private struct AccentPolicy
{
public AccentState AccentState;
public int AccentFlags;
public int GradientColor;
public int AnimationId;
[Flags]
public enum DWMWINDOWATTRIBUTE
{
DWMWA_USE_IMMERSIVE_DARK_MODE = 20,
DWMWA_SYSTEMBACKDROP_TYPE = 38,
DWMWA_TRANSITIONS_FORCEDISABLED = 3,
DWMWA_BORDER_COLOR
}

[StructLayout(LayoutKind.Sequential)]
public struct MARGINS
{
public int cxLeftWidth; // width of left border that retains its size
public int cxRightWidth; // width of right border that retains its size
public int cyTopHeight; // height of top border that retains its size
public int cyBottomHeight; // height of bottom border that retains its size
};
}

[StructLayout(LayoutKind.Sequential)]
private struct WindowCompositionAttributeData
public static class Methods
{
public WindowCompositionAttribute Attribute;
public IntPtr Data;
public int SizeOfData;
[DllImport("DwmApi.dll")]
static extern int DwmExtendFrameIntoClientArea(
IntPtr hwnd,
ref ParameterTypes.MARGINS pMarInset);

[DllImport("dwmapi.dll")]
static extern int DwmSetWindowAttribute(IntPtr hwnd, ParameterTypes.DWMWINDOWATTRIBUTE dwAttribute, ref int pvAttribute, int cbAttribute);

public static int ExtendFrame(IntPtr hwnd, ParameterTypes.MARGINS margins)
=> DwmExtendFrameIntoClientArea(hwnd, ref margins);

public static int SetWindowAttribute(IntPtr hwnd, ParameterTypes.DWMWINDOWATTRIBUTE attribute, int parameter)
=> DwmSetWindowAttribute(hwnd, attribute, ref parameter, Marshal.SizeOf<int>());
}

private enum WindowCompositionAttribute
Window mainWindow = Application.Current.MainWindow;

public void RefreshFrame()
{
WCA_ACCENT_POLICY = 19
IntPtr mainWindowPtr = new WindowInteropHelper(mainWindow).Handle;
HwndSource mainWindowSrc = HwndSource.FromHwnd(mainWindowPtr);
//mainWindowSrc.CompositionTarget.BackgroundColor = Color.FromArgb(0, 255, 181, 178);

ParameterTypes.MARGINS margins = new ParameterTypes.MARGINS();
margins.cxLeftWidth = -1;
margins.cxRightWidth = -1;
margins.cyTopHeight = -1;
margins.cyBottomHeight = -1;
Methods.ExtendFrame(mainWindowSrc.Handle, margins);

// Remove OS minimizing/maximizing animation
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_TRANSITIONS_FORCEDISABLED, 3);
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_BORDER_COLOR, 0x00FF0000);

SetBlurForWindow();
}
[DllImport("user32.dll")]
private static extern int SetWindowCompositionAttribute(IntPtr hwnd, ref WindowCompositionAttributeData data);



/// <summary>
/// Sets the blur for a window via SetWindowCompositionAttribute
/// </summary>
public void SetBlurForWindow()
{
//SetWindowAccent();
var dict = GetThemeResourceDictionary(Settings.Theme);
var windowBorderStyle = dict["WindowBorderStyle"] as Style;
if (BlurEnabled)
{
SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_ENABLE_BLURBEHIND);
windowBorderStyle.Setters.Remove(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
windowBorderStyle.Setters.Add(new Setter(Border.BackgroundProperty, new SolidColorBrush(Colors.Transparent)));
mainWindow.WindowStyle = WindowStyle.SingleBorderWindow;
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 3);
BlurColor(BlurMode());
}
else
{
SetWindowAccent(Application.Current.MainWindow, AccentState.ACCENT_DISABLED);
mainWindow.WindowStyle = WindowStyle.None;
if (windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background") != null)
{
windowBorderStyle.Setters.Add(windowBorderStyle.Setters.OfType<Setter>().FirstOrDefault(x => x.Property.Name == "Background"));
}
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_SYSTEMBACKDROP_TYPE, 1);
}
UpdateResourceDictionary(dict);
}

private bool IsBlurTheme()
public void BlurColor(string Color)
{
if (Color == "Light")
{
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0);
}
else if (Color == "Dark")
{
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1);
}
else /* Case of "Auto" Blur Type Theme */
{
if (_isDarkTheme())
{
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 1);
}
else
{
Methods.SetWindowAttribute(new WindowInteropHelper(mainWindow).Handle, DWMWINDOWATTRIBUTE.DWMWA_USE_IMMERSIVE_DARK_MODE, 0);
}
}

}
public bool IsBlurTheme()
{
if (Environment.OSVersion.Version >= new Version(6, 2))
{
Expand All @@ -368,30 +435,21 @@ private bool IsBlurTheme()

return false;
}

private void SetWindowAccent(Window w, AccentState state)
public string BlurMode()
{
var windowHelper = new WindowInteropHelper(w);

windowHelper.EnsureHandle();

var accent = new AccentPolicy { AccentState = state };
var accentStructSize = Marshal.SizeOf(accent);

var accentPtr = Marshal.AllocHGlobal(accentStructSize);
Marshal.StructureToPtr(accent, accentPtr, false);

var data = new WindowCompositionAttributeData
if (Environment.OSVersion.Version >= new Version(6, 2))
{
Attribute = WindowCompositionAttribute.WCA_ACCENT_POLICY,
SizeOfData = accentStructSize,
Data = accentPtr
};
var resource = Application.Current.TryFindResource("BlurMode");

SetWindowCompositionAttribute(windowHelper.Handle, ref data);
if (resource is string)
return (string)resource;

Marshal.FreeHGlobal(accentPtr);
return null;
}

return null;
}

#endregion
}
}
8 changes: 5 additions & 3 deletions Flow.Launcher.Core/Resource/ThemeManager.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
namespace Flow.Launcher.Core.Resource
using System;

namespace Flow.Launcher.Core.Resource
{
public class ThemeManager
{
private static Theme instance;
private static object syncObject = new object();

public static Func<bool> IsDarkMode { get; set; }
public static Theme Instance
{
get
Expand All @@ -15,7 +17,7 @@ public static Theme Instance
{
if (instance == null)
{
instance = new Theme();
instance = new Theme(IsDarkMode);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public class Settings : BaseModel, IHotkeySettings
public string SelectNextItemHotkey2 { get; set; } = $"";
public string SelectPrevItemHotkey { get; set; } = $"Shift + Tab";
public string SelectPrevItemHotkey2 { get; set; } = $"";
public string SelectNextPageHotkey { get; set; } = $"";
public string SelectPrevPageHotkey { get; set; } = $"";
public string SelectNextPageHotkey { get; set; } = $"PageUp";
public string SelectPrevPageHotkey { get; set; } = $"PageDown";
public string OpenContextMenuHotkey { get; set; } = $"Ctrl+O";
public string SettingWindowHotkey { get; set; } = $"Ctrl+I";

Expand Down
1 change: 1 addition & 0 deletions Flow.Launcher/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ await Stopwatch.NormalAsync("|App.OnStartup|Startup cost", async () =>
InternationalizationManager.Instance.Settings = _settings;
InternationalizationManager.Instance.ChangeLanguage(_settings.Language);
// main windows needs initialized before theme change because of blur settings
ThemeManager.IsDarkMode = () => ModernWpf.ThemeManager.Current.ActualApplicationTheme is ModernWpf.ApplicationTheme.Dark;
ThemeManager.Instance.Settings = _settings;
ThemeManager.Instance.ChangeTheme(_settings.Theme);

Expand Down
5 changes: 3 additions & 2 deletions Flow.Launcher/Languages/en.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,17 @@
<system:String x:Key="autoCompleteHotkey">Auto Complete</system:String>
<system:String x:Key="autoCompleteHotkeyToolTip">Runs autocomplete for the selected items.</system:String>
<system:String x:Key="SelectNextItemHotkey">Select Next Item</system:String>
<system:String x:Key="SelectPrevItemHotkey">Select Prev Item</system:String>
<system:String x:Key="SelectPrevItemHotkey">Select Previous Item</system:String>
<system:String x:Key="SelectNextPageHotkey">Next Page</system:String>
<system:String x:Key="SelectPrevPageHotkey">Prev Page</system:String>
<system:String x:Key="SelectPrevPageHotkey">Previous Page</system:String>
<system:String x:Key="OpenContextMenuHotkey">Open Context Menu</system:String>
<system:String x:Key="SettingWindowHotkey">Open Setting Window</system:String>
<system:String x:Key="CopyFilePathHotkey">Copy File Path</system:String>
<system:String x:Key="ToggleGameModeHotkey">Toggle Game Mode</system:String>
<system:String x:Key="ToggleHistoryHotkey">Toggle History</system:String>
<system:String x:Key="OpenContainFolderHotkey">Open Containing Folder</system:String>
<system:String x:Key="RunAsAdminHotkey">Run As Admin</system:String>
<system:String x:Key="RequeryHotkey">Refresh Search Results</system:String>
<system:String x:Key="ReloadPluginHotkey">Reload Plugins Data</system:String>
<system:String x:Key="QuickWidthHotkey">Quick Adjust Window Width</system:String>
<system:String x:Key="QuickHeightHotkey">Quick Adjust Window Height</system:String>
Expand Down
22 changes: 17 additions & 5 deletions Flow.Launcher/MainWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
MaxWidth="{Binding MainWindowWidth, Mode=OneWay}"
d:DataContext="{d:DesignInstance Type=vm:MainViewModel}"
AllowDrop="True"
AllowsTransparency="True"
AllowsTransparency="False"
Background="Transparent"
Closing="OnClosing"
Deactivated="OnDeactivated"
Expand All @@ -25,15 +25,21 @@
LocationChanged="OnLocationChanged"
Opacity="{Binding MainWindowOpacity, Mode=OneWay, UpdateSourceTrigger=PropertyChanged}"
PreviewKeyDown="OnKeyDown"
PreviewKeyUp="OnKeyUp"
ResizeMode="NoResize"
ShowInTaskbar="False"
SizeToContent="Height"
Style="{DynamicResource WindowStyle}"
Topmost="True"
Visibility="{Binding MainWindowVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
WindowStartupLocation="Manual"
WindowStyle="None"
mc:Ignorable="d">
<WindowChrome.WindowChrome>
<WindowChrome
CaptionHeight="9"
GlassFrameThickness="-1"
ResizeBorderThickness="{x:Static SystemParameters.WindowResizeBorderThickness}" />
</WindowChrome.WindowChrome>
<Window.Resources>
<converters:QuerySuggestionBoxConverter x:Key="QuerySuggestionBoxConverter" />
<converters:BorderClipConverter x:Key="BorderClipConverter" />
Expand Down Expand Up @@ -198,7 +204,10 @@
Command="{Binding SelectPrevPageCommand}"
Modifiers="{Binding SelectPrevPageHotkey, Converter={StaticResource StringToKeyBindingConverter}, ConverterParameter='modifiers'}" />
</Window.InputBindings>
<Grid>
<Grid Style="{DynamicResource BlurTint}">
<!--<Grid.Background>
<SolidColorBrush Opacity="{DynamicResource TintValue}" Color="{DynamicResource WindowBlurTint}" />
</Grid.Background>-->
<Border MouseDown="OnMouseDown" Style="{DynamicResource WindowBorderStyle}">
<StackPanel Orientation="Vertical">
<Grid>
Expand Down Expand Up @@ -307,11 +316,11 @@
<Line
x:Name="ProgressBar"
Width="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Grid}}, Path=ActualWidth}"
Height="2"
Height="1"
Margin="12,0,12,0"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
StrokeThickness="2"
StrokeThickness="1"
Style="{DynamicResource PendingLineStyle}"
Visibility="{Binding ProgressBarVisibility, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
X1="-100"
Expand Down Expand Up @@ -347,6 +356,9 @@

</Grid>
<Grid>
<!--<Grid.Background>
<SolidColorBrush Opacity="0.5" Color="#000000" />
</Grid.Background>-->
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" MinWidth="100" />
<ColumnDefinition Width="Auto" />
Expand Down
Loading