GlazeWM is a tiling window manager for macOS and Windows inspired by i3wm.
feat: option to disable floating windows initial centering (#476)
George Sladkovsky18eb8c80ceaf
diff --git a/GlazeWM.App/Resources/sample-config.yaml b/GlazeWM.App/Resources/sample-config.yamlindex 5dc5860f..f537afaf 100644--- a/GlazeWM.App/Resources/sample-config.yaml+++ b/GlazeWM.App/Resources/sample-config.yaml@@ -15,6 +15,9 @@ general:# Amount to move floating windows by (eg. when using `alt+<hjkl>` on a floating window)floating_window_move_amount: "5%"+ # Whether to center new floating windows.+ center_new_floating_windows: true+# *Strongly* recommended to set to 'false'. Whether to globally enable/disable# window transition animations (on minimize, close, etc). Set to 'unchanged'# to make no setting changes.diff --git a/GlazeWM.Domain/UserConfigs/GeneralConfig.cs b/GlazeWM.Domain/UserConfigs/GeneralConfig.csindex 27a88df8..8d892469 100644--- a/GlazeWM.Domain/UserConfigs/GeneralConfig.cs+++ b/GlazeWM.Domain/UserConfigs/GeneralConfig.cs@@ -26,5 +26,9 @@ namespace GlazeWM.Domain.UserConfigs/// Whether to enable window transition animations (on minimize, close, etc)./// </summary>public WindowAnimations WindowAnimations { get; set; } = WindowAnimations.Unchanged;+ /// <summary>+ /// Whether to center new floating windows+ /// </summary>+ public bool CenterNewFloatingWindows { get; set; } = true;}}diff --git a/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs b/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.csindex 0587864f..217a7bcd 100644--- a/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs+++ b/GlazeWM.Domain/Windows/CommandHandlers/ManageWindowHandler.cs@@ -87,14 +87,21 @@ namespace GlazeWM.Domain.Windows.CommandHandlersreturn CommandResponse.Ok;}- private static Window CreateWindow(IntPtr windowHandle, Container targetParent)+ private Window CreateWindow(IntPtr windowHandle, Container targetParent){var originalPlacement = WindowService.GetPlacementOfHandle(windowHandle).NormalPosition;- // Calculate where window should be placed when floating is enabled. Use the original- // width/height of the window, but position it in the center of the workspace.var targetWorkspace = WorkspaceService.GetWorkspaceFromChildContainer(targetParent);- var floatingPlacement = originalPlacement.TranslateToCenter(targetWorkspace.ToRect());+ var handleWorkspace = _monitorService+ .GetMonitorFromHandleLocation(windowHandle)+ .DisplayedWorkspace;++ // Calculate where window should be placed when floating is enabled. Use the original+ // width/height of the window and optionally position it in the center of the workspace.+ var centerNewFloatingWindows = _userConfigService.GeneralConfig.CenterNewFloatingWindows;+ var floatingPlacement = handleWorkspace == targetWorkspace && !centerNewFloatingWindows+ ? originalPlacement+ : originalPlacement.TranslateToCenter(targetWorkspace.ToRect());var defaultBorderDelta = new RectDelta(7, 0, 7, 7);diff --git a/README.md b/README.mdindex 394bc7ba..3fbc0b96 100644--- a/README.md+++ b/README.md@@ -91,6 +91,9 @@ general:# Whether to globally enable/disable window transition animations (on minimize, close,# etc). Set to 'unchanged' to make no setting changes.window_animations: "unchanged"++ # Whether to center new floating windows (default is true)+ center_new_floating_windows: true```## Keybindings