2008-09-29 16:49:18 +02:00
|
|
|
---------------------------------------------------------------------------
|
2014-05-20 13:02:39 +02:00
|
|
|
--- Useful functions for tag manipulation.
|
|
|
|
--
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @author Julien Danjou <julien@danjou.info>
|
|
|
|
-- @copyright 2008 Julien Danjou
|
|
|
|
-- @release @AWESOME_VERSION@
|
2014-05-20 13:02:39 +02:00
|
|
|
-- @module awful.tag
|
2008-09-29 16:49:18 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
|
|
|
local util = require("awful.util")
|
2015-01-31 16:40:46 +01:00
|
|
|
local ascreen = require("awful.screen")
|
2015-01-11 11:14:45 +01:00
|
|
|
local timer = require("gears.timer")
|
2015-07-02 23:24:04 +02:00
|
|
|
local beautiful = require("beautiful")
|
2010-06-01 11:42:52 +02:00
|
|
|
local tostring = tostring
|
2008-09-29 16:49:18 +02:00
|
|
|
local pairs = pairs
|
|
|
|
local ipairs = ipairs
|
2009-05-30 18:11:07 +02:00
|
|
|
local table = table
|
2009-04-11 14:04:51 +02:00
|
|
|
local setmetatable = setmetatable
|
2008-09-29 16:49:18 +02:00
|
|
|
local capi =
|
|
|
|
{
|
2009-08-21 15:50:01 +02:00
|
|
|
tag = tag,
|
2008-09-29 16:49:18 +02:00
|
|
|
screen = screen,
|
2009-07-10 14:36:04 +02:00
|
|
|
mouse = mouse,
|
2012-10-20 17:33:32 +02:00
|
|
|
client = client,
|
|
|
|
root = root
|
2008-09-29 16:49:18 +02:00
|
|
|
}
|
|
|
|
|
2015-09-09 23:44:10 +02:00
|
|
|
-- we use require("awful.client") inside functions to prevent circular dependencies.
|
|
|
|
local client
|
|
|
|
|
2012-06-12 20:13:09 +02:00
|
|
|
local tag = { mt = {} }
|
2008-09-29 16:49:18 +02:00
|
|
|
|
|
|
|
-- Private data
|
|
|
|
local data = {}
|
|
|
|
data.history = {}
|
2009-04-11 14:04:51 +02:00
|
|
|
data.tags = setmetatable({}, { __mode = 'k' })
|
2008-09-29 16:49:18 +02:00
|
|
|
|
|
|
|
-- History functions
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.history = {}
|
|
|
|
tag.history.limit = 20
|
2008-09-29 16:49:18 +02:00
|
|
|
|
2010-05-29 01:39:17 +02:00
|
|
|
--- Move a tag to an absolute position in the screen[]:tags() table.
|
|
|
|
-- @param new_index Integer absolute position in the table to insert.
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param target_tag The tag that should be moved. If null, the currently
|
|
|
|
-- selected tag is used.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.move(new_index, target_tag)
|
|
|
|
local target_tag = target_tag or tag.selected()
|
2012-10-25 18:39:19 +02:00
|
|
|
local scr = tag.getscreen(target_tag)
|
2012-10-25 18:41:00 +02:00
|
|
|
local tmp_tags = tag.gettags(scr)
|
2010-05-29 01:39:17 +02:00
|
|
|
|
|
|
|
if (not new_index) or (new_index < 1) or (new_index > #tmp_tags) then
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2014-11-01 23:46:06 +01:00
|
|
|
local rm_index = nil
|
|
|
|
|
2010-05-29 01:39:17 +02:00
|
|
|
for i, t in ipairs(tmp_tags) do
|
|
|
|
if t == target_tag then
|
|
|
|
table.remove(tmp_tags, i)
|
2014-11-01 23:46:06 +01:00
|
|
|
rm_index = i
|
2010-05-29 01:39:17 +02:00
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
table.insert(tmp_tags, new_index, target_tag)
|
2012-10-25 18:41:00 +02:00
|
|
|
|
2014-11-01 23:46:06 +01:00
|
|
|
for i=new_index < rm_index and new_index or rm_index, #tmp_tags do
|
|
|
|
local tmp_tag = tmp_tags[i]
|
2012-10-25 18:41:00 +02:00
|
|
|
tag.setscreen(tmp_tag, scr)
|
2014-04-09 22:02:14 +02:00
|
|
|
tag.setproperty(tmp_tag, "index", i)
|
2012-10-25 18:41:00 +02:00
|
|
|
end
|
2010-05-29 01:39:17 +02:00
|
|
|
end
|
|
|
|
|
2014-10-13 21:19:14 +02:00
|
|
|
--- Swap 2 tags
|
|
|
|
-- @param tag1 The first tag
|
|
|
|
-- @param tag2 The second tag
|
2015-02-17 18:55:26 +01:00
|
|
|
function tag.swap(tag1, tag2)
|
|
|
|
local idx1, idx2 = tag.getidx(tag1), tag.getidx(tag2)
|
|
|
|
local src2, src1 = tag.getscreen(tag2), tag.getscreen(tag1)
|
|
|
|
tag.setscreen(tag2, src1)
|
|
|
|
tag.move(idx1, tag2)
|
|
|
|
tag.setscreen(tag1, scr2)
|
|
|
|
tag.move(idx2, tag1)
|
2014-10-13 21:19:14 +02:00
|
|
|
end
|
|
|
|
|
2010-05-28 09:29:23 +02:00
|
|
|
--- Add a tag.
|
|
|
|
-- @param name The tag name, a string
|
|
|
|
-- @param props The tags properties, a table
|
2010-09-08 10:18:21 +02:00
|
|
|
-- @return The created tag
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.add(name, props)
|
2010-05-28 09:29:23 +02:00
|
|
|
local properties = props or {}
|
2014-11-01 23:46:06 +01:00
|
|
|
|
|
|
|
-- Be sure to set the screen before the tag is activated to avoid function
|
|
|
|
-- connected to property::activated to be called without a valid tag.
|
|
|
|
-- set properies cannot be used as this has to be set before the first signal
|
|
|
|
-- is sent
|
2015-01-31 16:40:46 +01:00
|
|
|
properties.screen = properties.screen or ascreen.focused()
|
2010-05-28 09:29:23 +02:00
|
|
|
|
2014-11-01 23:46:06 +01:00
|
|
|
-- Index is also required
|
|
|
|
properties.index = (#tag.gettags(properties.screen))+1
|
|
|
|
|
|
|
|
local newtag = capi.tag{ name = name }
|
|
|
|
|
|
|
|
-- Start with a fresh property table to avoid collisions with unsupported data
|
|
|
|
data.tags[newtag] = {screen=properties.screen, index=properties.index}
|
|
|
|
|
|
|
|
newtag.activated = true
|
|
|
|
|
2010-05-28 09:29:23 +02:00
|
|
|
for k, v in pairs(properties) do
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.setproperty(newtag, k, v)
|
2010-05-28 09:29:23 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return newtag
|
|
|
|
end
|
|
|
|
|
2009-08-21 15:50:01 +02:00
|
|
|
--- Create a set of tags and attach it to a screen.
|
|
|
|
-- @param names The tag name, in a table
|
|
|
|
-- @param screen The tag screen, or 1 if not set.
|
2009-10-26 10:58:39 +01:00
|
|
|
-- @param layout The layout or layout table to set for this tags by default.
|
2009-08-21 15:50:01 +02:00
|
|
|
-- @return A table with all created tags.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.new(names, screen, layout)
|
2009-08-21 15:50:01 +02:00
|
|
|
local screen = screen or 1
|
|
|
|
local tags = {}
|
|
|
|
for id, name in ipairs(names) do
|
2012-06-12 20:13:09 +02:00
|
|
|
table.insert(tags, id, tag.add(name, {screen = screen,
|
2010-05-28 09:29:23 +02:00
|
|
|
layout = (layout and layout[id]) or
|
|
|
|
layout}))
|
2009-08-21 15:50:01 +02:00
|
|
|
-- Select the first tag.
|
|
|
|
if id == 1 then
|
2010-05-28 09:29:23 +02:00
|
|
|
tags[id].selected = true
|
2009-08-21 15:50:01 +02:00
|
|
|
end
|
|
|
|
end
|
2010-05-28 09:29:23 +02:00
|
|
|
|
2009-08-21 15:50:01 +02:00
|
|
|
return tags
|
|
|
|
end
|
|
|
|
|
2010-08-02 20:25:30 +02:00
|
|
|
--- Find a suitable fallback tag.
|
2015-01-31 16:40:46 +01:00
|
|
|
-- @param screen The screen number to look for a tag on. [awful.screen.focused()]
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param invalids A table of tags we consider unacceptable. [selectedlist(scr)]
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.find_fallback(screen, invalids)
|
2015-01-31 16:40:46 +01:00
|
|
|
local scr = screen or ascreen.focused()
|
2012-06-12 20:13:09 +02:00
|
|
|
local t = invalids or tag.selectedlist(scr)
|
2010-08-02 20:25:30 +02:00
|
|
|
|
2012-10-25 18:41:00 +02:00
|
|
|
for _, v in pairs(tag.gettags(scr)) do
|
2010-08-02 20:25:30 +02:00
|
|
|
if not util.table.hasitem(t, v) then return v end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Delete a tag.
|
|
|
|
-- @param target_tag Optional tag object to delete. [selected()]
|
|
|
|
-- @param fallback_tag Tag to assign stickied tags to. [~selected()]
|
|
|
|
-- @return Returns true if the tag is successfully deleted, nil otherwise.
|
|
|
|
-- If there are no clients exclusively on this tag then delete it. Any
|
|
|
|
-- stickied clients are assigned to the optional 'fallback_tag'.
|
|
|
|
-- If after deleting the tag there is no selected tag, try and restore from
|
|
|
|
-- history or select the first tag on the screen.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.delete(target_tag, fallback_tag)
|
2010-08-02 20:25:30 +02:00
|
|
|
-- abort if no tag is passed or currently selected
|
2012-06-12 20:13:09 +02:00
|
|
|
local target_tag = target_tag or tag.selected()
|
2014-11-01 23:46:06 +01:00
|
|
|
if target_tag == nil or target_tag.activated == false then return end
|
2010-08-02 20:25:30 +02:00
|
|
|
|
2012-10-25 18:39:19 +02:00
|
|
|
local target_scr = tag.getscreen(target_tag)
|
2014-11-01 23:46:06 +01:00
|
|
|
local tags = tag.gettags(target_scr)
|
|
|
|
local idx = tag.getidx(target_tag)
|
|
|
|
local ntags = #tags
|
2010-08-02 20:25:30 +02:00
|
|
|
|
|
|
|
-- We can't use the target tag as a fallback.
|
|
|
|
local fallback_tag = fallback_tag
|
|
|
|
if fallback_tag == target_tag then return end
|
|
|
|
|
|
|
|
-- No fallback_tag provided, try and get one.
|
|
|
|
if fallback_tag == nil then
|
2012-06-12 20:13:09 +02:00
|
|
|
fallback_tag = tag.find_fallback(target_scr, {target_tag})
|
2010-08-02 20:25:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Abort if we would have un-tagged clients.
|
|
|
|
local clients = target_tag:clients()
|
|
|
|
if ( #clients > 0 and ntags <= 1 ) or fallback_tag == nil then return end
|
|
|
|
|
|
|
|
-- Move the clients we can off of this tag.
|
|
|
|
for _, c in pairs(clients) do
|
2015-07-07 18:42:24 +02:00
|
|
|
local nb_tags = #c:tags()
|
2010-08-02 20:25:30 +02:00
|
|
|
|
|
|
|
-- If a client has only this tag, or stickied clients with
|
|
|
|
-- nowhere to go, abort.
|
2015-07-07 18:42:24 +02:00
|
|
|
if (not c.sticky and nb_tags == 1) or
|
2010-08-02 20:25:30 +02:00
|
|
|
(c.sticky and fallback_tag == nil) then
|
|
|
|
return
|
2014-10-14 03:36:11 +02:00
|
|
|
-- If a client has multiple tags, then do not move it to fallback
|
2015-07-07 18:42:24 +02:00
|
|
|
elseif nb_tags < 2 then
|
2010-08-02 20:25:30 +02:00
|
|
|
c:tags({fallback_tag})
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- delete the tag
|
2012-10-25 18:39:19 +02:00
|
|
|
data.tags[target_tag].screen = nil
|
2013-11-23 14:54:13 +01:00
|
|
|
target_tag.activated = false
|
2010-08-02 20:25:30 +02:00
|
|
|
|
2014-11-01 23:46:06 +01:00
|
|
|
-- Update all indexes
|
2015-02-17 18:55:26 +01:00
|
|
|
for i=idx+1, #tags do
|
2014-11-01 23:46:06 +01:00
|
|
|
tag.setproperty(tags[i], "index", i-1)
|
|
|
|
end
|
|
|
|
|
2010-08-02 20:25:30 +02:00
|
|
|
-- If no tags are visible, try and view one.
|
2012-06-12 20:13:09 +02:00
|
|
|
if tag.selected(target_scr) == nil and ntags > 0 then
|
2014-03-24 01:17:54 +01:00
|
|
|
tag.history.restore(nil, 1)
|
2012-06-12 20:13:09 +02:00
|
|
|
if tag.selected(target_scr) == nil then
|
2014-11-01 23:46:06 +01:00
|
|
|
tags[tags[1] == target_tag and 2 or 1].selected = true
|
2010-08-02 20:25:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Update the tag history.
|
2009-08-27 16:03:45 +02:00
|
|
|
-- @param obj Screen object.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.history.update(obj)
|
2009-08-27 16:03:45 +02:00
|
|
|
local s = obj.index
|
2012-06-12 20:13:09 +02:00
|
|
|
local curtags = tag.selectedlist(s)
|
2009-08-27 16:03:45 +02:00
|
|
|
-- create history table
|
|
|
|
if not data.history[s] then
|
|
|
|
data.history[s] = {}
|
2010-10-20 17:30:48 +02:00
|
|
|
else
|
|
|
|
if data.history[s].current then
|
|
|
|
-- Check that the list is not identical
|
2014-10-13 21:00:09 +02:00
|
|
|
local identical = #data.history[s].current == #curtags
|
|
|
|
if identical then
|
|
|
|
for idx, _tag in ipairs(data.history[s].current) do
|
|
|
|
if curtags[idx] ~= _tag then
|
|
|
|
identical = false
|
|
|
|
break
|
|
|
|
end
|
2010-10-20 17:30:48 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Do not update history the table are identical
|
|
|
|
if identical then return end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Limit history
|
2012-06-12 20:13:09 +02:00
|
|
|
if #data.history[s] >= tag.history.limit then
|
|
|
|
for i = tag.history.limit, #data.history[s] do
|
2010-10-20 17:30:48 +02:00
|
|
|
data.history[s][i] = nil
|
|
|
|
end
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
end
|
2010-10-20 17:30:48 +02:00
|
|
|
|
2009-08-27 16:03:45 +02:00
|
|
|
-- store previously selected tags in the history table
|
|
|
|
table.insert(data.history[s], 1, data.history[s].current)
|
|
|
|
data.history[s].previous = data.history[s][1]
|
|
|
|
-- store currently selected tags
|
2010-10-20 17:30:48 +02:00
|
|
|
data.history[s].current = setmetatable(curtags, { __mode = 'v' })
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2009-04-29 14:58:41 +02:00
|
|
|
--- Revert tag history.
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @param screen The screen number.
|
2009-08-27 16:03:45 +02:00
|
|
|
-- @param idx Index in history. Defaults to "previous" which is a special index
|
|
|
|
-- toggling between last two selected sets of tags. Number (eg 1) will go back
|
|
|
|
-- to the given index in history.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.history.restore(screen, idx)
|
2015-01-31 16:40:46 +01:00
|
|
|
local s = screen or ascreen.focused()
|
2009-08-27 16:03:45 +02:00
|
|
|
local i = idx or "previous"
|
2012-06-12 20:13:09 +02:00
|
|
|
local sel = tag.selectedlist(s)
|
2009-08-27 16:03:45 +02:00
|
|
|
-- do nothing if history empty
|
|
|
|
if not data.history[s] or not data.history[s][i] then return end
|
|
|
|
-- if all tags been deleted, try next entry
|
|
|
|
if #data.history[s][i] == 0 then
|
|
|
|
if i == "previous" then i = 0 end
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.history.restore(s, i + 1)
|
2009-08-27 16:03:45 +02:00
|
|
|
return
|
|
|
|
end
|
|
|
|
-- deselect all tags
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.viewnone(s)
|
2009-08-27 16:03:45 +02:00
|
|
|
-- select tags from the history entry
|
|
|
|
for _, t in ipairs(data.history[s][i]) do
|
|
|
|
t.selected = true
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
2009-08-27 16:03:45 +02:00
|
|
|
-- update currently selected tags table
|
|
|
|
data.history[s].current = data.history[s][i]
|
|
|
|
-- store previously selected tags
|
|
|
|
data.history[s].previous = setmetatable(sel, { __mode = 'v' })
|
|
|
|
-- remove the reverted history entry
|
|
|
|
if i ~= "previous" then table.remove(data.history[s], i) end
|
2014-03-12 01:46:37 +01:00
|
|
|
|
|
|
|
capi.screen[s]:emit_signal("tag::history::update")
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2012-10-20 16:34:06 +02:00
|
|
|
--- Get a list of all tags on a screen
|
|
|
|
-- @param s Screen number
|
|
|
|
-- @return A table with all available tags
|
|
|
|
function tag.gettags(s)
|
2012-10-20 17:33:32 +02:00
|
|
|
local tags = {}
|
|
|
|
for i, t in ipairs(root.tags()) do
|
|
|
|
if tag.getscreen(t) == s then
|
|
|
|
table.insert(tags, t)
|
|
|
|
end
|
|
|
|
end
|
2013-01-02 15:06:45 +01:00
|
|
|
|
2014-11-01 23:46:06 +01:00
|
|
|
table.sort(tags, function(a, b)
|
2015-03-29 17:50:11 +02:00
|
|
|
return (tag.getproperty(a, "index") or 9999) < (tag.getproperty(b, "index") or 9999)
|
2014-11-01 23:46:06 +01:00
|
|
|
end)
|
2012-10-20 17:33:32 +02:00
|
|
|
return tags
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Set a tag's screen
|
|
|
|
-- @param t tag object
|
|
|
|
-- @param s Screen number
|
|
|
|
function tag.setscreen(t, s)
|
2015-01-31 16:40:46 +01:00
|
|
|
local s = s or ascreen.focused()
|
2014-11-01 23:46:06 +01:00
|
|
|
local sel = tag.selected
|
2014-04-09 22:04:32 +02:00
|
|
|
local old_screen = tag.getproperty(t, "screen")
|
|
|
|
if s == old_screen then return end
|
2014-03-26 22:59:33 +01:00
|
|
|
|
|
|
|
-- Keeping the old index make very little sense when changing screen
|
|
|
|
tag.setproperty(t, "index", nil)
|
|
|
|
|
|
|
|
-- Change the screen
|
2012-10-20 17:33:32 +02:00
|
|
|
tag.setproperty(t, "screen", s)
|
2014-03-26 22:59:33 +01:00
|
|
|
|
|
|
|
-- Make sure the client's screen matches its tags
|
|
|
|
for k,c in ipairs(t:clients()) do
|
|
|
|
c.screen = s --Move all clients
|
|
|
|
c:tags({t})
|
|
|
|
end
|
2014-11-01 23:46:06 +01:00
|
|
|
|
|
|
|
-- Update all indexes
|
2015-02-17 18:55:26 +01:00
|
|
|
for _,screen in ipairs {old_screen, s} do
|
2014-11-01 23:46:06 +01:00
|
|
|
for i,t in ipairs(tag.gettags(screen)) do
|
|
|
|
tag.setproperty(t, "index", i)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Restore the old screen history if the tag was selected
|
|
|
|
if sel then
|
2015-02-17 18:55:26 +01:00
|
|
|
tag.history.restore(old_screen, 1)
|
2014-11-01 23:46:06 +01:00
|
|
|
end
|
2012-10-20 17:33:32 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get a tag's screen
|
2015-09-09 23:44:10 +02:00
|
|
|
-- @param[opt] t tag object
|
2012-10-20 17:33:32 +02:00
|
|
|
-- @return Screen number
|
|
|
|
function tag.getscreen(t)
|
2015-09-09 23:44:10 +02:00
|
|
|
local t = t or tag.selected()
|
2012-10-20 17:33:32 +02:00
|
|
|
return tag.getproperty(t, "screen")
|
2012-10-20 16:34:06 +02:00
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Return a table with all visible tags
|
|
|
|
-- @param s Screen number.
|
|
|
|
-- @return A table with all selected tags.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.selectedlist(s)
|
2015-01-31 16:40:46 +01:00
|
|
|
local screen = s or ascreen.focused()
|
2012-10-20 16:34:06 +02:00
|
|
|
local tags = tag.gettags(screen)
|
2008-09-29 16:49:18 +02:00
|
|
|
local vtags = {}
|
|
|
|
for i, t in pairs(tags) do
|
|
|
|
if t.selected then
|
|
|
|
vtags[#vtags + 1] = t
|
|
|
|
end
|
|
|
|
end
|
|
|
|
return vtags
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Return only the first visible tag.
|
|
|
|
-- @param s Screen number.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.selected(s)
|
|
|
|
return tag.selectedlist(s)[1]
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Set master width factor.
|
|
|
|
-- @param mwfact Master width factor.
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param t The tag to modify, if null tag.selected() is used.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.setmwfact(mwfact, t)
|
|
|
|
local t = t or tag.selected()
|
2009-01-26 10:37:52 +01:00
|
|
|
if mwfact >= 0 and mwfact <= 1 then
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.setproperty(t, "mwfact", mwfact)
|
2009-01-26 10:37:52 +01:00
|
|
|
end
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase master width factor.
|
|
|
|
-- @param add Value to add to master width factor.
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param t The tag to modify, if null tag.selected() is used.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.incmwfact(add, t)
|
|
|
|
tag.setmwfact(tag.getmwfact(t) + add, t)
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get master width factor.
|
2015-02-26 22:06:34 +01:00
|
|
|
-- @param[opt] t The tag.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.getmwfact(t)
|
|
|
|
local t = t or tag.selected()
|
|
|
|
return tag.getproperty(t, "mwfact") or 0.5
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2015-02-22 20:29:18 +01:00
|
|
|
--- Set the spacing between clients
|
|
|
|
-- @param useless_gap The spacing between clients
|
|
|
|
-- @param t The tag to modify, if null tag.selected() is used.
|
|
|
|
function tag.setgap(useless_gap, t)
|
|
|
|
local t = t or tag.selected()
|
|
|
|
if useless_gap >= 0 then
|
|
|
|
tag.setproperty(t, "useless_gap", useless_gap)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase the spacing between clients
|
|
|
|
-- @param add Value to add to the spacing between clients
|
|
|
|
-- @param t The tag to modify, if null tag.selected() is used.
|
|
|
|
function tag.incgap(add, t)
|
|
|
|
tag.setgap(tag.getgap(t) + add, t)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the spacing between clients
|
|
|
|
-- @param t Optional tag.
|
|
|
|
function tag.getgap(t)
|
|
|
|
local t = t or tag.selected()
|
2015-07-02 23:24:04 +02:00
|
|
|
return tag.getproperty(t, "useless_gap") or beautiful.useless_gap or 0
|
2015-02-22 20:29:18 +01:00
|
|
|
end
|
|
|
|
|
2015-07-16 11:48:18 +02:00
|
|
|
--- Set size fill policy for the master client(s)
|
2015-07-15 15:24:08 +02:00
|
|
|
-- @tparam string policy Can be set to
|
|
|
|
-- "expand" (fill all the available workarea) or
|
|
|
|
-- "mwfact" (fill only an area inside the master width factor)
|
2015-07-30 09:21:59 +02:00
|
|
|
-- @tparam[opt=tag.selected()] tag t The tag to modify
|
|
|
|
function tag.setmfpol(policy, t)
|
2015-07-15 15:24:08 +02:00
|
|
|
local t = t or tag.selected()
|
2015-07-30 09:21:59 +02:00
|
|
|
tag.setproperty(t, "master_fill_policy", policy)
|
2015-07-15 15:24:08 +02:00
|
|
|
end
|
|
|
|
|
2015-07-16 11:48:18 +02:00
|
|
|
--- Toggle size fill policy for the master client(s)
|
2015-07-30 09:21:59 +02:00
|
|
|
-- between "expand" and "mwfact"
|
2015-07-15 15:24:08 +02:00
|
|
|
-- @tparam tag t The tag to modify, if null tag.selected() is used.
|
|
|
|
function tag.togglemfpol(t)
|
|
|
|
if tag.getmfpol(t) == "expand" then
|
|
|
|
tag.setmfpol("mwfact", t)
|
|
|
|
else
|
|
|
|
tag.setmfpol("expand", t)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-16 11:48:18 +02:00
|
|
|
--- Get size fill policy for the master client(s)
|
2015-07-30 09:21:59 +02:00
|
|
|
-- @tparam[opt=tag.selected()] tag t The tag
|
|
|
|
-- @treturn string Possible values are
|
|
|
|
-- "expand" (fill all the available workarea, default one) or
|
2015-07-15 15:24:08 +02:00
|
|
|
-- "mwfact" (fill only an area inside the master width factor)
|
|
|
|
function tag.getmfpol(t)
|
|
|
|
local t = t or tag.selected()
|
|
|
|
return tag.getproperty(t, "master_fill_policy") or "expand"
|
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Set the number of master windows.
|
|
|
|
-- @param nmaster The number of master windows.
|
2015-02-26 22:06:34 +01:00
|
|
|
-- @param[opt] t The tag.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.setnmaster(nmaster, t)
|
|
|
|
local t = t or tag.selected()
|
2009-01-26 10:37:52 +01:00
|
|
|
if nmaster >= 0 then
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.setproperty(t, "nmaster", nmaster)
|
2009-01-26 10:37:52 +01:00
|
|
|
end
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the number of master windows.
|
2015-02-26 22:06:34 +01:00
|
|
|
-- @param[opt] t The tag.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.getnmaster(t)
|
|
|
|
local t = t or tag.selected()
|
|
|
|
return tag.getproperty(t, "nmaster") or 1
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase the number of master windows.
|
|
|
|
-- @param add Value to add to number of master windows.
|
2015-09-09 23:44:10 +02:00
|
|
|
-- @param[opt] t The tag to modify, if null tag.selected() is used.
|
|
|
|
-- @tparam[opt=false] boolean sensible Limit nmaster based on the number of
|
|
|
|
-- visible tiled windows?
|
|
|
|
function tag.incnmaster(add, t, sensible)
|
|
|
|
if sensible then
|
|
|
|
client = client or require("awful.client")
|
|
|
|
local ntiled = #client.tiled(tag.getscreen(t))
|
|
|
|
|
|
|
|
local nmaster = tag.getnmaster(t)
|
|
|
|
if nmaster > ntiled then
|
|
|
|
nmaster = ntiled
|
|
|
|
end
|
|
|
|
|
|
|
|
local newnmaster = nmaster + add
|
|
|
|
if newnmaster > ntiled then
|
|
|
|
newnmaster = ntiled
|
|
|
|
end
|
|
|
|
tag.setnmaster(newnmaster, t)
|
|
|
|
else
|
|
|
|
tag.setnmaster(tag.getnmaster(t) + add, t)
|
|
|
|
end
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2009-01-13 16:04:11 +01:00
|
|
|
|
|
|
|
--- Set the tag icon
|
|
|
|
-- @param icon the icon to set, either path or image object
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param _tag the tag
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.seticon(icon, _tag)
|
|
|
|
local _tag = _tag or tag.selected()
|
|
|
|
tag.setproperty(_tag, "icon", icon)
|
2009-01-13 16:04:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the tag icon
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param _tag the tag
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.geticon(_tag)
|
|
|
|
local _tag = _tag or tag.selected()
|
|
|
|
return tag.getproperty(_tag, "icon")
|
2009-01-13 16:04:11 +01:00
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Set number of column windows.
|
|
|
|
-- @param ncol The number of column.
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param t The tag to modify, if null tag.selected() is used.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.setncol(ncol, t)
|
|
|
|
local t = t or tag.selected()
|
2009-01-26 10:37:52 +01:00
|
|
|
if ncol >= 1 then
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.setproperty(t, "ncol", ncol)
|
2009-01-26 10:37:52 +01:00
|
|
|
end
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get number of column windows.
|
2015-02-26 22:06:34 +01:00
|
|
|
-- @param[opt] t The tag.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.getncol(t)
|
|
|
|
local t = t or tag.selected()
|
|
|
|
return tag.getproperty(t, "ncol") or 1
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase number of column windows.
|
|
|
|
-- @param add Value to add to number of column windows.
|
2015-09-09 23:44:10 +02:00
|
|
|
-- @param[opt] t The tag to modify, if null tag.selected() is used.
|
|
|
|
-- @tparam[opt=false] boolean sensible Limit ncol based on the number of visible
|
|
|
|
-- tiled windows?
|
|
|
|
function tag.incncol(add, t, sensible)
|
|
|
|
if sensible then
|
|
|
|
client = client or require("awful.client")
|
|
|
|
local ntiled = #client.tiled(tag.getscreen(t))
|
|
|
|
local nmaster = tag.getnmaster(t)
|
|
|
|
local nsecondary = ntiled - nmaster
|
|
|
|
|
|
|
|
local ncol = tag.getncol(t)
|
|
|
|
if ncol > nsecondary then
|
|
|
|
ncol = nsecondary
|
|
|
|
end
|
|
|
|
|
|
|
|
local newncol = ncol + add
|
|
|
|
if newncol > nsecondary then
|
|
|
|
newncol = nsecondary
|
|
|
|
end
|
|
|
|
tag.setncol(newncol, t)
|
|
|
|
else
|
|
|
|
tag.setncol(tag.getncol(t) + add, t)
|
|
|
|
end
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- View no tag.
|
2015-02-26 22:06:34 +01:00
|
|
|
-- @tparam[opt] int screen The screen number.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewnone(screen)
|
2015-01-31 16:40:46 +01:00
|
|
|
local tags = tag.gettags(screen or ascreen.focused())
|
2008-09-29 16:49:18 +02:00
|
|
|
for i, t in pairs(tags) do
|
|
|
|
t.selected = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-05-30 18:11:07 +02:00
|
|
|
--- View a tag by its taglist index.
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @param i The relative index to see.
|
2015-02-26 22:06:34 +01:00
|
|
|
-- @param[opt] screen The screen number.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewidx(i, screen)
|
2015-01-31 16:40:46 +01:00
|
|
|
local screen = screen or ascreen.focused()
|
2012-10-20 16:34:06 +02:00
|
|
|
local tags = tag.gettags(screen)
|
2009-05-30 18:11:07 +02:00
|
|
|
local showntags = {}
|
|
|
|
for k, t in ipairs(tags) do
|
2012-06-12 20:13:09 +02:00
|
|
|
if not tag.getproperty(t, "hide") then
|
2009-05-30 18:11:07 +02:00
|
|
|
table.insert(showntags, t)
|
|
|
|
end
|
|
|
|
end
|
2012-06-12 20:13:09 +02:00
|
|
|
local sel = tag.selected(screen)
|
|
|
|
tag.viewnone(screen)
|
2009-05-30 18:11:07 +02:00
|
|
|
for k, t in ipairs(showntags) do
|
2008-09-29 16:49:18 +02:00
|
|
|
if t == sel then
|
2009-05-30 18:11:07 +02:00
|
|
|
showntags[util.cycle(#showntags, k + i)].selected = true
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
end
|
2009-08-27 16:03:45 +02:00
|
|
|
capi.screen[screen]:emit_signal("tag::history::update")
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2012-10-20 16:34:06 +02:00
|
|
|
--- Get a tag's index in the gettags() table.
|
2010-05-29 01:39:18 +02:00
|
|
|
-- @param query_tag The tag object to find. [selected()]
|
|
|
|
-- @return The index of the tag, nil if the tag is not found.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.getidx(query_tag)
|
|
|
|
local query_tag = query_tag or tag.selected()
|
2010-05-29 01:39:18 +02:00
|
|
|
if query_tag == nil then return end
|
|
|
|
|
2012-10-25 18:39:19 +02:00
|
|
|
for i, t in ipairs(tag.gettags(tag.getscreen(query_tag))) do
|
2010-05-29 01:39:18 +02:00
|
|
|
if t == query_tag then
|
|
|
|
return i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- View next tag. This is the same as tag.viewidx(1).
|
2009-08-24 08:31:44 +02:00
|
|
|
-- @param screen The screen number.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewnext(screen)
|
|
|
|
return tag.viewidx(1, screen)
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- View previous tag. This is the same a tag.viewidx(-1).
|
2009-08-24 08:31:44 +02:00
|
|
|
-- @param screen The screen number.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewprev(screen)
|
|
|
|
return tag.viewidx(-1, screen)
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- View only a tag.
|
|
|
|
-- @param t The tag object.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewonly(t)
|
2012-10-20 16:34:06 +02:00
|
|
|
local tags = tag.gettags(tag.getscreen(t))
|
2009-09-28 11:24:39 +02:00
|
|
|
-- First, untag everyone except the viewed tag.
|
2012-06-12 20:13:09 +02:00
|
|
|
for _, _tag in pairs(tags) do
|
|
|
|
if _tag ~= t then
|
|
|
|
_tag.selected = false
|
2009-09-28 11:24:39 +02:00
|
|
|
end
|
2009-09-22 14:09:56 +02:00
|
|
|
end
|
2009-09-28 11:24:39 +02:00
|
|
|
-- Then, set this one to selected.
|
|
|
|
-- We need to do that in 2 operations so we avoid flickering and several tag
|
|
|
|
-- selected at the same time.
|
|
|
|
t.selected = true
|
2012-10-20 16:34:06 +02:00
|
|
|
capi.screen[tag.getscreen(t)]:emit_signal("tag::history::update")
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- View only a set of tags.
|
|
|
|
-- @param tags A table with tags to view only.
|
2015-02-26 22:06:34 +01:00
|
|
|
-- @param[opt] screen The screen number of the tags.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewmore(tags, screen)
|
2015-01-31 16:40:46 +01:00
|
|
|
local screen = screen or ascreen.focused()
|
2013-12-30 11:33:09 +01:00
|
|
|
local screen_tags = tag.gettags(screen)
|
2012-06-12 20:13:09 +02:00
|
|
|
for _, _tag in ipairs(screen_tags) do
|
|
|
|
if not util.table.hasitem(tags, _tag) then
|
|
|
|
_tag.selected = false
|
2009-09-28 11:24:39 +02:00
|
|
|
end
|
|
|
|
end
|
2012-06-12 20:13:09 +02:00
|
|
|
for _, _tag in ipairs(tags) do
|
|
|
|
_tag.selected = true
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
2009-08-27 16:03:45 +02:00
|
|
|
capi.screen[screen]:emit_signal("tag::history::update")
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2009-08-27 17:16:56 +02:00
|
|
|
--- Toggle selection of a tag
|
2014-05-19 13:28:57 +02:00
|
|
|
-- @tparam tag t Tag to be toggled
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewtoggle(t)
|
2009-08-27 17:16:56 +02:00
|
|
|
t.selected = not t.selected
|
2012-10-20 16:34:06 +02:00
|
|
|
capi.screen[tag.getscreen(t)]:emit_signal("tag::history::update")
|
2009-08-27 17:16:56 +02:00
|
|
|
end
|
|
|
|
|
2009-02-24 21:50:46 +01:00
|
|
|
--- Get tag data table.
|
2014-05-19 13:28:57 +02:00
|
|
|
-- @tparam tag _tag The tag.
|
2009-02-24 21:50:46 +01:00
|
|
|
-- @return The data table.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.getdata(_tag)
|
|
|
|
return data.tags[_tag]
|
2009-02-24 21:50:46 +01:00
|
|
|
end
|
|
|
|
|
2008-11-25 17:01:06 +01:00
|
|
|
--- Get a tag property.
|
2014-05-20 13:02:39 +02:00
|
|
|
-- @tparam tag _tag The tag.
|
2014-05-19 13:28:57 +02:00
|
|
|
-- @tparam string prop The property name.
|
2008-11-25 17:01:06 +01:00
|
|
|
-- @return The property.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.getproperty(_tag, prop)
|
|
|
|
if data.tags[_tag] then
|
|
|
|
return data.tags[_tag][prop]
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Set a tag property.
|
|
|
|
-- This properties are internal to awful. Some are used to draw taglist, or to
|
|
|
|
-- handle layout, etc.
|
2012-11-19 14:09:10 +01:00
|
|
|
-- @param _tag The tag.
|
2008-11-25 17:01:06 +01:00
|
|
|
-- @param prop The property name.
|
|
|
|
-- @param value The value.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.setproperty(_tag, prop, value)
|
|
|
|
if not data.tags[_tag] then
|
|
|
|
data.tags[_tag] = {}
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
2015-07-07 13:01:53 +02:00
|
|
|
if data.tags[_tag][prop] ~= value then
|
|
|
|
data.tags[_tag][prop] = value
|
|
|
|
_tag:emit_signal("property::" .. prop)
|
|
|
|
end
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
2009-02-03 12:20:17 +01:00
|
|
|
--- Tag a client with the set of current tags.
|
|
|
|
-- @param c The client to tag.
|
2013-10-08 10:45:22 +02:00
|
|
|
function tag.withcurrent(c)
|
|
|
|
local tags = {}
|
|
|
|
for k, t in ipairs(c:tags()) do
|
|
|
|
if tag.getscreen(t) == c.screen then
|
|
|
|
table.insert(tags, t)
|
2009-02-03 12:20:17 +01:00
|
|
|
end
|
|
|
|
end
|
2013-10-08 10:45:22 +02:00
|
|
|
if #tags == 0 then
|
|
|
|
tags = tag.selectedlist(c.screen)
|
|
|
|
end
|
2014-03-26 14:29:02 +01:00
|
|
|
if #tags == 0 then
|
|
|
|
tags = tag.gettags(c.screen)
|
|
|
|
end
|
|
|
|
if #tags ~= 0 then
|
|
|
|
c:tags(tags)
|
|
|
|
end
|
2009-02-03 12:20:17 +01:00
|
|
|
end
|
|
|
|
|
2009-10-09 20:39:55 +02:00
|
|
|
local function attached_connect_signal_screen(screen, sig, func)
|
2012-10-20 17:35:09 +02:00
|
|
|
capi.tag.connect_signal(sig, function(_tag, ...)
|
|
|
|
if tag.getscreen(_tag) == screen then
|
|
|
|
func(_tag)
|
|
|
|
end
|
2009-08-18 16:44:03 +02:00
|
|
|
end)
|
|
|
|
end
|
|
|
|
|
2015-07-29 04:14:39 +02:00
|
|
|
--- Add a signal to all attached tags and all tags that will be attached in the
|
|
|
|
-- future. When a tag is detached from the screen, its signal is removed.
|
2009-08-18 16:44:03 +02:00
|
|
|
-- @param screen The screen concerned, or all if nil.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.attached_connect_signal(screen, ...)
|
2009-08-18 16:44:03 +02:00
|
|
|
if screen then
|
2009-10-09 20:39:55 +02:00
|
|
|
attached_connect_signal_screen(screen, ...)
|
2009-08-18 16:44:03 +02:00
|
|
|
else
|
2012-10-20 17:35:09 +02:00
|
|
|
capi.tag.connect_signal(...)
|
2009-08-18 16:44:03 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2014-03-27 13:50:19 +01:00
|
|
|
-- Register standard signals.
|
|
|
|
capi.client.connect_signal("manage", function(c)
|
2009-09-22 16:09:44 +02:00
|
|
|
-- If we are not managing this application at startup,
|
|
|
|
-- move it to the screen where the mouse is.
|
|
|
|
-- We only do it for "normal" windows (i.e. no dock, etc).
|
2014-03-27 13:50:19 +01:00
|
|
|
if not awesome.startup and c.type ~= "desktop" and c.type ~= "dock" then
|
2009-09-22 11:57:40 +02:00
|
|
|
if c.transient_for then
|
|
|
|
c.screen = c.transient_for.screen
|
|
|
|
if not c.sticky then
|
|
|
|
c:tags(c.transient_for:tags())
|
|
|
|
end
|
|
|
|
else
|
2015-01-31 16:40:46 +01:00
|
|
|
c.screen = ascreen.focused()
|
2009-09-22 11:57:40 +02:00
|
|
|
end
|
|
|
|
end
|
2014-03-24 22:05:21 +01:00
|
|
|
c:connect_signal("property::screen", tag.withcurrent)
|
2009-08-24 16:32:19 +02:00
|
|
|
end)
|
2008-09-29 16:49:18 +02:00
|
|
|
|
2015-02-14 23:22:01 +01:00
|
|
|
-- Keep track of the number of urgent clients.
|
2015-02-17 18:38:24 +01:00
|
|
|
local function update_urgent(c, t, modif)
|
|
|
|
local count = tag.getproperty(t, "urgent_count") or 0
|
2014-11-01 23:19:12 +01:00
|
|
|
count = (count + modif) >= 0 and (count + modif) or 0
|
2015-02-17 18:55:26 +01:00
|
|
|
tag.setproperty(t, "urgent" , count > 0)
|
|
|
|
tag.setproperty(t, "urgent_count", count )
|
2014-11-01 23:19:12 +01:00
|
|
|
end
|
|
|
|
|
2015-02-14 23:22:01 +01:00
|
|
|
-- Update the urgent counter when a client is tagged.
|
2015-02-17 18:55:26 +01:00
|
|
|
local function client_tagged(c, t)
|
2014-11-01 23:19:12 +01:00
|
|
|
if c.urgent then
|
2015-02-17 18:38:24 +01:00
|
|
|
update_urgent(c, t, 1)
|
2014-11-01 23:19:12 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-14 23:22:01 +01:00
|
|
|
-- Update the urgent counter when a client is untagged.
|
2015-02-17 18:55:26 +01:00
|
|
|
local function client_untagged(c, t)
|
2014-11-01 23:19:12 +01:00
|
|
|
if c.urgent then
|
2015-02-17 18:38:24 +01:00
|
|
|
update_urgent(c, t, -1)
|
2014-11-01 23:19:12 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-02-14 23:22:01 +01:00
|
|
|
-- Count the urgent clients.
|
2014-11-01 23:19:12 +01:00
|
|
|
local function urgent_callback(c)
|
|
|
|
for k,t in ipairs(c:tags()) do
|
2015-02-17 18:38:24 +01:00
|
|
|
update_urgent(c, t, c.urgent and 1 or -1)
|
2014-11-01 23:19:12 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
capi.client.connect_signal("property::urgent", urgent_callback)
|
2015-02-14 14:29:16 +01:00
|
|
|
capi.client.connect_signal("manage", tag.withcurrent)
|
2015-02-14 23:22:01 +01:00
|
|
|
capi.client.connect_signal("untagged", client_untagged)
|
|
|
|
capi.client.connect_signal("tagged", client_tagged)
|
2014-03-08 15:33:34 +01:00
|
|
|
capi.tag.connect_signal("request::select", tag.viewonly)
|
2010-01-08 16:16:37 +01:00
|
|
|
|
2010-08-25 23:00:36 +02:00
|
|
|
capi.tag.add_signal("property::hide")
|
2010-08-26 18:11:13 +02:00
|
|
|
capi.tag.add_signal("property::icon")
|
2015-03-17 16:23:40 +01:00
|
|
|
capi.tag.add_signal("property::icon_only")
|
2010-08-25 23:00:36 +02:00
|
|
|
capi.tag.add_signal("property::layout")
|
|
|
|
capi.tag.add_signal("property::mwfact")
|
2015-02-22 20:29:18 +01:00
|
|
|
capi.tag.add_signal("property::useless_gap")
|
2015-07-15 15:24:08 +02:00
|
|
|
capi.tag.add_signal("property::master_fill_policy")
|
2010-08-25 23:00:36 +02:00
|
|
|
capi.tag.add_signal("property::ncol")
|
|
|
|
capi.tag.add_signal("property::nmaster")
|
|
|
|
capi.tag.add_signal("property::windowfact")
|
2012-10-20 17:33:32 +02:00
|
|
|
capi.tag.add_signal("property::screen")
|
2013-01-02 15:06:45 +01:00
|
|
|
capi.tag.add_signal("property::index")
|
2014-11-01 23:19:12 +01:00
|
|
|
capi.tag.add_signal("property::urgent")
|
|
|
|
capi.tag.add_signal("property::urgent_count")
|
2010-08-25 23:00:36 +02:00
|
|
|
|
2014-03-30 16:37:19 +02:00
|
|
|
capi.screen.add_signal("tag::history::update")
|
2009-08-27 16:03:45 +02:00
|
|
|
for s = 1, capi.screen.count() do
|
2012-06-12 20:13:09 +02:00
|
|
|
capi.screen[s]:connect_signal("tag::history::update", tag.history.update)
|
2009-08-27 16:03:45 +02:00
|
|
|
end
|
|
|
|
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.mt:__call(...)
|
|
|
|
return tag.new(...)
|
|
|
|
end
|
|
|
|
|
|
|
|
return setmetatable(tag, tag.mt)
|
2009-08-21 15:50:01 +02:00
|
|
|
|
2011-09-11 16:50:01 +02:00
|
|
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|