Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: option to disable floating windows initial centering #476

Conversation

Video-Nomad
Copy link
Contributor

Issue: some apps (Autodesk Maya, 3ds Max) have a workflow of creating floating windows constantly. Setting a rule of "set floating" to those windows will center them on the screen every time you open them. By default, those apps keep the position of those windows internally, but GlazeWM will treat them as new windows every time and center them (even within one session).

Solution: have an option to disable initial centering of newly created floating windows. Default behavior will not change, unless the user decides to set the option to false. I keep it constantly to false in my build.

Possible issues: I haven't tested this on a multi-monitor setup, as I don't use multiple screens.

Partially closes the (#436)

@lars-berger
Copy link
Member

Hey, thanks for the PR! 👍 Started a poIl in the discord just now for whether we should change the default to false instead. I actually think more people find the centering annoying than useful, but we can wait a few hours before making the change

There's a minor issue when using multi monitors. If you have an empty workspace 1 on monitor A and a non-empty workspace 2 on monitor B, then when a window is opened with workspace 1 focused, the OS will plop it on workspace 2. So there just needs to be a check in ManageWindowHandler.cs whether the window was opened on a different monitor than where it should go, and if so, translate it to center.

@Video-Nomad
Copy link
Contributor Author

Video-Nomad commented Dec 19, 2023

Thanks for the heads-up @lars-berger ! I need to buy a second monitor, I guess 😅
I think this check should do the trick. If the window is not in the correct workspace it will snap it to the center:

var targetWorkspace = WorkspaceService.GetWorkspaceFromChildContainer(targetParent);
var windowWorkspace = _monitorService
  .GetMonitorFromHandleLocation(windowHandle)
  .DisplayedWorkspace;

var floatingPlacement = originalPlacement;
if (windowWorkspace != targetWorkspace ||
    _userConfigService.GeneralConfig.CenterNewFloatingWindows)
{
  floatingPlacement = floatingPlacement.TranslateToCenter(targetWorkspace.ToRect());
}

Let me know if it will work, I can't really test it on my end at the moment.

Also, how's the poll going? Should I change the floating centering to be false by default?

@lars-berger
Copy link
Member

@Video-Nomad Surprisingly it looks like more people prefer the default centering behavior (15:4 votes so far), so it's fine to leave as is 👍

Thanks for the snippet, I can test it out later and commit it directly to your branch

@lars-berger lars-berger merged commit 18eb8c8 into glzr-io:develop Dec 21, 2023
1 check passed
@Video-Nomad Video-Nomad deleted the feat/optional-floating-windows-centering branch December 31, 2023 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants