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

Switching to a specific layout interferes with cycling over layouts #3412

Open
qsmodo opened this issue Aug 16, 2021 · 2 comments
Open

Switching to a specific layout interferes with cycling over layouts #3412

qsmodo opened this issue Aug 16, 2021 · 2 comments

Comments

@qsmodo
Copy link

qsmodo commented Aug 16, 2021

awesome v4.3 (Too long)
 • Compiled against Lua 5.1.5 (running with Lua 5.1)
 • D-Bus support: ✘
 • execinfo support: ✔
 • xcb-randr version: 1.6
 • LGI version: 0.9.2

How to reproduce the issue:

Modify lua.rc to only cycle over a subset of the available layouts with Mod+Space. Then assign a keybinding to a layout that is not in that subset. Example:

awful.layout.layouts = {
    awful.layout.suit.tile,
    awful.layout.suit.max,
}

-- Keys section
    awful.key({ modkey, }, "space", function () awful.layout.inc( 1) end,
              {description = "select next", group = "layout"}),
    awful.key({ modkey, }, "s", function () awful.layout.set(awful.layout.suit.tile.bottom) end,
              {description = "select previous", group = "layout"}),

Actual result:

Once you switch to the outsider layout with Mod+S, Mod+Space cycles over that layout too. If, on the other hand, you use awful.layout.inc( 1, nil, awful.layout.layouts) for Mod+Space, once you switch to the outsider layout with Mod+S, Mod+Space no longer cycles over any layout.

Expected result:

Mod+Space cycles over only layouts in awful.layout.layouts, always.

@Aire-One
Copy link
Member

When setting the tag layout to a layout that is not in the tag's layouts table, the new layout is pushed to this tag layouts table.

local newindex = gmath.cycle(#layouts, cur_idx + i)
layout.set(layouts[newindex], t)

So at the next call of layout.inc, the t.layout table contains the newly added layout, and the function will eventually iterate over it:

layouts = layouts or t.layouts or {}

This is an old behavior (> 3 years), so I wouldn't consider that as a bug, and I don't think any change should be applied. Maybe we can add a note about that in the documentation, tho?

So, I'm sorry to tell you that, but from my point of view, we shouldn't change any behavior. Instead, you have to adapt your code with the solution you proposed awful.layout.inc( 1, nil, awful.layout.layouts).

@actionless
Copy link
Member

  1. get current layout index: file:///usr/share/doc/awesome/doc/libraries/awful.layout.html#awful.layout.get_tag_layout_index
  2. find index of desired layout: file:///usr/share/doc/awesome/doc/libraries/awful.layout.html#awful.layout.layouts
  3. apply the difference between these two values: file:///usr/share/doc/awesome/doc/libraries/awful.layout.html#awful.layout.inc

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

No branches or pull requests

3 participants