Skip to content

Commit

Permalink
fix: maximized windows stay maximized when new windows are created an…
Browse files Browse the repository at this point in the history
…d after switching worskpaces
  • Loading branch information
phisko committed Oct 4, 2023
1 parent f292744 commit 1298f8e
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ public CommandResponse Handle(RedrawContainersCommand command)
var windowsToRestore = windowsToRedraw
.Where(
(window) =>
window is not MinimizedWindow &&
window.HasWindowStyle(WindowStyles.Maximize | WindowStyles.Minimize)
(window is not MinimizedWindow && window.HasWindowStyle(WindowStyles.Minimize)) ||
(window is not MaximizedWindow && window.HasWindowStyle(WindowStyles.Maximize))
)
.ToList();

Expand Down Expand Up @@ -109,6 +109,13 @@ DisplayState.Shown or
return;
}

if (window is MaximizedWindow)
{
defaultFlags |= SetWindowPosFlags.NoSize;
defaultFlags |= SetWindowPosFlags.NoMove;
defaultFlags |= SetWindowPosFlags.NoZOrder;
}

// Get z-order to set for floating windows.
var shouldShowOnTop = _userConfigService.GeneralConfig.ShowFloatingOnTop;
var floatingZOrder = shouldShowOnTop
Expand Down
18 changes: 18 additions & 0 deletions GlazeWM.Domain/Windows/CommandHandlers/SetMaximizedHandler.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using GlazeWM.Domain.Containers.Commands;
using GlazeWM.Domain.Windows.Commands;
using GlazeWM.Infrastructure.Bussing;
using static GlazeWM.Infrastructure.WindowsApi.WindowsApiService;
Expand All @@ -6,11 +7,28 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
{
internal sealed class SetMaximizedHandler : ICommandHandler<SetMaximizedCommand>
{
private readonly Bus _bus;

public SetMaximizedHandler(Bus bus)
{
_bus = bus;
}

public CommandResponse Handle(SetMaximizedCommand command)
{
var window = command.Window;

ShowWindow(window.Handle, ShowWindowFlags.Maximize);
var maximizedWindow = new MaximizedWindow(
window.Handle,
window.FloatingPlacement,
window.BorderDelta
)
{
Id = window.Id
};

_bus.Invoke(new ReplaceContainerCommand(maximizedWindow, window.Parent, window.Index));

return CommandResponse.Ok;
}
Expand Down
13 changes: 10 additions & 3 deletions GlazeWM.Domain/Windows/CommandHandlers/ToggleMaximizedHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,21 @@ namespace GlazeWM.Domain.Windows.CommandHandlers
{
internal sealed class ToggleMaximizedHandler : ICommandHandler<ToggleMaximizedCommand>
{
private readonly Bus _bus;

public ToggleMaximizedHandler(Bus bus)
{
_bus = bus;
}

public CommandResponse Handle(ToggleMaximizedCommand command)
{
var window = command.Window;

if (window.HasWindowStyle(WindowStyles.Maximize))
ShowWindow(window.Handle, ShowWindowFlags.Restore);
if (window is MaximizedWindow)
_bus.Invoke(new SetTilingCommand(window));
else
ShowWindow(window.Handle, ShowWindowFlags.Maximize);
_bus.Invoke(new SetMaximizedCommand(window));

return CommandResponse.Ok;
}
Expand Down

0 comments on commit 1298f8e

Please sign in to comment.