Skip to content

Commit

Permalink
another fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lars-berger committed Sep 5, 2023
1 parent 8ab806a commit 4582538
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ public CommandResponse Handle(ManageWindowCommand command)
else
_bus.Invoke(new AttachContainerCommand(window, targetParent, targetIndex));

// The OS might spawn the window on a different monitor to the target parent, so adjustments
// might need to be made because of DPI.
var monitor = _monitorService.GetMonitorFromHandleLocation(windowHandle);
if (MonitorService.HasDpiDifference(monitor, window.Parent))
window.HasPendingDpiAdjustment = true;

var windowRules = _userConfigService.GetMatchingWindowRules(window);
var windowRuleCommands = windowRules
.SelectMany(rule => rule.CommandList)
Expand Down Expand Up @@ -89,7 +95,7 @@ public CommandResponse Handle(ManageWindowCommand command)
return CommandResponse.Ok;
}

private Window CreateWindow(IntPtr windowHandle, Container targetParent)
private static Window CreateWindow(IntPtr windowHandle, Container targetParent)
{
var originalPlacement = WindowService.GetPlacementOfHandle(windowHandle).NormalPosition;

Expand All @@ -104,7 +110,7 @@ private Window CreateWindow(IntPtr windowHandle, Container targetParent)
var isResizable = WindowService.HandleHasWindowStyle(windowHandle, WindowStyles.ThickFrame);

// TODO: Handle initialization of maximized and fullscreen windows.
Window window = windowType switch
return windowType switch
{
WindowType.Minimized => new MinimizedWindow(
windowHandle,
Expand All @@ -126,14 +132,6 @@ private Window CreateWindow(IntPtr windowHandle, Container targetParent)
WindowType.Fullscreen => throw new ArgumentException(null, nameof(windowHandle)),
_ => throw new ArgumentException(null, nameof(windowHandle)),
};

// The OS might spawn the window on a different monitor to the target parent, so adjustments
// might need to be made because of DPI.
var monitor = _monitorService.GetMonitorFromHandleLocation(windowHandle);
if (MonitorService.HasDpiDifference(monitor, window.Parent))
window.HasPendingDpiAdjustment = true;

return window;
}

private static WindowType GetWindowTypeToCreate(IntPtr windowHandle)
Expand Down

0 comments on commit 4582538

Please sign in to comment.