ianyh / Amethyst

Automatic tiling window manager for macOS à la xmonad.
https://ianyh.com/amethyst/
MIT License
14.66k stars 486 forks source link

Add the ability for custom layouts to hide/show widows #1603

Open j-o-sh opened 7 months ago

j-o-sh commented 7 months ago

First of all: Thank you for creating Amethyst. It is a superb tool for my workflow. 🙏🥳

I have been playing around with cutom layouts, since I would like a very particular layout that

With this layout I could have a two-panel screen setup, where my main terminal (with tmux, neovim, etc.) always stays on the left, while I can switch between different supplementary apps on the right.

However I ran into the issue that I couldn't find out how to show or hide windows fro a custom layout and I fear it may not even be possible right now.

Could this be done? Maybe even by returning the window with visible: false from the getFrameAssignments method?

Or something like:

getFrameAssignments(windows, screen, state) {
  return {
    [windows[0].id]: mainFrame(window[0]),
    [windows[activeAside].id: sideFrame(window[activeAside]),
    // every other window - setting the id to `false` instead of a frame would hide it?
    [windows[x].id]: false
  }
}
ianyh commented 7 months ago

You could give all of the supplementary windows the same frame and focus the "visible" one.

j-o-sh commented 7 months ago

Yes, that is basically how I do it with the 'Tall' layout at the moment.

The problem here is only that this doesn't allow me to switch the supplementary window quickly, while staying im my editor. If I could hide windows from the getFrameAssignments method or even just switch their z-stacking, I could cycle through them with a single layout command. ;)

ianyh commented 7 months ago

Ah, I see the problem, yeah. You can try setting a max windows count, and see if that does what you want. It will minimize rather than hide, but functionally should be pretty much the same.

ianyh commented 7 months ago

Oh, actually, maybe that has the same cycling problem.

ianyh commented 7 months ago

I think it would be mostly straightforward to add hiding as a custom layout capability. I don't have the bandwidth immediately, but it could make for a good contribution if anyone has cycles to put towards it.

j-o-sh commented 7 months ago

Unfortunatelly yes. Also, maxWindowCount is global and not per layout. 🤔

As to contributing: Could you point me into the direction of where I would start doing that? I may try if I can do that if that's cool with you. Or maybe even code that layout as a Swift one?

j-o-sh commented 7 months ago

...while I am at it: Is there a way to get at the settings for screenPadding and window Margins in a custom layout?

ianyh commented 7 months ago

Not currently, no. And I would prefer that we add it as a capability of custom layouts. You can look at CustomLayout.swift and ReflowOperation.swift.