Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Modified getpos to work with multiple screens #14

Merged
merged 3 commits into from

3 participants

@gdott9

The getpos() function doesn't work very well with multiple screens.
It doesn't return correct tags when using it on other screens than the first.

Here is a corrected version of this function.

In the third commit, I changed the default behaviour to add a tag to every screen if the screen attribute is not defined for the tag.

@masterkorp masterkorp was assigned
@bioe007 bioe007 merged commit 62ea299 into bioe007:master
@bioe007
Owner

d'oh. Sorry, this got buried in my 'TODO' list.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 44 additions and 29 deletions.
  1. +44 −29 init.lua
View
73 init.lua
@@ -820,41 +820,53 @@ function getpos(pos, scr_arg)
end
if #existing > 0 then
- -- if making another of an existing tag, return the end of
- -- the list the optional 2nd argument decides if we return
- -- only
- if scr_arg ~= nil then
+ -- if there is no selected tag on current screen, look for the first one
+ if not selected then
for _, tag in pairs(existing) do
- if tag.screen == scr_arg then return tag end
+ if tag.screen == scr then return tag end
end
- -- no tag with a position and scr_arg match found, clear
- -- v and allow the subseqeunt conditions to be evaluated
- v = nil
- else
- v = (selected and
- existing[awful.util.cycle(#existing, selected + 1)]) or
- existing[1]
+
+ -- no tag found, loop through the other tags
+ selected = #existing
end
+ -- look for the next unselected tag
+ i = selected
+ repeat
+ i = awful.util.cycle(#existing, i + 1)
+ tag = existing[i]
+
+ if (scr_arg == nil or tag.screen == scr_arg) and not tag.selected then return tag end
+ until i == selected
+
+ -- if the screen is not specified or
+ -- if a selected tag exists on the specified screen
+ -- return the selected tag
+ if scr_arg == nil or existing[selected].screen == scr then return existing[selected] end
+
+ -- if scr_arg ~= nil and no tag exists on this screen, continue
end
- if not v then
- -- search for preconf with 'pos' and create it
- for i, j in pairs(config.tags) do
- if j.position == pos then
- v = add({name = i,
- position = pos,
- noswitch = not switch})
- end
+
+ local screens = {}
+ for s = 1, capi.screen.count() do table.insert(screens, s) end
+
+ -- search for preconf with 'pos' on current screen and create it
+ for i, j in pairs(config.tags) do
+ local tag_scr = j.screen or screens
+ if type(tag_scr) ~= 'table' then tag_scr = {tag_scr} end
+
+ if j.position == pos and awful.util.table.hasitem(tag_scr, scr) then
+ return add({name = i,
+ position = pos,
+ noswitch = not switch})
end
end
- if not v then
- -- not existing, not preconfigured
- v = add({position = pos,
- rename = pos .. ':',
- no_selectall = true,
- noswitch = not switch})
- end
- return v
+
+ -- not existing, not preconfigured
+ return add({position = pos,
+ rename = pos .. ':',
+ no_selectall = true,
+ noswitch = not switch})
end
--init : search shifty.config.tags for initial set of
@@ -862,8 +874,11 @@ end
function init()
local numscr = capi.screen.count()
+ local screens = {}
+ for s = 1, capi.screen.count() do table.insert(screens, s) end
+
for i, j in pairs(config.tags) do
- local scr = j.screen or {1}
+ local scr = j.screen or screens
if type(scr) ~= 'table' then
scr = {scr}
end
Something went wrong with that request. Please try again.