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