Skip to content

Commit

Permalink
taskbar icon fix
Browse files Browse the repository at this point in the history
- Fixed an issue where the taskbar icon appears for some wallpapers.
  • Loading branch information
rocksdanister committed Feb 9, 2021
1 parent bfa87cc commit 567aa58
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ private void LoadUI()
catch (Exception e)
{
Logger.Error(e.ToString());
Task.Run(() => (MessageBox.Show(e.ToString(), Properties.Resources.TitleAppName)));
_= Task.Run(() => (MessageBox.Show(e.ToString(), Properties.Resources.TitleAppName)));
}
}

Expand Down
7 changes: 5 additions & 2 deletions src/livelywpf/livelywpf/Core/SetupDesktop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -219,9 +219,12 @@ public static void SetWallpaper(LibraryModel wallpaper, LivelyScreen display)
Logger.Info("Core: Skipping program wallpaper on MSIX package.");
System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new ThreadStart(delegate
{
Program.LibraryVM.WallpaperDelete(wallpaper);
if (wallpaper.DataType == LibraryTileType.processing)
{
Program.LibraryVM.WallpaperDelete(wallpaper);
}
}));
MessageBox.Show(Properties.Resources.TextFeatureMissing, Properties.Resources.TextError);
_= Task.Run(() => (MessageBox.Show(Properties.Resources.TextFeatureMissing, Properties.Resources.TextError)));
}
else
{
Expand Down
26 changes: 15 additions & 11 deletions src/livelywpf/livelywpf/Helpers/WindowOperations.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ public static void SetParentSafe(IntPtr child, IntPtr parent)
public static void BorderlessWinStyle(IntPtr handle)
{
// Get window styles
var styleCurrentWindowStandard = NativeMethods.GetWindowLongPtr(handle, (-16));
var styleCurrentWindowExtended = NativeMethods.GetWindowLongPtr(handle, (-20));
var styleCurrentWindowStandard = NativeMethods.GetWindowLongPtr(handle, (int)NativeMethods.GWL.GWL_STYLE);
var styleCurrentWindowExtended = NativeMethods.GetWindowLongPtr(handle, (int)NativeMethods.GWL.GWL_EXSTYLE);

// Compute new styles (XOR of the inverse of all the bits to filter)
var styleNewWindowStandard =
Expand Down Expand Up @@ -135,8 +135,8 @@ public static void BorderlessWinStyle(IntPtr handle)
);

// update window styles
NativeMethods.SetWindowLongPtr(new HandleRef(null, handle), (-16), (IntPtr)styleNewWindowStandard);
NativeMethods.SetWindowLongPtr(new HandleRef(null, handle), (-20), (IntPtr)styleNewWindowExtended);
NativeMethods.SetWindowLongPtr(new HandleRef(null, handle), (int)NativeMethods.GWL.GWL_STYLE, (IntPtr)styleNewWindowStandard);
NativeMethods.SetWindowLongPtr(new HandleRef(null, handle), (int)NativeMethods.GWL.GWL_EXSTYLE, (IntPtr)styleNewWindowExtended);

// remove the menu and menuitems and force a redraw
var menuHandle = NativeMethods.GetMenu(handle);
Expand All @@ -158,16 +158,20 @@ public static void BorderlessWinStyle(IntPtr handle)
/// <param name="handle">window handle</param>
public static void RemoveWindowFromTaskbar(IntPtr handle)
{
var styleNewWindowExtended =
(Int64)NativeMethods.WindowStyles.WS_EX_NOACTIVATE
| (Int64)NativeMethods.WindowStyles.WS_EX_TOOLWINDOW;
var styleCurrentWindowExtended = NativeMethods.GetWindowLongPtr(handle, (int)NativeMethods.GWL.GWL_EXSTYLE);

var styleNewWindowExtended = styleCurrentWindowExtended.ToInt64() |
(Int64)NativeMethods.WindowStyles.WS_EX_NOACTIVATE |
(Int64)NativeMethods.WindowStyles.WS_EX_TOOLWINDOW;

// update window styles
NativeMethods.SetWindowLongPtr(new HandleRef(null, handle), (-20), (IntPtr)styleNewWindowExtended);
//https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setwindowlongptra
//Certain window data is cached, so changes you make using SetWindowLongPtr will not take effect until you call the SetWindowPos function?
NativeMethods.ShowWindow(handle, (int)NativeMethods.SHOWWINDOW.SW_HIDE);
NativeMethods.SetWindowLongPtr(new HandleRef(null, handle), (int)NativeMethods.GWL.GWL_EXSTYLE, (IntPtr)styleNewWindowExtended);
NativeMethods.ShowWindow(handle, (int)NativeMethods.SHOWWINDOW.SW_SHOW);
}

public const int GWL_EXSTYLE = -20;
public const int WS_EX_LAYERED = 0x80000;
public const int LWA_ALPHA = 0x2;
public const int LWA_COLORKEY = 0x1;

Expand All @@ -182,7 +186,7 @@ public static void SetWindowTransparency(IntPtr Handle)
styleCurrentWindowExtended.ToInt64() ^
NativeMethods.WindowStyles.WS_EX_LAYERED;

NativeMethods.SetWindowLongPtr(new HandleRef(null, Handle), GWL_EXSTYLE, (IntPtr)styleNewWindowExtended);
NativeMethods.SetWindowLongPtr(new HandleRef(null, Handle), (int)NativeMethods.GWL.GWL_EXSTYLE, (IntPtr)styleNewWindowExtended);
NativeMethods.SetLayeredWindowAttributes(Handle, 0, 128, LWA_ALPHA);
}
}
Expand Down
8 changes: 0 additions & 8 deletions src/livelywpf/livelywpf/Views/Screen/ScreenLayoutView.xaml.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace livelywpf.Views
{
Expand Down
2 changes: 1 addition & 1 deletion src/livelywpf/livelywpf/livelywpf.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<StartupObject>livelywpf.Program</StartupObject>
<ApplicationIcon>appicon.ico</ApplicationIcon>
<Version>1.0.0</Version>
<AssemblyVersion>1.1.9.0</AssemblyVersion>
<AssemblyVersion>1.1.9.2</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x86'">
Expand Down

0 comments on commit 567aa58

Please sign in to comment.