Skip to content

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

feat(domain): avoid toggling floating if focused window is not in foreground

Lars Berger05231480670f
diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ToggleFocusedWindowFloatingHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ToggleFocusedWindowFloatingHandler.cs
index eef29442..3923bcb8 100644
--- a/GlazeWM.Domain/Windows/CommandHandlers/ToggleFocusedWindowFloatingHandler.cs
+++ b/GlazeWM.Domain/Windows/CommandHandlers/ToggleFocusedWindowFloatingHandler.cs
@@ -1,6 +1,7 @@
using GlazeWM.Domain.Containers;
using GlazeWM.Domain.Windows.Commands;
using GlazeWM.Infrastructure.Bussing;
+using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService;
namespace GlazeWM.Domain.Windows.CommandHandlers
{
@@ -18,9 +19,10 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
public CommandResponse Handle(ToggleFocusedWindowFloatingCommand command)
{
var focusedWindow = _containerService.FocusedContainer as Window;
+ var foregroundWindow = GetForegroundWindow();
- // Ignore cases where focused container is not a window.
- if (focusedWindow == null)
+ // Ignore cases where focused container is not a window or not in foreground.
+ if (focusedWindow == null || foregroundWindow != focusedWindow.Hwnd)
return CommandResponse.Ok;
_bus.Invoke(new ToggleFloatingCommand(focusedWindow));