Skip to content

GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.

feat(bar): hide WPF window from task switch (alt+tab menu)

Lars Berger2abec9cffbd9
diff --git a/GlazeWM.Bar/MainWindow.xaml.cs b/GlazeWM.Bar/MainWindow.xaml.cs
index 706c38dc..fc38637b 100644
--- a/GlazeWM.Bar/MainWindow.xaml.cs
+++ b/GlazeWM.Bar/MainWindow.xaml.cs
@@ -31,9 +31,20 @@ namespace GlazeWM.Bar
base.OnSourceInitialized(e);
var windowHandle = new WindowInteropHelper(this).Handle;
+ HideFromTaskSwitcher(windowHandle);
PositionWindow(windowHandle);
}
+ /// <summary>
+ /// Hide the WPF window from task switcher (alt+tab menu).
+ /// </summary>
+ private void HideFromTaskSwitcher(IntPtr windowHandle)
+ {
+ var exstyle = (int)GetWindowLongPtr(windowHandle, GWL_EXSTYLE);
+ exstyle |= (int)(WS_EX.WS_EX_TOOLWINDOW);
+ SetWindowLongPtr(windowHandle, GWL_EXSTYLE, (IntPtr)exstyle);
+ }
+
/// <summary>
/// Position and size the WPF window manually using WinAPI. When using `PerMonitorAwareV2` DPI
/// awareness, positioning the window with WPF bindings is ambiguous and annoying.