Added a functions for getting all tags on a screen
Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
1e418cbe3b
commit
2ada67b730
|
@ -260,7 +260,7 @@ function mouse.client.dragtotag.border(c)
|
|||
capi.mouse.coords({ x = wa.x + 1 })
|
||||
end
|
||||
if not button_down then
|
||||
local tags = capi.screen[c.screen]:tags()
|
||||
local tags = tag.gettags(c.screen)
|
||||
local t = tag.selected()
|
||||
local idx
|
||||
for i, v in ipairs(tags) do
|
||||
|
|
|
@ -228,12 +228,19 @@ function tag.history.restore(screen, idx)
|
|||
if i ~= "previous" then table.remove(data.history[s], i) end
|
||||
end
|
||||
|
||||
--- Get a list of all tags on a screen
|
||||
-- @param s Screen number
|
||||
-- @return A table with all available tags
|
||||
function tag.gettags(s)
|
||||
return capi.screen[s]:tags()
|
||||
end
|
||||
|
||||
--- Return a table with all visible tags
|
||||
-- @param s Screen number.
|
||||
-- @return A table with all selected tags.
|
||||
function tag.selectedlist(s)
|
||||
local screen = s or capi.mouse.screen
|
||||
local tags = capi.screen[screen]:tags()
|
||||
local tags = tag.gettags(screen)
|
||||
local vtags = {}
|
||||
for i, t in pairs(tags) do
|
||||
if t.selected then
|
||||
|
@ -335,7 +342,7 @@ end
|
|||
--- View no tag.
|
||||
-- @param Optional screen number.
|
||||
function tag.viewnone(screen)
|
||||
local tags = capi.screen[screen or capi.mouse.screen]:tags()
|
||||
local tags = tag.gettags(screen or capi.mouse.screen)
|
||||
for i, t in pairs(tags) do
|
||||
t.selected = false
|
||||
end
|
||||
|
@ -346,7 +353,7 @@ end
|
|||
-- @param screen Optional screen number.
|
||||
function tag.viewidx(i, screen)
|
||||
local screen = screen or capi.mouse.screen
|
||||
local tags = capi.screen[screen]:tags()
|
||||
local tags = tag.gettags(screen)
|
||||
local showntags = {}
|
||||
for k, t in ipairs(tags) do
|
||||
if not tag.getproperty(t, "hide") then
|
||||
|
@ -363,14 +370,14 @@ function tag.viewidx(i, screen)
|
|||
capi.screen[screen]:emit_signal("tag::history::update")
|
||||
end
|
||||
|
||||
--- Get a tag's index in the screen[]:tags() table.
|
||||
--- Get a tag's index in the gettags() table.
|
||||
-- @param query_tag The tag object to find. [selected()]
|
||||
-- @return The index of the tag, nil if the tag is not found.
|
||||
function tag.getidx(query_tag)
|
||||
local query_tag = query_tag or tag.selected()
|
||||
if query_tag == nil then return end
|
||||
|
||||
for i, t in ipairs(capi.screen[query_tag.screen]:tags()) do
|
||||
for i, t in ipairs(tag.gettags(query_tag.screen)) do
|
||||
if t == query_tag then
|
||||
return i
|
||||
end
|
||||
|
@ -392,7 +399,7 @@ end
|
|||
--- View only a tag.
|
||||
-- @param t The tag object.
|
||||
function tag.viewonly(t)
|
||||
local tags = capi.screen[t.screen]:tags()
|
||||
local tags = tag.gettags(tag.getscreen(t))
|
||||
-- First, untag everyone except the viewed tag.
|
||||
for _, _tag in pairs(tags) do
|
||||
if _tag ~= t then
|
||||
|
@ -403,14 +410,14 @@ function tag.viewonly(t)
|
|||
-- We need to do that in 2 operations so we avoid flickering and several tag
|
||||
-- selected at the same time.
|
||||
t.selected = true
|
||||
capi.screen[t.screen]:emit_signal("tag::history::update")
|
||||
capi.screen[tag.getscreen(t)]:emit_signal("tag::history::update")
|
||||
end
|
||||
|
||||
--- View only a set of tags.
|
||||
-- @param tags A table with tags to view only.
|
||||
-- @param screen Optional screen number of the tags.
|
||||
function tag.viewmore(tags, screen)
|
||||
local screen_tags = capi.screen[screen or capi.mouse.screen]:tags()
|
||||
local screen_tags = tag.gettags(screen or capi.mouse.screen)
|
||||
for _, _tag in ipairs(screen_tags) do
|
||||
if not util.table.hasitem(tags, _tag) then
|
||||
_tag.selected = false
|
||||
|
@ -426,7 +433,7 @@ end
|
|||
-- @param tag Tag to be toggled
|
||||
function tag.viewtoggle(t)
|
||||
t.selected = not t.selected
|
||||
capi.screen[t.screen]:emit_signal("tag::history::update")
|
||||
capi.screen[tag.getscreen(t)]:emit_signal("tag::history::update")
|
||||
end
|
||||
|
||||
--- Get tag data table.
|
||||
|
@ -478,7 +485,7 @@ local function attached_connect_signal_screen(screen, sig, func)
|
|||
capi.screen[screen]:connect_signal("tag::detach", function (s, _tag)
|
||||
_tag:disconnect_signal(sig, func)
|
||||
end)
|
||||
for _, _tag in ipairs(capi.screen[screen]:tags()) do
|
||||
for _, _tag in ipairs(tag.gettags(screen)) do
|
||||
_tag:connect_signal(sig, func)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -102,7 +102,7 @@ end
|
|||
|
||||
local function taglist_update(s, w, buttons, filter, data, style)
|
||||
local tags = {}
|
||||
for k, t in ipairs(capi.screen[s]:tags()) do
|
||||
for k, t in ipairs(tag.gettags(s)) do
|
||||
if not tag.getproperty(t, "hide") and filter(t) then
|
||||
table.insert(tags, t)
|
||||
end
|
||||
|
|
|
@ -167,7 +167,7 @@ function tasklist.filter.currenttags(c, screen)
|
|||
if c.screen ~= screen then return false end
|
||||
-- Include sticky client too
|
||||
if c.sticky then return true end
|
||||
local tags = capi.screen[screen]:tags()
|
||||
local tags = tag.gettags(screen)
|
||||
for k, t in ipairs(tags) do
|
||||
if t.selected then
|
||||
local ctags = c:tags()
|
||||
|
@ -192,7 +192,7 @@ function tasklist.filter.minimizedcurrenttags(c, screen)
|
|||
if c.sticky then return true end
|
||||
-- Check client is minimized
|
||||
if not c.minimized then return false end
|
||||
local tags = capi.screen[screen]:tags()
|
||||
local tags = tag.gettags(screen)
|
||||
for k, t in ipairs(tags) do
|
||||
-- Select only minimized clients
|
||||
if t.selected then
|
||||
|
|
Loading…
Reference in New Issue