Skip to content

Fluent Window #3271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 119 commits into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
119 commits
Select commit Hold shift + click to select a range
3e9a0e2
Added basic structure for fluent window
onesounds Feb 22, 2025
270f5b3
Base Structure for fluent window
onesounds Feb 23, 2025
53cb94d
Fix first load issue
onesounds Feb 24, 2025
278121b
Remove delay for hide
onesounds Feb 24, 2025
db5036a
Fix other delays when hide window
onesounds Feb 24, 2025
41b05b3
Replace dll import with PInvoke for code quality
Jack251970 Feb 24, 2025
10bbccb
Add theme compatibility code
onesounds Feb 24, 2025
77e0234
Merge branch '250223FluentTest2' of https://github.com/onesounds/Flow…
onesounds Feb 24, 2025
4426bed
Merge Dev
onesounds Feb 28, 2025
912c991
Fix theme.cs
onesounds Feb 28, 2025
bbdb589
Add BGcolor style for blur mode
onesounds Mar 1, 2025
6a736a8
Add bgcolor for blur
onesounds Mar 1, 2025
70543d2
Add WindowCornerRadius Property function
onesounds Mar 1, 2025
5b81cf5
Adjust Shadow Effect
onesounds Mar 1, 2025
f00f98c
Add Proprerty for blur themes
onesounds Mar 1, 2025
2cd5174
Adjust themes
onesounds Mar 2, 2025
ff18abc
Change Window type
onesounds Mar 4, 2025
f0b1422
Change AddShadow Logic
onesounds Mar 4, 2025
90828d9
Fix Shadow Timing
onesounds Mar 4, 2025
f712f63
Adjust Animator
onesounds Mar 5, 2025
4ab5ef0
Adjust Animation
onesounds Mar 6, 2025
2da2012
Adjust Animation
onesounds Mar 6, 2025
2a55cab
Fix Show Function
onesounds Mar 6, 2025
40ca75a
Adjust Comment, Adjust Shadow Timing.
onesounds Mar 6, 2025
7587178
Adjust Hide function for fix blink issue
onesounds Mar 6, 2025
4042231
Fix blink issue when fast trigering show/hide
onesounds Mar 6, 2025
a65dc65
Change Show/Hide function to using DWM
onesounds Mar 6, 2025
1bfec0a
Fix Animation
onesounds Mar 6, 2025
624fa0e
Fix Hide
onesounds Mar 6, 2025
1b22d9c
Fix Clock Animation
onesounds Mar 6, 2025
2710de1
Fix Search Icon Opacity
onesounds Mar 6, 2025
46cdb2a
Fix Blink issue when hidestartup mode (hide on)
onesounds Mar 8, 2025
01d081d
Revert Startup Blinking
onesounds Mar 8, 2025
b8748d6
Fix Render Blink
onesounds Mar 8, 2025
c63bb21
Added Windows 10 check code
onesounds Mar 8, 2025
1345470
- Revert blinking fix
onesounds Mar 8, 2025
7e622b7
Add BackdropType in setting
onesounds Mar 9, 2025
9510a07
Add Mica Background option
onesounds Mar 9, 2025
f5d9155
Add Mica control in blur function
onesounds Mar 9, 2025
4fd5e15
- Adjust Setting order
onesounds Mar 11, 2025
1c79d51
Fix Change Theme render timing
onesounds Mar 11, 2025
ba02a3c
Add Strings
onesounds Mar 11, 2025
f4b074c
Fix shadow effec tissue
onesounds Mar 12, 2025
ea5b3f1
Disable backdrop control when use non-blur theme
onesounds Mar 12, 2025
aabe967
Adjust Dropshadow control disable
onesounds Mar 13, 2025
ec5d52e
Fix Preview background
onesounds Mar 13, 2025
72d2b7e
Change default pending color
onesounds Mar 13, 2025
73c5f39
Merge Dev
onesounds Mar 13, 2025
dd1f439
Adjust strings and icon
onesounds Mar 13, 2025
6c1730e
Merge Dev
onesounds Mar 13, 2025
88f8274
Remove duplicated strings
onesounds Mar 13, 2025
2cd769b
Fix UI thread issue and preview
onesounds Mar 14, 2025
c7a2dee
Fix Keeping shadow when change page issue
onesounds Mar 14, 2025
caa5a48
Use enum instead of constants & Use vm property
Jack251970 Mar 14, 2025
8484c2b
Fix color scheme change issue & Code cleanup
Jack251970 Mar 14, 2025
c17dcad
Revert "Use enum instead of constants"
Jack251970 Mar 14, 2025
57d206f
Fix SystemBG color select
onesounds Mar 14, 2025
887be64
Merge branch '250223FluentTest2' of https://github.com/onesounds/Flow…
onesounds Mar 14, 2025
e527e6c
Fix Backdrop reset when change theme
onesounds Mar 14, 2025
fd344a3
Fix Preview border
onesounds Mar 14, 2025
4e15cb0
Comment cleanup
onesounds Mar 15, 2025
d90b82a
Code Cleanup
onesounds Mar 15, 2025
7c8d45d
- Fix Clock Right margin
onesounds Mar 15, 2025
aeb3f22
- rollback pin theme to legacy
onesounds Mar 15, 2025
53d647f
Adjust Themes for fluent
onesounds Mar 16, 2025
9ec6d5c
Fix clock visibilty when open context menu
onesounds Mar 16, 2025
fa5bfd3
Fix BlurWhite theme
onesounds Mar 16, 2025
ce55303
- Fix Logic for dwmBG
onesounds Mar 16, 2025
0086a9e
Add a condition to disable blur on unsupported Windows versions.
onesounds Mar 16, 2025
c792544
Adjust UI
onesounds Mar 16, 2025
a98b7b7
Merge branch 'dev' into 250223FluentTest2
Jack251970 Mar 16, 2025
29c6f12
Code cleanup
Jack251970 Mar 16, 2025
07b0e72
Code cleanup
Jack251970 Mar 16, 2025
e4ade45
Use PInvoke.DwmSetWindowAttribute instead of DllImport
Jack251970 Mar 16, 2025
db37ab7
Use PInvoke.DwmSetWindowAttribute instead of DllImport
Jack251970 Mar 16, 2025
7a85439
Improve code quality
Jack251970 Mar 16, 2025
2dcbe7f
Remove old blur handling codes
Jack251970 Mar 16, 2025
200c32b
Code cleanup
Jack251970 Mar 16, 2025
cff400b
Revert main window xaml change
Jack251970 Mar 16, 2025
7c23aeb
Improve code quality
Jack251970 Mar 16, 2025
07c5fa4
Improve code quality
Jack251970 Mar 16, 2025
2ed5de3
Improve sys plugin theme selector
Jack251970 Mar 16, 2025
cd46c79
Fix build issue
Jack251970 Mar 16, 2025
9a6175e
Remove useless position initialization & Remove useless dispatcher in…
Jack251970 Mar 16, 2025
6f093cf
Merge branch 'dev' into 250223FluentTest2
Jack251970 Mar 16, 2025
3966290
Refresh frame after position is intialized
Jack251970 Mar 16, 2025
2ea303f
Code cleanup
Jack251970 Mar 16, 2025
70e7f82
Fix Blink
onesounds Mar 16, 2025
ecc9f0d
Fix acrylic backdrop flicker issue
Jack251970 Mar 16, 2025
09d66f5
Merge branch '250223FluentTest2' of https://github.com/onesounds/Flow…
onesounds Mar 16, 2025
8b10973
Revert "Fix Blink"
Jack251970 Mar 16, 2025
1ca17aa
Code cleanup
Jack251970 Mar 16, 2025
2cd1683
Improve code quality
Jack251970 Mar 16, 2025
a98a033
Improve code quality
Jack251970 Mar 16, 2025
7d62ded
Improve code quality
Jack251970 Mar 16, 2025
49f1d79
Fix SetWindowLong issue
Jack251970 Mar 16, 2025
bf5591c
Fix position set issue
Jack251970 Mar 16, 2025
0bcc187
Keep user settings when changing theme
Jack251970 Mar 16, 2025
2b6e1bf
Improve code quality
Jack251970 Mar 17, 2025
da30e2e
Improve code quality
Jack251970 Mar 17, 2025
a2f70f4
Organize usings
Jack251970 Mar 17, 2025
1e6bbdd
Organize usings
Jack251970 Mar 17, 2025
698217f
Improve code quality
Jack251970 Mar 17, 2025
4d080a9
Fix build issue
Jack251970 Mar 17, 2025
841cc06
Fix blink clock/icon animation issue when show/hide repeatly
onesounds Mar 17, 2025
f3a5365
Merge remote-tracking branch 'origin/250223FluentTest2' into 250223Fl…
onesounds Mar 17, 2025
0741231
Adjust Flickering code
onesounds Mar 17, 2025
95f151b
Organize usings
Jack251970 Mar 17, 2025
711865d
Use local variable for storyboard
Jack251970 Mar 17, 2025
7876fa1
Fix possible cancel token issue
Jack251970 Mar 17, 2025
570d9ce
Remove useless logic
Jack251970 Mar 17, 2025
bfa7622
Improve performance
Jack251970 Mar 17, 2025
df8f2f0
Merge branch 'dev' into 250223FluentTest2
Jack251970 Mar 17, 2025
8493fa5
Merge branch 'dev' into 250223FluentTest2
Jack251970 Mar 18, 2025
a3322fc
Remove Corner Type
onesounds Mar 18, 2025
4731d88
Removed window animation storyboard
onesounds Mar 18, 2025
aaca0c0
Change Comment to english
onesounds Mar 18, 2025
9cb31c8
Improve code quality
Jack251970 Mar 19, 2025
944393c
Improve code quality
Jack251970 Mar 19, 2025
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
535 changes: 444 additions & 91 deletions Flow.Launcher.Core/Resource/Theme.cs

Large diffs are not rendered by default.

123 changes: 123 additions & 0 deletions Flow.Launcher.Infrastructure/MonitorInfo.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
using System.Collections.Generic;
using System;
using System.Runtime.InteropServices;
using System.Windows;
using Windows.Win32;
using Windows.Win32.Foundation;
using Windows.Win32.Graphics.Gdi;
using Windows.Win32.UI.WindowsAndMessaging;

namespace Flow.Launcher.Infrastructure;

/// <summary>
/// Contains full information about a display monitor.
/// Codes are edited from: <see href="https://github.com/Jack251970/DesktopWidgets3">.
/// </summary>
internal class MonitorInfo
{
/// <summary>
/// Gets the display monitors (including invisible pseudo-monitors associated with the mirroring drivers).
/// </summary>
/// <returns>A list of display monitors</returns>
public static unsafe IList<MonitorInfo> GetDisplayMonitors()
{
var monitorCount = PInvoke.GetSystemMetrics(SYSTEM_METRICS_INDEX.SM_CMONITORS);
var list = new List<MonitorInfo>(monitorCount);
var callback = new MONITORENUMPROC((HMONITOR monitor, HDC deviceContext, RECT* rect, LPARAM data) =>
{
list.Add(new MonitorInfo(monitor, rect));
return true;
});
var dwData = new LPARAM();
var hdc = new HDC();
bool ok = PInvoke.EnumDisplayMonitors(hdc, (RECT?)null, callback, dwData);
if (!ok)
{
Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
}
return list;
}

/// <summary>
/// Gets the display monitor that is nearest to a given window.
/// </summary>
/// <param name="hwnd">Window handle</param>
/// <returns>The display monitor that is nearest to a given window, or null if no monitor is found.</returns>
public static unsafe MonitorInfo GetNearestDisplayMonitor(HWND hwnd)
{
var nearestMonitor = PInvoke.MonitorFromWindow(hwnd, MONITOR_FROM_FLAGS.MONITOR_DEFAULTTONEAREST);
MonitorInfo nearestMonitorInfo = null;
var callback = new MONITORENUMPROC((HMONITOR monitor, HDC deviceContext, RECT* rect, LPARAM data) =>
{
if (monitor == nearestMonitor)
{
nearestMonitorInfo = new MonitorInfo(monitor, rect);
return false;
}
return true;
});
var dwData = new LPARAM();
var hdc = new HDC();
bool ok = PInvoke.EnumDisplayMonitors(hdc, (RECT?)null, callback, dwData);
if (!ok)
{
Marshal.ThrowExceptionForHR(Marshal.GetLastWin32Error());
}
return nearestMonitorInfo;
}

private readonly HMONITOR _monitor;

internal unsafe MonitorInfo(HMONITOR monitor, RECT* rect)
{
RectMonitor =
new Rect(new Point(rect->left, rect->top),
new Point(rect->right, rect->bottom));
_monitor = monitor;
var info = new MONITORINFOEXW() { monitorInfo = new MONITORINFO() { cbSize = (uint)sizeof(MONITORINFOEXW) } };
GetMonitorInfo(monitor, ref info);
RectWork =
new Rect(new Point(info.monitorInfo.rcWork.left, info.monitorInfo.rcWork.top),
new Point(info.monitorInfo.rcWork.right, info.monitorInfo.rcWork.bottom));
Name = new string(info.szDevice.AsSpan()).Replace("\0", "").Trim();
}

/// <summary>
/// Gets the name of the display.
/// </summary>
public string Name { get; }

/// <summary>
/// Gets the display monitor rectangle, expressed in virtual-screen coordinates.
/// </summary>
/// <remarks>
/// <note>If the monitor is not the primary display monitor, some of the rectangle's coordinates may be negative values.</note>
/// </remarks>
public Rect RectMonitor { get; }

/// <summary>
/// Gets the work area rectangle of the display monitor, expressed in virtual-screen coordinates.
/// </summary>
/// <remarks>
/// <note>If the monitor is not the primary display monitor, some of the rectangle's coordinates may be negative values.</note>
/// </remarks>
public Rect RectWork { get; }

/// <summary>
/// Gets if the monitor is the the primary display monitor.
/// </summary>
public bool IsPrimary => _monitor == PInvoke.MonitorFromWindow(new(IntPtr.Zero), MONITOR_FROM_FLAGS.MONITOR_DEFAULTTOPRIMARY);

/// <inheritdoc />
public override string ToString() => $"{Name} {RectMonitor.Width}x{RectMonitor.Height}";

private static unsafe bool GetMonitorInfo(HMONITOR hMonitor, ref MONITORINFOEXW lpmi)
{
fixed (MONITORINFOEXW* lpmiLocal = &lpmi)
{
var lpmiBase = (MONITORINFO*)lpmiLocal;
var __result = PInvoke.GetMonitorInfo(hMonitor, lpmiBase);
return __result;
}
}
}
32 changes: 31 additions & 1 deletion Flow.Launcher.Infrastructure/NativeMethods.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,34 @@ WM_KEYUP
WM_SYSKEYDOWN
WM_SYSKEYUP

