Skip to content

Conversation

AethanFoot
Copy link
Member

@AethanFoot AethanFoot commented Aug 19, 2021

Tagging #260, #447, #292. This is just an initial commit, and to open a bit of a discussion. I agree with the notes in #447, where there should be an option to allow the user to choose to have per tag or per workspace layouts with which could be toggled via a command. Other issues we should address is the management of layouts, with this added complexity it becomes harder for a new dev to find their way through the code, e.g. the fact that the layout vec is stored in config, manager, workspace, and now tag. I feel it would be helpful to add a layout manager similar to the focus manager, which holds the list, which mode the user is in, and common functions around changing the layout.

Another option we could add would be choosing the mode per workspace, say tags sent to workspace one will be forced to the same layout but on workspace two will use the tags preferred layout.

Many Thanks!

Edit closes #260, closes #447.

@AethanFoot AethanFoot marked this pull request as draft August 19, 2021 17:03
@stevensonmt
Copy link
Contributor

In my head I equate workspaces to actual screen real estate and tags to collections of opened windows. This feature applied per workspace would allow specific workflows to take advantage of specific monitor dimensions/orientation. It would also allow for tags to define a certain workflow that could be set up on any workspace/monitor.
With that in mind to maximize the utility of the feature I would consider having both options available but then there's the issue of which setting gets precedence and should that be user configurable?
I appreciate as a newcomer to leftwm and development in general the desire to keep the code human readable. The layout manager idea makes a lot of sense in that regard.

@VuiMuich
Copy link
Member

I wholeheartedly agree on the idea of a layout manager!

Maybe instead of a bool it is more like a tuple apply_layout_to with options workspace, all_tags, individual_tag and the toggle command cycles through the modes?
We might move this option to be a optional field of the detailed workspace config, same should go for the layout option.
Maybe something like this:

[[workspaces]]
x = 0
y = 0
height = 1200
width = 1920
layouts = ["MainAndDeck", "Monocle"]
apply_layout_to = ["workspace", "all_tags", "individual_tags"]

[[workspaces]]
y = 1200
x = 0
height = 1440
width = 1280
layouts = ["MainAndDeck"]
apply_layout_to = ["workspace"]

[[workspaces]]
y = 1200
x = 1280
height = 1440
width = 1280
layouts = ["MainAndDeck", "Monocle", "CenterMainBalanced", "LeftWiderRightStack"]
apply_layout_to = ["individual_tags"]

@stevensonmt
Copy link
Contributor

Maybe this is not a configurable setting at all but a command that takes a layout plus a workspace or tag as arguments. Users can run the command to set a desired layout per tag or workspace in their up scripts to make it theme-able. Keeps it from propagating another setting throughout the code. Is that overly simplistic?

@lex148
Copy link
Member

lex148 commented Aug 21, 2021

Sorry a bit late to the conversation. The layout manager is a great idea. Abstracting code and concepts away is always a big win. I would even take it one step further and say you should pull each behavior into its own file under the layout manager module.

@AethanFoot AethanFoot marked this pull request as ready for review October 2, 2021 11:19
@AethanFoot
Copy link
Member Author

So this has a base implementation of layout per tag being togglable between tag and workspace. It is ready and should be easy and extend this with greater customisation (don't know if we should wait for the new config format before deciding more complex configuration setups?). This has also simplified routing through the code with more things directly accessing what they need directly, and we are no longer passing around vectors of tags or layouts when not needed.

This should be merged after the fixes #499 and #500, and I will fix any conflicts.

Thanks!

@lex148
Copy link
Member

lex148 commented Oct 6, 2021

@AethanFoot I am excited to get this one merged in but am having a little trouble testing. I see the config setting to change from Tag to Workspace mode, but it doesn't seam to change anything. Am I missing something? I also see you are defaulting to Workspace. I think that is a really good Idea while we are still developing this. Lets keep the default at Workspace until we are sure we have all the kinks worked out. After that we can set it to whatever everyone wants.

@AethanFoot
Copy link
Member Author

Ye so the config option is:

# config.toml
layout_mode = "Tag"

Which should allow you to a different layout and/or rotation per tag.

@VuiMuich
Copy link
Member

VuiMuich commented Oct 6, 2021

I am experiencing three regressions, all only appear in layout_mode = "Tag":

  • FocusWindowUp/Down behaves like MoveWindowUp/Down
  • leftwm state -w 0 -s "{{workspace.layout}}" does not update on layout change and always prints Monocle
  • layout state does not survive SoftReload (log: leftwm-worker[738246]: Cannot load old state: missing field layout at line 1 column 17062)

For the first two my guess is, that the repsective handlers and the state-file miss the change of layout.
No idea though, why it choses Monocle on reload. My config is layouts = ["MainAndDeck", "Monocle", "CenterMainBalanced", "LeftWiderRightStack"] and I tried if adding Fibonacci in the second position would change anything, but didn't.

@AethanFoot
Copy link
Member Author

@VuiMuich hopefully those are fixed now?

@VuiMuich
Copy link
Member

VuiMuich commented Oct 6, 2021

Jep looks good now, thanks!

@lex148
Copy link
Member

lex148 commented Oct 7, 2021

I am still experiencing layouts being applied by tags while in workspace mode.

Here are the steps I did for testing:

  1. rebuild everything on this branch
  2. deleted my config file. ./config/leftwm/config.toml
  3. pkill leftwm-worker
  4. verified the new config.toml file is in layout_mode=Workspace
  5. open a bunch of windows on both monitors.
  6. changed layout to all horizontal for wide screen monitor
  7. changed layout to all vertical for vertical monitor
  8. swapped the two tags

Result:
the wide screen monitor is now displaying windows using the vertical layout
the vertical monitor is now displaying windows using the horizontal layout

Expected:
I expected the layouts to remain the same on the two workspaces.

@AethanFoot
Copy link
Member Author

Ah, it appears Workspace needs to be quoted e.g. "Workspace". Can you check that pr fixes it, as I wasn't updating a tag moved to a visible workspace.

@lex148
Copy link
Member

lex148 commented Oct 8, 2021

Ah, it appears Workspace needs to be quoted e.g. "Workspace". Can you check that pr fixes it, as I wasn't updating a tag moved to a visible workspace.

Am afraid not. I am still seeing layouts follow the tags when in workspace mode

@AethanFoot
Copy link
Member Author

AethanFoot commented Oct 8, 2021

Oh wait, heres the logic of workspace mode:
Each workspace can display its own layout, where every tag moved to that workspace changes to the workspaces layout.
In tag mode:
Each tag can display its own layout, where when a tag moves to a workspace the workspace changes to the tags layout.

Ignore this didn't see you swapped tags.
Your initial events seem correct where monitor one and monitor two can have different layouts, but when switching tags to the monitors the tags change to the current layout of the monitor.

If I am missing something, sorry currently writing up #511.

@AethanFoot
Copy link
Member Author

Ok, I think this works now. Most definitely needs a cleanup, but it may easier to do this in a different pr as more may need to be refactored.

@hertg hertg mentioned this pull request Oct 10, 2021
@lex148
Copy link
Member

lex148 commented Oct 10, 2021

@AethanFoot excellent work!

@lex148 lex148 merged commit da1f900 into leftwm:master Oct 10, 2021
@AethanFoot
Copy link
Member Author

@lex148 Thanks and thanks for the modabilities 😄!

@AethanFoot AethanFoot deleted the layout_per_tag branch November 25, 2021 12:56
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.

[Question] Is there any way to manage layout on per tag basis? Remember layout by tag
4 participants