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

Monocle Layout "minimize unfocused windows" fix and improvements #45

Merged

Conversation

bladedvox
Copy link
Contributor

@bladedvox bladedvox commented Sep 22, 2021

Summary

Fixes Monocle Layout with Minimize Unfocused Windows (internally config.monocleMinimizeRest) option enabled.

Restores previous functionality (before Wayland patches) and adds

  • minimize inactive windows only on same monitor with multimonitor setup
  • can switch windows with focus-changing Actions
  • switches to the next window when closing the active window (still a little buggy in multimonitor, but a big improvment)
  • handles moving window onto a Surface with this layout properly

Breaking Changes

None

UI Changes

Removed "(WIP)" from "Minimize unfocused windows" option in the config UI.

Test Plan

  1. Reload script
  2. Verify all behavior in the Summary

Related Issues

Closes #43, #55

@gikari
Copy link
Member

gikari commented Sep 22, 2021

Could you also change your commit messages to respect CC?

@bladedvox bladedvox force-pushed the multimonitor_monocle_minimize_others branch from 2bb9f3f to cef1f23 Compare September 22, 2021 17:21
@bladedvox bladedvox marked this pull request as draft September 22, 2021 17:22
@bladedvox
Copy link
Contributor Author

@gikari I've got the original functionality restored. It's kind of hacky but the only way I could find to do it. Basically I added a hook to controller.onWindowFocused() to do the minimization under the correct layout (and if the setting is enabled). I also had controller.showNotification() raise the event as well so that it works properly when first changing to the Monocle layout.

How do you want to handle the finer points?

  • Should we enable this by default?
  • Should we make an exception for the focus cycle (or add a separate Action) that includes minimized windows in the queue when switching focus?

Copy link
Member

@gikari gikari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we enable this by default?

Not yet. If it works well - we probably should in the future.

Should we make an exception for the focus cycle (or add a separate Action) that includes minimized windows in the queue when switching focus?

We have FocusNextWindow and FocusPreviousWindow. Those should work with this option on as in before. As for Focus Left, Right and so on, I am not sure. How do those work in classic tilings WMs with monocle layout (It seems like Monocle is the terminology, that comes from dwm)?

src/controller/index.ts Outdated Show resolved Hide resolved
src/controller/index.ts Outdated Show resolved Hide resolved
@bladedvox
Copy link
Contributor Author

I will address the comments you raised today -- as for the keyboard shortcuts, it's been a long time since I used DWM, but looking at the source code now it seems that it doesn't implement minimization at all. I currently like the behavior we have of cycling only through visible windows with the FocusNext/PrevWindow actions. I use a keybind for a task switcher that cycles through minimized windows only if I need to quickly get access to one, and is how I currently switch focus by keyboard in Monocle mode with the monocleMinimizeRest option enabled.

I think, just to avoid needing a separate keyboard shortcut, we should either
a. include minimized windows for consideration in FoucsNext/Prev
b. add an optional argument to engine.focusOrder() that is used in MonocleLayout (when this option is enabled) when overriding FocusNext/Prev/Bottom/Upper/Left/Right that includes minimized windows for consideration

I lean towards b since I like the current focus switching model.

@gikari
Copy link
Member

gikari commented Sep 26, 2021

it's been a long time since I used DWM, but looking at the source code now it seems that it doesn't implement minimization at all.

I meant if the switching between windows in monocle mode works with Next/Previous window shortcuts. If it is, we should do the same, but we can provide an option to exclude minimized windows from the list.

@bladedvox
Copy link
Contributor Author

bladedvox commented Sep 27, 2021

Using this branch on my machine and so far so good. Here's some notes on the behavior:

Assuming monocle layout and config.monocleMinimizeRest == true:

  • You can switch windows with the WindowFocusNext/Prev/Right/Left/Upper/Bottom Actions
  • Closing the active window switches to the next window
  • Floating windows on the DriverSurface are handled properly
  • Moving a tiled window into the workspace/screen results in it being the only visible window

There is still an issue with using this layout in a multi-monitor setup -- if you close the active window in Monocle layout in your secondary monitor, it switches to a window in the primary monitor instead of the same monitor that the closed window was in. I Haven't really figured out why this is happening. I have some code that tries to fix it but it isn't really working. Will update with progress on that. Other than that minor issue, I am comfortable with the experience so far.

@bladedvox bladedvox marked this pull request as ready for review September 29, 2021 16:28
@bladedvox
Copy link
Contributor Author

@gikari I wasn't able to get focus to change to the same monitor as the closed window when closing the active window in Moncole mode with monocleMinimizeRest == true in a multimonitor setup, but other than that it's a smooth experience and I'm pretty satisfied. I think we should wrap this PR up and try to address that bug later. Let me know if any architectural issues still need to be addressed :)

@bladedvox
Copy link
Contributor Author

I see the failing tests. Edited the action.test locally and will rebase/reword to shorten my commit messages.

@gikari
Copy link
Member

gikari commented Sep 29, 2021

I see the failing tests. Edited the action.test locally and will rebase/reword to shorten my commit messages.

Could you also please update the MR description according to the new template please?

@bladedvox bladedvox force-pushed the multimonitor_monocle_minimize_others branch from 86ae8a5 to 92c00fa Compare September 29, 2021 22:50
@bladedvox bladedvox changed the title Monocle Layout "minimize others" only on same monitor Monocle Layout "minimize unfocused windows" fix and improvements Sep 29, 2021
@bladedvox
Copy link
Contributor Author

PR description updated, hope it's all up to standard :)

Copy link
Member

@gikari gikari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! 🎉 I just tested, and it works very well (except after closing a window in multimonitor it focuses the one, on the other monitor, so after merging you could create an issue for this strange behavior). Just a little small nitpicks (including in-code comments):

I think you can remove WIP it the UI. It still has the multimonitor problem, but I think it works good to be considered WIP feature, and in general marking something WIP in the UI lies not a good impression on the end user.

Also, I apologize for some pasts of CI not working as intended right now. So, could you please format your code with prettier?

And you need to rebase your branch on the current master.

src/controller/index.ts Show resolved Hide resolved
src/controller/index.ts Outdated Show resolved Hide resolved
src/controller/index.ts Outdated Show resolved Hide resolved
src/controller/index.ts Outdated Show resolved Hide resolved
src/engine/index.ts Show resolved Hide resolved
src/engine/index.ts Outdated Show resolved Hide resolved
@bladedvox bladedvox force-pushed the multimonitor_monocle_minimize_others branch from 92c00fa to f772f21 Compare September 30, 2021 01:12
@bladedvox
Copy link
Contributor Author

Addressed the issues you mentioned, got the husky hooks set up, verified with ESLint (apparently if you have a default parameter in a function, you don't need to declare its type, good to know) and formatted with Prettier. Rebuilt and restarted KWin for good measure. Everything seems good on my end!

Copy link
Member

@gikari gikari left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, I noticed another thing - if I switch to another layout, the windows, that were minimized by the script are not brought back. I think this, can be addressed in another PR. For now, it is good.

@@ -343,42 +350,42 @@ export class TilingEngine implements Engine {
this.windows.remove(window);
}

/**
* Focus the next or previous window.
/** Focus next or previous window
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't have to duplicate JSDoc here.

@gikari gikari merged commit 5e26214 into Bismuth-Forge:master Sep 30, 2021
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.

"Minimize other windows in Monocle layout" should only minimize windows on the same monitor
2 participants