Skip to content

Commit

Permalink
Added Dim Taskbar option (#13)
Browse files Browse the repository at this point in the history
* dim taskbar option

* Update App.xaml.cs
  • Loading branch information
Yiannis1999 authored Aug 16, 2024
1 parent 748a121 commit db72d33
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
21 changes: 21 additions & 0 deletions App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,15 @@ public void WinCloseEventProc(IntPtr hWinEventHook, uint eventType, IntPtr hwnd,
shadeWindows.Remove(windowShade);
}
}

if(settings.DimTaskbar)
{
IntPtr taskbarHwnd = Win32.FindWindow("Shell_TrayWnd", null);

Check warning on line 215 in App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
if (taskbarHwnd != IntPtr.Zero)
{
Win32.SetWindowPos(taskbarHwnd, Win32.HWND_BOTTOM, 0, 0, 0, 0, Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.SWP_NOACTIVATE);
}
}
}

private void UpdateDimming(IntPtr fgHwnd)
Expand All @@ -229,6 +238,15 @@ private void UpdateDimming(IntPtr fgHwnd)
// Finally place the dimmer window behind the first pinned or foreground
Win32.SetWindowPos(dimWin.Handle, firstPinned ?? fgHwnd, 0, 0, 0, 0, Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.SWP_NOACTIVATE);
}

if(settings.DimTaskbar)
{
IntPtr taskbarHwnd = Win32.FindWindow("Shell_TrayWnd", null);

Check warning on line 244 in App.xaml.cs

View workflow job for this annotation

GitHub Actions / build

Cannot convert null literal to non-nullable reference type.
if (taskbarHwnd != IntPtr.Zero)
{
Win32.SetWindowPos(taskbarHwnd, Win32.HWND_BOTTOM, 0, 0, 0, 0, Win32.SWP_NOMOVE | Win32.SWP_NOSIZE | Win32.SWP_NOACTIVATE);
}
}
}

private void UpdateShade(IntPtr shadedHwnd, WindowShade windowShade)
Expand Down Expand Up @@ -286,6 +304,9 @@ public interface ISettings : INotifyPropertyChanged
[Option(Alias = "dimmingEnabled", DefaultValue = false)]
bool DimmingEnabled { get; set; }

[Option(Alias = "dimTaskbar", DefaultValue = true)]
bool DimTaskbar { get; set; }

[Option(Alias = "brightness", DefaultValue = 50)]
int Brightness { get; set; }

Expand Down
4 changes: 4 additions & 0 deletions NotifyIconController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ public NotifyIconController(ISettings settings)
};
})
.AddHandler((b) => settings.DimmingEnabled = b))
.AddToggle(option => option
.SetText("Dim Taskbar?")
.SetChecked(settings.DimTaskbar)
.AddHandler((b) => settings.DimTaskbar = b))
.AddToggle(option => option
.SetText("Active on launch?")
.SetChecked(settings.ActiveOnLaunch)
Expand Down
3 changes: 3 additions & 0 deletions Win32.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public static partial class Win32
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern int SetWindowLong(IntPtr hWnd, int nIndex, int dwNewLong);

[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = true)]
public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

public static readonly IntPtr HWND_TOP = new IntPtr(0);
public static readonly IntPtr HWND_BOTTOM = new IntPtr(1);
public static readonly IntPtr HWND_NOTOPMOST = new IntPtr(-2);
Expand Down

0 comments on commit db72d33

Please sign in to comment.