EnumWindows
EnumWindows

DwmSetWindowAttribute
DWM_SYSTEMBACKDROP_TYPE
DWM_WINDOW_CORNER_PREFERENCE

MAX_PATH
SystemParametersInfo

SetForegroundWindow

GetWindowLong
GetForegroundWindow
GetDesktopWindow
GetShellWindow
GetWindowRect
GetClassName
FindWindowEx
WINDOW_STYLE

SetLastError
WINDOW_EX_STYLE

GetSystemMetrics
EnumDisplayMonitors
MonitorFromWindow
GetMonitorInfo
MONITORINFOEXW

WM_ENTERSIZEMOVE
WM_EXITSIZEMOVE
25 changes: 25 additions & 0 deletions Flow.Launcher.Infrastructure/PInvokeExtensions.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System.Runtime.InteropServices;
using Windows.Win32.Foundation;
using Windows.Win32.UI.WindowsAndMessaging;

namespace Windows.Win32;

// Edited from: https://github.com/files-community/Files
internal static partial class PInvoke
{
[DllImport("User32", EntryPoint = "SetWindowLongW", ExactSpelling = true)]
static extern int _SetWindowLong(HWND hWnd, int nIndex, int dwNewLong);

[DllImport("User32", EntryPoint = "SetWindowLongPtrW", ExactSpelling = true)]
static extern nint _SetWindowLongPtr(HWND hWnd, int nIndex, nint dwNewLong);

// NOTE:
// CsWin32 doesn't generate SetWindowLong on other than x86 and vice versa.
// For more info, visit https://github.com/microsoft/CsWin32/issues/882
public static unsafe nint SetWindowLongPtr(HWND hWnd, WINDOW_LONG_PTR_INDEX nIndex, nint dwNewLong)
{
return sizeof(nint) is 4
? _SetWindowLong(hWnd, (int)nIndex, (int)dwNewLong)
: _SetWindowLongPtr(hWnd, (int)nIndex, dwNewLong);
}
}
9 changes: 9 additions & 0 deletions Flow.Launcher.Infrastructure/UserSettings/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public string Theme
}
}
public bool UseDropShadowEffect { get; set; } = true;
public BackdropTypes BackdropType{ get; set; } = BackdropTypes.None;

/* Appearance Settings. It should be separated from the setting later.*/
public double WindowHeightSize { get; set; } = 42;
Expand Down Expand Up @@ -430,4 +431,12 @@ public enum AnimationSpeeds
Fast,
Custom
}

public enum BackdropTypes
{
None,
Acrylic,
Mica,
MicaAlt
}
}
Loading
Loading