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
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @module tag
|
2008-09-29 16:49:18 +02:00
|
|
|
---------------------------------------------------------------------------
|
|
|
|
|
|
|
|
-- Grab environment we need
|
2017-03-15 06:08:40 +01:00
|
|
|
local gdebug = require("gears.debug")
|
2015-01-31 16:40:46 +01:00
|
|
|
local ascreen = require("awful.screen")
|
2015-07-02 23:24:04 +02:00
|
|
|
local beautiful = require("beautiful")
|
2017-03-06 17:15:40 +01:00
|
|
|
local gmath = require("gears.math")
|
2016-03-13 08:43:50 +01:00
|
|
|
local object = require("gears.object")
|
2016-08-23 05:18:07 +02:00
|
|
|
local timer = require("gears.timer")
|
2017-03-08 21:18:33 +01:00
|
|
|
local gtable = require("gears.table")
|
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
|
|
|
}
|
|
|
|
|
2016-02-26 20:07:26 +01:00
|
|
|
local function get_screen(s)
|
|
|
|
return s and capi.screen[s]
|
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
local tag = {object = {}, mt = {} }
|
2008-09-29 16:49:18 +02:00
|
|
|
|
|
|
|
-- Private data
|
|
|
|
local data = {}
|
|
|
|
data.history = {}
|
|
|
|
|
|
|
|
-- History functions
|
2012-06-12 20:13:09 +02:00
|
|
|
tag.history = {}
|
|
|
|
tag.history.limit = 20
|
2008-09-29 16:49:18 +02:00
|
|
|
|
2016-08-30 18:25:05 +02:00
|
|
|
-- Default values
|
2016-09-14 23:11:00 +02:00
|
|
|
local defaults = {}
|
|
|
|
|
|
|
|
-- The gap between clients (in points).
|
|
|
|
defaults.gap = 0
|
|
|
|
|
|
|
|
-- The default gap_count.
|
|
|
|
defaults.gap_single_client = true
|
|
|
|
|
|
|
|
-- The default master fill policy.
|
|
|
|
defaults.master_fill_policy = "expand"
|
|
|
|
|
|
|
|
-- The default master width factor.
|
|
|
|
defaults.master_width_factor = 0.5
|
|
|
|
|
|
|
|
-- The default master count.
|
|
|
|
defaults.master_count = 1
|
|
|
|
|
|
|
|
-- The default column count.
|
|
|
|
defaults.column_count = 1
|
2016-08-30 18:25:05 +02:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
-- screen.tags depend on index, it cannot be used by awful.tag
|
|
|
|
local function raw_tags(scr)
|
|
|
|
local tmp_tags = {}
|
|
|
|
for _, t in ipairs(root.tags()) do
|
|
|
|
if get_screen(t.screen) == scr then
|
|
|
|
table.insert(tmp_tags, t)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return tmp_tags
|
|
|
|
end
|
|
|
|
|
|
|
|
--- The number of elements kept in the history.
|
|
|
|
-- @tfield integer awful.tag.history.limit
|
2016-08-30 18:25:05 +02:00
|
|
|
-- @tparam[opt=20] integer limit
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
--- The tag index.
|
|
|
|
--
|
|
|
|
-- The index is the position as shown in the `awful.widget.taglist`.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::index*
|
|
|
|
--
|
|
|
|
-- @property index
|
|
|
|
-- @param integer
|
|
|
|
-- @treturn number The tag index.
|
2010-05-29 01:39:17 +02:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
function tag.object.set_index(self, idx)
|
|
|
|
local scr = get_screen(tag.getproperty(self, "screen"))
|
|
|
|
|
|
|
|
-- screen.tags cannot be used as it depend on index
|
|
|
|
local tmp_tags = raw_tags(scr)
|
|
|
|
|
2016-08-22 06:40:21 +02:00
|
|
|
-- sort the tags by index
|
|
|
|
table.sort(tmp_tags, function(a, b)
|
|
|
|
local ia, ib = tag.getproperty(a, "index"), tag.getproperty(b, "index")
|
|
|
|
return (ia or math.huge) < (ib or math.huge)
|
|
|
|
end)
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
if (not idx) or (idx < 1) or (idx > #tmp_tags) then
|
2010-05-29 01:39:17 +02:00
|
|
|
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
|
2016-04-05 09:02:00 +02:00
|
|
|
if t == self then
|
2010-05-29 01:39:17 +02:00
|
|
|
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
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
table.insert(tmp_tags, idx, self)
|
|
|
|
for i = idx < rm_index and idx or rm_index, #tmp_tags do
|
2014-11-01 23:46:06 +01:00
|
|
|
local tmp_tag = tmp_tags[i]
|
2016-04-05 09:02:00 +02:00
|
|
|
tag.object.set_screen(tmp_tag, scr)
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(tmp_tag, "index", i)
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function tag.object.get_index(query_tag)
|
|
|
|
|
|
|
|
local idx = tag.getproperty(query_tag, "index")
|
|
|
|
|
|
|
|
if idx then return idx end
|
|
|
|
|
2016-08-22 06:40:21 +02:00
|
|
|
-- Get an unordered list of tags
|
|
|
|
local tags = raw_tags(query_tag.screen)
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
-- Too bad, lets compute it
|
|
|
|
for i, t in ipairs(tags) do
|
|
|
|
if t == query_tag then
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "index", i)
|
2016-04-05 09:02:00 +02:00
|
|
|
return i
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Move a tag to an absolute position in the screen[]:tags() table.
|
|
|
|
-- @deprecated awful.tag.move
|
|
|
|
-- @param new_index Integer absolute position in the table to insert.
|
|
|
|
-- @param target_tag The tag that should be moved. If null, the currently
|
|
|
|
-- selected tag is used.
|
|
|
|
-- @see index
|
|
|
|
function tag.move(new_index, target_tag)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.index = new_index instead of awful.tag.move", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
target_tag = target_tag or ascreen.focused().selected_tag
|
|
|
|
tag.object.set_index(target_tag, new_index)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Swap 2 tags
|
|
|
|
-- @function tag.swap
|
|
|
|
-- @param tag2 The second tag
|
|
|
|
-- @see client.swap
|
|
|
|
function tag.object.swap(self, tag2)
|
|
|
|
local idx1, idx2 = tag.object.get_index(self), tag.object.get_index(tag2)
|
|
|
|
local scr2, scr1 = tag.getproperty(tag2, "screen"), tag.getproperty(self, "screen")
|
|
|
|
|
|
|
|
-- If they are on the same screen, avoid recomputing the whole table
|
|
|
|
-- for nothing.
|
|
|
|
if scr1 == scr2 then
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(self, "index", idx2)
|
|
|
|
tag.setproperty(tag2, "index", idx1)
|
2016-04-05 09:02:00 +02:00
|
|
|
else
|
|
|
|
tag.object.set_screen(tag2, scr1)
|
|
|
|
tag.object.set_index (tag2, idx1)
|
|
|
|
tag.object.set_screen(self, scr2)
|
|
|
|
tag.object.set_index (self, idx2)
|
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
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.swap
|
|
|
|
-- @see tag.swap
|
2014-10-13 21:19:14 +02:00
|
|
|
-- @param tag1 The first tag
|
|
|
|
-- @param tag2 The second tag
|
2015-02-17 18:55:26 +01:00
|
|
|
function tag.swap(tag1, tag2)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t:swap(tag2) instead of awful.tag.swap", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
tag.object.swap(tag1, tag2)
|
2014-10-13 21:19:14 +02:00
|
|
|
end
|
|
|
|
|
2010-05-28 09:29:23 +02:00
|
|
|
--- Add a tag.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
|
|
|
-- This function allow to create tags from a set of properties:
|
|
|
|
--
|
|
|
|
-- local t = awful.tag.add("my new tag", {
|
|
|
|
-- screen = screen.primary,
|
|
|
|
-- layout = awful.layout.suit.max,
|
|
|
|
-- })
|
|
|
|
--
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.add
|
2010-05-28 09:29:23 +02:00
|
|
|
-- @param name The tag name, a string
|
2016-01-03 09:29:21 +01:00
|
|
|
-- @param props The tags inital properties, a table
|
2010-09-08 10:18:21 +02:00
|
|
|
-- @return The created tag
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see tag.delete
|
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.
|
2016-01-03 09:29:21 +01:00
|
|
|
-- set properties cannot be used as this has to be set before the first
|
|
|
|
-- signal is sent
|
2016-02-26 20:07:26 +01:00
|
|
|
properties.screen = get_screen(properties.screen or ascreen.focused())
|
2014-11-01 23:46:06 +01:00
|
|
|
-- Index is also required
|
2016-12-01 22:04:57 +01:00
|
|
|
properties.index = properties.index or #raw_tags(properties.screen)+1
|
2014-11-01 23:46:06 +01:00
|
|
|
|
|
|
|
local newtag = capi.tag{ name = name }
|
|
|
|
|
|
|
|
-- Start with a fresh property table to avoid collisions with unsupported data
|
2016-10-05 21:16:33 +02:00
|
|
|
newtag.data.awful_tag_properties = {screen=properties.screen, index=properties.index}
|
2014-11-01 23:46:06 +01:00
|
|
|
|
|
|
|
newtag.activated = true
|
|
|
|
|
2010-05-28 09:29:23 +02:00
|
|
|
for k, v in pairs(properties) do
|
2016-04-05 09:02:00 +02:00
|
|
|
-- `rawget` doesn't work on userdata, `:clients()` is the only relevant
|
|
|
|
-- entry.
|
|
|
|
if k == "clients" or tag.object[k] then
|
|
|
|
newtag[k](newtag, v)
|
|
|
|
else
|
|
|
|
newtag[k] = v
|
|
|
|
end
|
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.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.new
|
2009-08-21 15:50:01 +02:00
|
|
|
-- @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)
|
2016-02-26 20:07:26 +01:00
|
|
|
screen = get_screen(screen or 1)
|
2017-06-20 09:42:45 +02:00
|
|
|
-- True if `layout` should be used as the layout of each created tag
|
|
|
|
local have_single_layout = (not layout) or (layout.arrange and layout.name)
|
2009-08-21 15:50:01 +02:00
|
|
|
local tags = {}
|
|
|
|
for id, name in ipairs(names) do
|
2017-06-20 09:42:45 +02:00
|
|
|
local l = layout
|
|
|
|
if not have_single_layout then
|
|
|
|
l = layout[id] or layout[1]
|
|
|
|
end
|
|
|
|
table.insert(tags, id, tag.add(name, {screen = screen, layout = l}))
|
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.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.find_fallback
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param screen The screen 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()
|
2016-04-05 09:02:00 +02:00
|
|
|
local t = invalids or scr.selected_tags
|
2010-08-02 20:25:30 +02:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
for _, v in pairs(scr.tags) do
|
2017-03-08 21:18:33 +01:00
|
|
|
if not gtable.hasitem(t, v) then return v end
|
2010-08-02 20:25:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Delete a tag.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
|
|
|
-- To delete the current tag:
|
|
|
|
--
|
|
|
|
-- mouse.screen.selected_tag:delete()
|
|
|
|
--
|
|
|
|
-- @function tag.delete
|
|
|
|
-- @see awful.tag.add
|
|
|
|
-- @see awful.tag.find_fallback
|
|
|
|
-- @tparam[opt=awful.tag.find_fallback()] tag fallback_tag Tag to assign
|
|
|
|
-- stickied tags to.
|
2016-05-05 16:36:14 +02:00
|
|
|
-- @tparam[opt=false] boolean force Move even non-sticky clients to the fallback
|
|
|
|
-- tag.
|
2016-08-29 01:00:54 +02:00
|
|
|
-- @return Returns true if the tag is successfully deleted.
|
2010-08-02 20:25:30 +02:00
|
|
|
-- 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.
|
2016-05-05 16:36:14 +02:00
|
|
|
function tag.object.delete(self, fallback_tag, force)
|
2016-04-05 09:02:00 +02:00
|
|
|
-- abort if the taf isn't currently activated
|
2016-08-29 01:00:54 +02:00
|
|
|
if not self.activated then return false end
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
local target_scr = get_screen(tag.getproperty(self, "screen"))
|
|
|
|
local tags = target_scr.tags
|
|
|
|
local idx = tag.object.get_index(self)
|
2014-11-01 23:46:06 +01:00
|
|
|
local ntags = #tags
|
2010-08-02 20:25:30 +02:00
|
|
|
|
|
|
|
-- We can't use the target tag as a fallback.
|
2016-08-29 01:00:54 +02:00
|
|
|
if fallback_tag == self then return false end
|
2010-08-02 20:25:30 +02:00
|
|
|
|
|
|
|
-- No fallback_tag provided, try and get one.
|
|
|
|
if fallback_tag == nil then
|
2016-04-05 09:02:00 +02:00
|
|
|
fallback_tag = tag.find_fallback(target_scr, {self})
|
2010-08-02 20:25:30 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
-- Abort if we would have un-tagged clients.
|
2016-04-05 09:02:00 +02:00
|
|
|
local clients = self:clients()
|
2016-08-29 01:00:54 +02:00
|
|
|
if #clients > 0 and fallback_tag == nil then return false end
|
2010-08-02 20:25:30 +02:00
|
|
|
|
|
|
|
-- 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.
|
2016-05-05 16:36:14 +02:00
|
|
|
if (not c.sticky and nb_tags == 1 and not force) then
|
2010-08-02 20:25:30 +02:00
|
|
|
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
|
2016-10-05 21:16:33 +02:00
|
|
|
self.data.awful_tag_properties.screen = nil
|
2016-04-05 09:02:00 +02:00
|
|
|
self.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
|
|
|
|
|
2016-08-29 01:02:39 +02:00
|
|
|
-- If no tags are visible (and we did not delete the lasttag), try and
|
|
|
|
-- view one. The > 1 is because ntags is no longer synchronized with the
|
|
|
|
-- current count.
|
|
|
|
if target_scr.selected_tag == nil and ntags > 1 then
|
2016-08-29 01:04:09 +02:00
|
|
|
tag.history.restore(target_scr, 1)
|
2016-04-05 09:02:00 +02:00
|
|
|
if target_scr.selected_tag == nil then
|
2016-04-17 15:42:15 +02:00
|
|
|
local other_tag = tags[tags[1] == self and 2 or 1]
|
|
|
|
if other_tag then
|
|
|
|
other_tag.selected = true
|
|
|
|
end
|
2010-08-02 20:25:30 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return true
|
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- Delete a tag.
|
|
|
|
-- @deprecated awful.tag.delete
|
|
|
|
-- @see tag.delete
|
|
|
|
-- @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.
|
|
|
|
function tag.delete(target_tag, fallback_tag)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t:delete(fallback_tag) instead of awful.tag.delete", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
return tag.object.delete(target_tag, fallback_tag)
|
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Update the tag history.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @function awful.tag.history.update
|
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)
|
2016-02-27 09:24:19 +01:00
|
|
|
local s = get_screen(obj)
|
2016-04-05 09:02:00 +02:00
|
|
|
local curtags = s.selected_tags
|
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.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @function awful.tag.history.restore
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param screen The screen.
|
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)
|
2016-02-26 20:07:26 +01:00
|
|
|
local s = get_screen(screen or ascreen.focused())
|
2009-08-27 16:03:45 +02:00
|
|
|
local i = idx or "previous"
|
2016-04-05 09:02:00 +02:00
|
|
|
local sel = s.selected_tags
|
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
|
2016-06-12 13:09:09 +02:00
|
|
|
if t.activated and t.screen then
|
|
|
|
t.selected = true
|
|
|
|
end
|
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
|
|
|
|
2016-02-26 20:07:26 +01:00
|
|
|
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
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @deprecated awful.tag.gettags
|
|
|
|
-- @tparam screen s Screen
|
2012-10-20 16:34:06 +02:00
|
|
|
-- @return A table with all available tags
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see screen.tags
|
2012-10-20 16:34:06 +02:00
|
|
|
function tag.gettags(s)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use s.tags instead of awful.tag.gettags", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-02-26 20:07:26 +01:00
|
|
|
s = get_screen(s)
|
2013-01-02 15:06:45 +01:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
return s and s.tags or {}
|
2012-10-20 17:33:32 +02:00
|
|
|
end
|
|
|
|
|
2017-03-19 21:06:22 +01:00
|
|
|
--- Find a tag by name.
|
|
|
|
-- @tparam screen s The screen of the tag
|
2016-04-10 11:12:31 +02:00
|
|
|
-- @tparam string name The name of the tag
|
|
|
|
-- @return The tag found, or `nil`
|
2017-03-19 21:06:22 +01:00
|
|
|
-- @usage -- For the current screen
|
|
|
|
-- local t = awful.tag.find_by_name(awful.screen.focused(), "name")
|
|
|
|
--
|
|
|
|
-- -- For a screen index
|
|
|
|
-- local t = awful.tag.find_by_name(screen[1], "name")
|
|
|
|
--
|
|
|
|
-- -- For all screens
|
|
|
|
-- local t = awful.tag.find_by_name(nil, "name")
|
2016-04-10 11:12:31 +02:00
|
|
|
function tag.find_by_name(s, name)
|
2017-03-19 21:06:22 +01:00
|
|
|
--TODO v5: swap the arguments and make screen [opt]
|
2016-04-10 11:12:31 +02:00
|
|
|
local tags = s and s.tags or root.tags()
|
|
|
|
for _, t in ipairs(tags) do
|
|
|
|
if name == t.name then
|
|
|
|
return t
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- The tag screen.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::screen*
|
|
|
|
--
|
|
|
|
-- @property screen
|
|
|
|
-- @param screen
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @see screen
|
2016-01-03 09:29:21 +01:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
function tag.object.set_screen(t, s)
|
2016-01-03 09:29:21 +01:00
|
|
|
|
2016-02-26 20:07:26 +01:00
|
|
|
s = get_screen(s or ascreen.focused())
|
2017-02-25 16:07:36 +01:00
|
|
|
local sel = t.selected
|
2016-04-05 09:02:00 +02:00
|
|
|
local old_screen = get_screen(tag.getproperty(t, "screen"))
|
|
|
|
|
2014-04-09 22:04:32 +02:00
|
|
|
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
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "index", nil)
|
2014-03-26 22:59:33 +01:00
|
|
|
|
|
|
|
-- Change the screen
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "screen", s)
|
2018-03-13 03:50:44 +01:00
|
|
|
if s then
|
|
|
|
tag.setproperty(t, "index", #s:get_tags(true))
|
|
|
|
end
|
2014-03-26 22:59:33 +01:00
|
|
|
|
|
|
|
-- Make sure the client's screen matches its tags
|
2016-02-07 15:02:25 +01:00
|
|
|
for _,c in ipairs(t:clients()) do
|
2014-03-26 22:59:33 +01:00
|
|
|
c.screen = s --Move all clients
|
|
|
|
c:tags({t})
|
|
|
|
end
|
2014-11-01 23:46:06 +01:00
|
|
|
|
2018-03-13 03:50:44 +01:00
|
|
|
if old_screen then
|
|
|
|
-- Update all indexes
|
|
|
|
for i,t2 in ipairs(old_screen.tags) do
|
|
|
|
tag.setproperty(t2, "index", i)
|
|
|
|
end
|
2014-11-01 23:46:06 +01:00
|
|
|
|
2018-03-13 03:50:44 +01:00
|
|
|
-- Restore the old screen history if the tag was selected
|
|
|
|
if sel then
|
|
|
|
tag.history.restore(old_screen, 1)
|
|
|
|
end
|
2014-11-01 23:46:06 +01:00
|
|
|
end
|
2012-10-20 17:33:32 +02:00
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- Set a tag's screen
|
|
|
|
-- @deprecated awful.tag.setscreen
|
|
|
|
-- @see screen
|
|
|
|
-- @param s Screen
|
|
|
|
-- @param t tag object
|
|
|
|
function tag.setscreen(s, t)
|
|
|
|
-- For API consistency, the arguments have been swapped for Awesome 3.6
|
|
|
|
-- this method is already deprecated, so be silent and swap the args
|
|
|
|
if type(t) == "number" then
|
|
|
|
s, t = t, s
|
|
|
|
end
|
|
|
|
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.screen = s instead of awful.tag.setscreen(t, s)", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
tag.object.set_screen(t, s)
|
|
|
|
end
|
|
|
|
|
2012-10-20 17:33:32 +02:00
|
|
|
--- Get a tag's screen
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.getscreen
|
|
|
|
-- @see 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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.screen instead of awful.tag.getscreen(t)", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
-- A new getter is not required
|
|
|
|
|
|
|
|
t = t or ascreen.focused().selected_tag
|
2016-02-26 20:07:26 +01:00
|
|
|
local prop = tag.getproperty(t, "screen")
|
|
|
|
return prop and prop.index
|
2012-10-20 16:34:06 +02:00
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Return a table with all visible tags
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @deprecated awful.tag.selectedlist
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param s Screen.
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @return A table with all selected tags.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see screen.selected_tags
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.selectedlist(s)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use s.selected_tags instead of awful.tag.selectedlist", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
s = get_screen(s or ascreen.focused())
|
2008-09-29 16:49:18 +02:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
return s.selected_tags
|
|
|
|
end
|
2016-04-12 04:53:22 +02:00
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Return only the first visible tag.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @deprecated awful.tag.selected
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param s Screen.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see screen.selected_tag
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.selected(s)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use s.selected_tag instead of awful.tag.selected", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
s = get_screen(s or ascreen.focused())
|
|
|
|
|
|
|
|
return s.selected_tag
|
|
|
|
end
|
|
|
|
|
2016-08-30 18:25:05 +02:00
|
|
|
--- The default master width factor
|
|
|
|
--
|
|
|
|
-- @beautiful beautiful.master_width_factor
|
|
|
|
-- @param number (default: 0.5)
|
|
|
|
-- @see master_width_factor
|
|
|
|
-- @see gap
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- The tag master width factor.
|
|
|
|
--
|
|
|
|
-- The master width factor is one of the 5 main properties used to configure
|
|
|
|
-- the `layout`. Each layout interpret (or ignore) this property differenly.
|
|
|
|
--
|
|
|
|
-- See the layout suit documentation for information about how the master width
|
|
|
|
-- factor is used.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
2016-04-11 06:30:05 +02:00
|
|
|
-- * *property::mwfact* (deprecated)
|
|
|
|
-- * *property::master_width_factor*
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @property master_width_factor
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @param number Between 0 and 1
|
2016-04-11 06:50:46 +02:00
|
|
|
-- @see master_count
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @see column_count
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see master_fill_policy
|
|
|
|
-- @see gap
|
|
|
|
|
2016-04-11 06:30:05 +02:00
|
|
|
function tag.object.set_master_width_factor(t, mwfact)
|
2016-04-05 09:02:00 +02:00
|
|
|
if mwfact >= 0 and mwfact <= 1 then
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "mwfact", mwfact)
|
2016-04-11 06:30:05 +02:00
|
|
|
tag.setproperty(t, "master_width_factor", mwfact)
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-11 06:30:05 +02:00
|
|
|
function tag.object.get_master_width_factor(t)
|
2016-09-14 23:11:00 +02:00
|
|
|
return tag.getproperty(t, "master_width_factor")
|
|
|
|
or beautiful.master_width_factor
|
|
|
|
or defaults.master_width_factor
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Set master width factor.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @deprecated awful.tag.setmwfact
|
|
|
|
-- @see master_fill_policy
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @see master_width_factor
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.master_width_factor = mwfact instead of awful.tag.setmwfact", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2017-03-06 01:04:33 +01:00
|
|
|
tag.object.set_master_width_factor(t or ascreen.focused().selected_tag, mwfact)
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase master width factor.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.incmwfact
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @see master_width_factor
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @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)
|
2016-04-05 09:02:00 +02:00
|
|
|
t = t or t or ascreen.focused().selected_tag
|
2016-04-11 06:30:05 +02:00
|
|
|
tag.object.set_master_width_factor(t, tag.object.get_master_width_factor(t) + add)
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get master width factor.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.getmwfact
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @see master_width_factor
|
|
|
|
-- @see master_fill_policy
|
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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.master_width_factor instead of awful.tag.getmwfact", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-04-11 06:30:05 +02:00
|
|
|
return tag.object.get_master_width_factor(t or ascreen.focused().selected_tag)
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- An ordered list of layouts.
|
|
|
|
-- `awful.tag.layout` Is usually defined in `rc.lua`. It store the list of
|
|
|
|
-- layouts used when selecting the previous and next layouts. This is the
|
|
|
|
-- default:
|
|
|
|
--
|
|
|
|
-- -- Table of layouts to cover with awful.layout.inc, order matters.
|
|
|
|
-- awful.layout.layouts = {
|
|
|
|
-- awful.layout.suit.floating,
|
|
|
|
-- awful.layout.suit.tile,
|
|
|
|
-- awful.layout.suit.tile.left,
|
|
|
|
-- awful.layout.suit.tile.bottom,
|
|
|
|
-- awful.layout.suit.tile.top,
|
|
|
|
-- awful.layout.suit.fair,
|
|
|
|
-- awful.layout.suit.fair.horizontal,
|
|
|
|
-- awful.layout.suit.spiral,
|
|
|
|
-- awful.layout.suit.spiral.dwindle,
|
|
|
|
-- awful.layout.suit.max,
|
|
|
|
-- awful.layout.suit.max.fullscreen,
|
|
|
|
-- awful.layout.suit.magnifier,
|
|
|
|
-- awful.layout.suit.corner.nw,
|
|
|
|
-- -- awful.layout.suit.corner.ne,
|
|
|
|
-- -- awful.layout.suit.corner.sw,
|
|
|
|
-- -- awful.layout.suit.corner.se,
|
|
|
|
-- }
|
|
|
|
--
|
|
|
|
-- @field awful.tag.layouts
|
|
|
|
|
|
|
|
--- The tag client layout.
|
|
|
|
--
|
|
|
|
-- This property hold the layout. A layout can be either stateless or stateful.
|
|
|
|
-- Stateless layouts are used by default by Awesome. They tile clients without
|
|
|
|
-- any other overhead. They take an ordered list of clients and place them on
|
|
|
|
-- the screen. Stateful layouts create an object instance for each tags and
|
|
|
|
-- can store variables and metadata. Because of this, they are able to change
|
|
|
|
-- over time and be serialized (saved).
|
|
|
|
--
|
|
|
|
-- Both types of layouts have valid usage scenarios.
|
|
|
|
--
|
|
|
|
-- **Stateless layouts:**
|
|
|
|
--
|
|
|
|
-- These layouts are stored in `awful.layout.suit`. They expose a table with 2
|
|
|
|
-- fields:
|
|
|
|
--
|
|
|
|
-- * **name** (*string*): The layout name. This should be unique.
|
|
|
|
-- * **arrange** (*function*): The function called when the clients need to be
|
|
|
|
-- placed. The only parameter is a table or arguments returned by
|
|
|
|
-- `awful.layout.parameters`
|
|
|
|
--
|
|
|
|
-- **Stateful layouts:**
|
|
|
|
--
|
|
|
|
-- The stateful layouts API is the same as stateless, but they are a function
|
|
|
|
-- returining a layout instead of a layout itself. They also should have an
|
|
|
|
-- `is_dynamic = true` property. If they don't, `awful.tag` will create a new
|
|
|
|
-- instance everytime the layout is set. If they do, the instance will be
|
|
|
|
-- cached and re-used.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::layout*
|
|
|
|
--
|
|
|
|
-- @property layout
|
|
|
|
-- @see awful.tag.layouts
|
|
|
|
-- @tparam layout|function layout A layout table or a constructor function
|
2016-01-07 00:22:45 +01:00
|
|
|
-- @return The layout
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
function tag.object.set_layout(t, layout)
|
2016-01-07 00:22:45 +01:00
|
|
|
-- Check if the signature match a stateful layout
|
|
|
|
if type(layout) == "function" or (
|
|
|
|
type(layout) == "table"
|
|
|
|
and getmetatable(layout)
|
|
|
|
and getmetatable(layout).__call
|
|
|
|
) then
|
2016-10-05 21:03:34 +02:00
|
|
|
if not t.dynamic_layout_cache then
|
|
|
|
t.dynamic_layout_cache = {}
|
2016-01-07 00:22:45 +01:00
|
|
|
end
|
|
|
|
|
2016-10-05 21:03:34 +02:00
|
|
|
local instance = t.dynamic_layout_cache[layout] or layout(t)
|
2016-01-07 00:22:45 +01:00
|
|
|
|
|
|
|
-- Always make sure the layout is notified it is enabled
|
2016-04-05 09:02:00 +02:00
|
|
|
if tag.getproperty(t, "screen").selected_tag == t and instance.wake_up then
|
2016-01-07 00:22:45 +01:00
|
|
|
instance:wake_up()
|
|
|
|
end
|
|
|
|
|
|
|
|
-- Avoid creating the same layout twice, use layout:reset() to reset
|
|
|
|
if instance.is_dynamic then
|
2016-10-05 21:03:34 +02:00
|
|
|
t.dynamic_layout_cache[layout] = instance
|
2016-01-07 00:22:45 +01:00
|
|
|
end
|
2016-01-19 23:52:08 +01:00
|
|
|
|
|
|
|
layout = instance
|
2016-01-07 00:22:45 +01:00
|
|
|
end
|
|
|
|
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "layout", layout)
|
2016-01-07 00:22:45 +01:00
|
|
|
|
|
|
|
return layout
|
|
|
|
end
|
|
|
|
|
2017-07-29 19:58:45 +02:00
|
|
|
function tag.object.get_layout(t)
|
|
|
|
return tag.getproperty(t, "layout") or require("awful.layout.suit.floating")
|
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- Set layout.
|
|
|
|
-- @deprecated awful.tag.setlayout
|
|
|
|
-- @see layout
|
|
|
|
-- @param layout a layout table or a constructor function
|
|
|
|
-- @param t The tag to modify
|
|
|
|
-- @return The layout
|
|
|
|
function tag.setlayout(layout, t)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.layout = layout instead of awful.tag.setlayout", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
return tag.object.set_layout(t, layout)
|
|
|
|
end
|
|
|
|
|
|
|
|
--- Define if the tag must be deleted when the last client is untagged.
|
|
|
|
--
|
|
|
|
-- This is useful to create "throw-away" tags for operation like 50/50
|
|
|
|
-- side-by-side views.
|
|
|
|
--
|
|
|
|
-- local t = awful.tag.add("Temporary", {
|
|
|
|
-- screen = client.focus.screen,
|
|
|
|
-- volatile = true,
|
|
|
|
-- clients = {
|
|
|
|
-- client.focus,
|
|
|
|
-- awful.client.focus.history.get(client.focus.screen, 1)
|
|
|
|
-- }
|
|
|
|
-- }
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::volatile*
|
|
|
|
--
|
|
|
|
-- @property volatile
|
|
|
|
-- @param boolean
|
|
|
|
|
|
|
|
-- Volatile accessors are implicit
|
|
|
|
|
2016-03-11 05:47:29 +01:00
|
|
|
--- Set if the tag must be deleted when the last client is untagged
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.setvolatile
|
|
|
|
-- @see volatile
|
2016-03-11 05:47:29 +01:00
|
|
|
-- @tparam boolean volatile If the tag must be deleted when the last client is untagged
|
|
|
|
-- @param t The tag to modify, if null tag.selected() is used.
|
|
|
|
function tag.setvolatile(volatile, t)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.volatile = volatile instead of awful.tag.setvolatile", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "volatile", volatile)
|
2016-03-11 05:47:29 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get if the tag must be deleted when the last client closes
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.getvolatile
|
|
|
|
-- @see volatile
|
2016-03-11 05:47:29 +01:00
|
|
|
-- @param t The tag to modify, if null tag.selected() is used.
|
|
|
|
-- @treturn boolean If the tag will be deleted when the last client is untagged
|
|
|
|
function tag.getvolatile(t)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.volatile instead of awful.tag.getvolatile", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-03-11 05:47:29 +01:00
|
|
|
return tag.getproperty(t, "volatile") or false
|
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- The default gap.
|
|
|
|
--
|
|
|
|
-- @beautiful beautiful.useless_gap
|
|
|
|
-- @param number (default: 0)
|
|
|
|
-- @see gap
|
2016-08-30 18:25:05 +02:00
|
|
|
-- @see gap_single_client
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
--- The gap (spacing, also called `useless_gap`) between clients.
|
|
|
|
--
|
|
|
|
-- This property allow to waste space on the screen in the name of style,
|
|
|
|
-- unicorns and readability.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
2016-04-11 06:50:46 +02:00
|
|
|
-- * *property::useless_gap*
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
|
|
|
-- @property gap
|
|
|
|
-- @param number The value has to be greater than zero.
|
2016-08-30 18:25:05 +02:00
|
|
|
-- @see gap_single_client
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
function tag.object.set_gap(t, useless_gap)
|
|
|
|
if useless_gap >= 0 then
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "useless_gap", useless_gap)
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
function tag.object.get_gap(t)
|
2016-09-14 23:11:00 +02:00
|
|
|
return tag.getproperty(t, "useless_gap")
|
|
|
|
or beautiful.useless_gap
|
|
|
|
or defaults.gap
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
|
2015-02-22 20:29:18 +01:00
|
|
|
--- Set the spacing between clients
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.setgap
|
|
|
|
-- @see gap
|
2015-02-22 20:29:18 +01:00
|
|
|
-- @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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.gap = useless_gap instead of awful.tag.setgap", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
tag.object.set_gap(t or ascreen.focused().selected_tag, useless_gap)
|
2015-02-22 20:29:18 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase the spacing between clients
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.incgap
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see gap
|
2015-02-22 20:29:18 +01:00
|
|
|
-- @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)
|
2016-04-05 09:02:00 +02:00
|
|
|
t = t or t or ascreen.focused().selected_tag
|
|
|
|
tag.object.set_gap(t, tag.object.get_gap(t) + add)
|
2015-02-22 20:29:18 +01:00
|
|
|
end
|
|
|
|
|
2016-08-30 18:25:05 +02:00
|
|
|
--- Enable gaps for a single client.
|
|
|
|
--
|
|
|
|
-- @beautiful beautiful.gap_single_client
|
|
|
|
-- @param boolean (default: true)
|
|
|
|
-- @see gap
|
|
|
|
-- @see gap_single_client
|
|
|
|
|
|
|
|
--- Enable gaps for a single client.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::gap\_single\_client*
|
|
|
|
--
|
|
|
|
-- @property gap_single_client
|
|
|
|
-- @param boolean Enable gaps for a single client
|
|
|
|
|
|
|
|
function tag.object.set_gap_single_client(t, gap_single_client)
|
|
|
|
tag.setproperty(t, "gap_single_client", gap_single_client == true)
|
|
|
|
end
|
|
|
|
|
|
|
|
function tag.object.get_gap_single_client(t)
|
2016-10-26 01:43:45 +02:00
|
|
|
local val = tag.getproperty(t, "gap_single_client")
|
|
|
|
if val ~= nil then
|
|
|
|
return val
|
|
|
|
end
|
|
|
|
val = beautiful.gap_single_client
|
|
|
|
if val ~= nil then
|
|
|
|
return val
|
|
|
|
end
|
|
|
|
return defaults.gap_single_client
|
2016-08-30 18:25:05 +02:00
|
|
|
end
|
|
|
|
|
2015-11-19 20:33:04 +01:00
|
|
|
--- Get the spacing between clients.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @deprecated awful.tag.getgap
|
|
|
|
-- @see gap
|
2015-11-19 20:33:04 +01:00
|
|
|
-- @tparam[opt=tag.selected()] tag t The tag.
|
|
|
|
-- @tparam[opt] int numclients Number of (tiled) clients. Passing this will
|
|
|
|
-- return 0 for a single client. You can override this function to change
|
|
|
|
-- this behavior.
|
|
|
|
function tag.getgap(t, numclients)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.gap instead of awful.tag.getgap", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2015-11-19 20:33:04 +01:00
|
|
|
if numclients == 1 then
|
|
|
|
return 0
|
|
|
|
end
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
return tag.object.get_gap(t or ascreen.focused().selected_tag)
|
|
|
|
end
|
|
|
|
|
2016-12-20 02:49:04 +01:00
|
|
|
--- The default fill policy.
|
|
|
|
--
|
|
|
|
-- ** Possible values**:
|
|
|
|
--
|
|
|
|
-- * *expand*: Take all the space
|
|
|
|
-- * *master_width_factor*: Only take the ratio defined by the
|
|
|
|
-- `master_width_factor`
|
2016-08-30 18:25:05 +02:00
|
|
|
--
|
|
|
|
-- @beautiful beautiful.master_fill_policy
|
|
|
|
-- @param string (default: "expand")
|
|
|
|
-- @see master_fill_policy
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- Set size fill policy for the master client(s).
|
|
|
|
--
|
2016-12-20 02:49:04 +01:00
|
|
|
-- ** Possible values**:
|
|
|
|
--
|
|
|
|
-- * *expand*: Take all the space
|
|
|
|
-- * *master_width_factor*: Only take the ratio defined by the
|
|
|
|
-- `master_width_factor`
|
|
|
|
--
|
2016-04-05 09:02:00 +02:00
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::master_fill_policy*
|
|
|
|
--
|
|
|
|
-- @property master_fill_policy
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @param string "expand" or "master_width_factor"
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
function tag.object.get_master_fill_policy(t)
|
2016-09-14 23:11:00 +02:00
|
|
|
return tag.getproperty(t, "master_fill_policy")
|
|
|
|
or beautiful.master_fill_policy
|
|
|
|
or defaults.master_fill_policy
|
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)
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.setmfpol
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see master_fill_policy
|
2015-07-15 15:24:08 +02:00
|
|
|
-- @tparam string policy Can be set to
|
|
|
|
-- "expand" (fill all the available workarea) or
|
2016-04-11 06:30:05 +02:00
|
|
|
-- "master_width_factor" (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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.master_fill_policy = policy instead of awful.tag.setmfpol", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
t = t or ascreen.focused().selected_tag
|
2016-04-09 11:06:44 +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)
|
2016-04-11 06:30:05 +02:00
|
|
|
-- between "expand" and "master_width_factor".
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @function awful.tag.togglemfpol
|
|
|
|
-- @see master_fill_policy
|
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)
|
2016-04-05 09:02:00 +02:00
|
|
|
t = t or ascreen.focused().selected_tag
|
|
|
|
|
2015-07-15 15:24:08 +02:00
|
|
|
if tag.getmfpol(t) == "expand" then
|
2016-04-11 06:30:05 +02:00
|
|
|
tag.setproperty(t, "master_fill_policy", "master_width_factor")
|
2015-07-15 15:24:08 +02:00
|
|
|
else
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "master_fill_policy", "expand")
|
2015-07-15 15:24:08 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-07-16 11:48:18 +02:00
|
|
|
--- Get size fill policy for the master client(s)
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.getmfpol
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @see master_fill_policy
|
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
|
2016-04-11 06:30:05 +02:00
|
|
|
-- "master_width_factor" (fill only an area inside the master width factor)
|
2015-07-15 15:24:08 +02:00
|
|
|
function tag.getmfpol(t)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.master_fill_policy instead of awful.tag.getmfpol", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
t = t or ascreen.focused().selected_tag
|
2016-09-14 23:11:00 +02:00
|
|
|
return tag.getproperty(t, "master_fill_policy")
|
|
|
|
or beautiful.master_fill_policy
|
|
|
|
or defaults.master_fill_policy
|
2015-07-15 15:24:08 +02:00
|
|
|
end
|
|
|
|
|
2016-08-30 18:25:05 +02:00
|
|
|
--- The default number of master windows.
|
|
|
|
--
|
|
|
|
-- @beautiful beautiful.master_count
|
|
|
|
-- @param integer (default: 1)
|
|
|
|
-- @see master_count
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Set the number of master windows.
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
2016-04-11 06:50:46 +02:00
|
|
|
-- * *property::nmaster* (deprecated)
|
2017-01-22 15:00:53 +01:00
|
|
|
-- * *property::master_count*
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
2016-04-11 06:50:46 +02:00
|
|
|
-- @property master_count
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @param integer nmaster Only positive values are accepted
|
|
|
|
|
2016-04-11 06:50:46 +02:00
|
|
|
function tag.object.set_master_count(t, nmaster)
|
2016-04-05 09:02:00 +02:00
|
|
|
if nmaster >= 0 then
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "nmaster", nmaster)
|
2016-04-11 06:50:46 +02:00
|
|
|
tag.setproperty(t, "master_count", nmaster)
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-11 06:50:46 +02:00
|
|
|
function tag.object.get_master_count(t)
|
2016-09-14 23:11:00 +02:00
|
|
|
return tag.getproperty(t, "master_count")
|
|
|
|
or beautiful.master_count
|
|
|
|
or defaults.master_count
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
|
2016-11-21 22:38:23 +01:00
|
|
|
---
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.setnmaster
|
2016-04-11 06:50:46 +02:00
|
|
|
-- @see master_count
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.master_count = nmaster instead of awful.tag.setnmaster", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-04-11 06:50:46 +02:00
|
|
|
tag.object.set_master_count(t or ascreen.focused().selected_tag, nmaster)
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the number of master windows.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.getnmaster
|
2016-04-11 06:50:46 +02:00
|
|
|
-- @see master_count
|
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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.master_count instead of awful.tag.setnmaster", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
t = t or ascreen.focused().selected_tag
|
2016-04-11 06:50:46 +02:00
|
|
|
return tag.getproperty(t, "master_count") or 1
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase the number of master windows.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.incnmaster
|
2016-04-11 06:50:46 +02:00
|
|
|
-- @see master_count
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @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)
|
2016-04-05 09:02:00 +02:00
|
|
|
t = t or ascreen.focused().selected_tag
|
|
|
|
|
2015-09-09 23:44:10 +02:00
|
|
|
if sensible then
|
2016-04-05 09:02:00 +02:00
|
|
|
local screen = get_screen(tag.getproperty(t, "screen"))
|
|
|
|
local ntiled = #screen.tiled_clients
|
2015-09-09 23:44:10 +02:00
|
|
|
|
2016-04-11 06:50:46 +02:00
|
|
|
local nmaster = tag.object.get_master_count(t)
|
2015-09-09 23:44:10 +02:00
|
|
|
if nmaster > ntiled then
|
|
|
|
nmaster = ntiled
|
|
|
|
end
|
|
|
|
|
|
|
|
local newnmaster = nmaster + add
|
|
|
|
if newnmaster > ntiled then
|
|
|
|
newnmaster = ntiled
|
|
|
|
end
|
2016-04-11 06:50:46 +02:00
|
|
|
tag.object.set_master_count(t, newnmaster)
|
2015-09-09 23:44:10 +02:00
|
|
|
else
|
2016-04-11 06:50:46 +02:00
|
|
|
tag.object.set_master_count(t, tag.object.get_master_count(t) + add)
|
2015-09-09 23:44:10 +02:00
|
|
|
end
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- Set the tag icon.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
|
|
|
-- * *property::icon*
|
|
|
|
--
|
|
|
|
-- @property icon
|
|
|
|
-- @tparam path|surface icon The icon
|
|
|
|
|
|
|
|
-- accessors are implicit.
|
2009-01-13 16:04:11 +01:00
|
|
|
|
|
|
|
--- Set the tag icon
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.seticon
|
|
|
|
-- @see icon
|
2009-01-13 16:04:11 +01:00
|
|
|
-- @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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.icon = icon instead of awful.tag.seticon", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
_tag = _tag or ascreen.focused().selected_tag
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(_tag, "icon", icon)
|
2009-01-13 16:04:11 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get the tag icon
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.geticon
|
|
|
|
-- @see 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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.icon instead of awful.tag.geticon", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
_tag = _tag or ascreen.focused().selected_tag
|
2012-06-12 20:13:09 +02:00
|
|
|
return tag.getproperty(_tag, "icon")
|
2009-01-13 16:04:11 +01:00
|
|
|
end
|
|
|
|
|
2016-08-30 18:25:05 +02:00
|
|
|
--- The default number of columns.
|
|
|
|
--
|
|
|
|
-- @beautiful beautiful.column_count
|
|
|
|
-- @param integer (default: 1)
|
|
|
|
-- @see column_count
|
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- Set the number of columns.
|
|
|
|
--
|
|
|
|
-- **Signal:**
|
|
|
|
--
|
2016-04-11 06:30:05 +02:00
|
|
|
-- * *property::ncol* (deprecated)
|
|
|
|
-- * *property::column_count*
|
2016-04-05 09:02:00 +02:00
|
|
|
--
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @property column_count
|
|
|
|
-- @tparam integer ncol Has to be greater than 1
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-04-11 06:30:05 +02:00
|
|
|
function tag.object.set_column_count(t, ncol)
|
2016-04-05 09:02:00 +02:00
|
|
|
if ncol >= 1 then
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "ncol", ncol)
|
2016-04-11 06:30:05 +02:00
|
|
|
tag.setproperty(t, "column_count", ncol)
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-04-11 06:30:05 +02:00
|
|
|
function tag.object.get_column_count(t)
|
2016-09-14 23:11:00 +02:00
|
|
|
return tag.getproperty(t, "column_count")
|
|
|
|
or beautiful.column_count
|
|
|
|
or defaults.column_count
|
2016-04-05 09:02:00 +02:00
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- Set number of column windows.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.setncol
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @see column_count
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.column_count = new_index instead of awful.tag.setncol", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
t = t or ascreen.focused().selected_tag
|
2009-01-26 10:37:52 +01:00
|
|
|
if ncol >= 1 then
|
2016-04-09 11:06:44 +02:00
|
|
|
tag.setproperty(t, "ncol", ncol)
|
2016-04-11 06:30:05 +02:00
|
|
|
tag.setproperty(t, "column_count", ncol)
|
2009-01-26 10:37:52 +01:00
|
|
|
end
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Get number of column windows.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.getncol
|
2016-04-11 06:30:05 +02:00
|
|
|
-- @see column_count
|
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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.column_count instead of awful.tag.getncol", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
t = t or ascreen.focused().selected_tag
|
2016-04-11 06:30:05 +02:00
|
|
|
return tag.getproperty(t, "column_count") or 1
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- Increase number of column windows.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.incncol
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @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.
|
2016-10-02 16:03:11 +02:00
|
|
|
-- @tparam[opt=false] boolean sensible Limit column_count based on the number
|
|
|
|
-- of visible tiled windows?
|
2015-09-09 23:44:10 +02:00
|
|
|
function tag.incncol(add, t, sensible)
|
2016-04-05 09:02:00 +02:00
|
|
|
t = t or ascreen.focused().selected_tag
|
|
|
|
|
2015-09-09 23:44:10 +02:00
|
|
|
if sensible then
|
2016-04-05 09:02:00 +02:00
|
|
|
local screen = get_screen(tag.getproperty(t, "screen"))
|
|
|
|
local ntiled = #screen.tiled_clients
|
2016-04-11 06:50:46 +02:00
|
|
|
local nmaster = tag.object.get_master_count(t)
|
2015-09-09 23:44:10 +02:00
|
|
|
local nsecondary = ntiled - nmaster
|
|
|
|
|
2016-04-11 06:30:05 +02:00
|
|
|
local ncol = tag.object.get_column_count(t)
|
2015-09-09 23:44:10 +02:00
|
|
|
if ncol > nsecondary then
|
|
|
|
ncol = nsecondary
|
|
|
|
end
|
|
|
|
|
|
|
|
local newncol = ncol + add
|
|
|
|
if newncol > nsecondary then
|
|
|
|
newncol = nsecondary
|
|
|
|
end
|
2016-04-05 09:02:00 +02:00
|
|
|
|
2016-04-11 06:30:05 +02:00
|
|
|
tag.object.set_column_count(t, newncol)
|
2015-09-09 23:44:10 +02:00
|
|
|
else
|
2016-04-11 06:30:05 +02:00
|
|
|
tag.object.set_column_count(t, tag.object.get_column_count(t) + add)
|
2015-09-09 23:44:10 +02:00
|
|
|
end
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- View no tag.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.viewnone
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @tparam[opt] int|screen screen The screen.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewnone(screen)
|
2016-04-05 09:02:00 +02:00
|
|
|
screen = screen or ascreen.focused()
|
|
|
|
local tags = screen.tags
|
2016-02-07 15:02:25 +01:00
|
|
|
for _, t in pairs(tags) do
|
2008-09-29 16:49:18 +02:00
|
|
|
t.selected = false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2009-05-30 18:11:07 +02:00
|
|
|
--- View a tag by its taglist index.
|
2016-04-12 04:53:22 +02:00
|
|
|
--
|
|
|
|
-- This is equivalent to `screen.tags[i]:view_only()`
|
|
|
|
-- @function awful.tag.viewidx
|
|
|
|
-- @see screen.tags
|
|
|
|
-- @param i The **relative** index to see.
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param[opt] screen The screen.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewidx(i, screen)
|
2016-02-26 20:07:26 +01:00
|
|
|
screen = get_screen(screen or ascreen.focused())
|
2016-04-05 09:02:00 +02:00
|
|
|
local tags = screen.tags
|
2009-05-30 18:11:07 +02:00
|
|
|
local showntags = {}
|
2016-02-07 15:02:25 +01:00
|
|
|
for _, 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
|
2016-04-05 09:02:00 +02:00
|
|
|
local sel = screen.selected_tag
|
2012-06-12 20:13:09 +02:00
|
|
|
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
|
2017-03-06 17:15:40 +01:00
|
|
|
showntags[gmath.cycle(#showntags, k + i)].selected = true
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
end
|
2016-02-26 20:07:26 +01:00
|
|
|
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.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @deprecated awful.tag.getidx
|
|
|
|
-- @see index
|
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)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t.index instead of awful.tag.getidx", {deprecated_in=4})
|
2010-05-29 01:39:18 +02:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
return tag.object.get_index(query_tag or ascreen.focused().selected_tag)
|
2010-05-29 01:39:18 +02:00
|
|
|
end
|
|
|
|
|
2008-09-29 16:49:18 +02:00
|
|
|
--- View next tag. This is the same as tag.viewidx(1).
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.viewnext
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param screen The screen.
|
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).
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.viewprev
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param screen The screen.
|
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.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @function tag.view_only
|
|
|
|
-- @see selected
|
|
|
|
function tag.object.view_only(self)
|
|
|
|
local tags = self.screen.tags
|
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
|
2016-04-05 09:02:00 +02:00
|
|
|
if _tag ~= self then
|
2012-06-12 20:13:09 +02:00
|
|
|
_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.
|
2016-04-05 09:02:00 +02:00
|
|
|
self.selected = true
|
|
|
|
capi.screen[self.screen]:emit_signal("tag::history::update")
|
|
|
|
end
|
|
|
|
|
|
|
|
--- View only a tag.
|
|
|
|
-- @deprecated awful.tag.viewonly
|
|
|
|
-- @see tag.view_only
|
|
|
|
-- @param t The tag object.
|
|
|
|
function tag.viewonly(t)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use t:view_only() instead of awful.tag.viewonly", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
tag.object.view_only(t)
|
2008-09-29 16:49:18 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
--- View only a set of tags.
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.viewmore
|
2008-09-29 16:49:18 +02:00
|
|
|
-- @param tags A table with tags to view only.
|
2016-02-26 20:07:26 +01:00
|
|
|
-- @param[opt] screen The screen of the tags.
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.viewmore(tags, screen)
|
2016-02-26 20:07:26 +01:00
|
|
|
screen = get_screen(screen or ascreen.focused())
|
2016-04-05 09:02:00 +02:00
|
|
|
local screen_tags = screen.tags
|
2012-06-12 20:13:09 +02:00
|
|
|
for _, _tag in ipairs(screen_tags) do
|
2017-03-08 21:18:33 +01:00
|
|
|
if not gtable.hasitem(tags, _tag) then
|
2012-06-12 20:13:09 +02:00
|
|
|
_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
|
2016-02-26 20:07:26 +01:00
|
|
|
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
|
2016-04-12 04:53:22 +02:00
|
|
|
-- @function awful.tag.viewtoggle
|
|
|
|
-- @see selected
|
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
|
2016-04-05 09:02:00 +02:00
|
|
|
capi.screen[tag.getproperty(t, "screen")]: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.
|
2016-04-12 04:53:22 +02:00
|
|
|
--
|
|
|
|
-- Do not use.
|
|
|
|
--
|
|
|
|
-- @deprecated awful.tag.getdata
|
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)
|
2016-10-05 21:16:33 +02:00
|
|
|
return _tag.data.awful_tag_properties
|
2009-02-24 21:50:46 +01:00
|
|
|
end
|
|
|
|
|
2008-11-25 17:01:06 +01:00
|
|
|
--- Get a tag property.
|
2016-04-12 04:53:22 +02:00
|
|
|
--
|
|
|
|
-- Use `_tag.prop` directly.
|
|
|
|
--
|
|
|
|
-- @deprecated awful.tag.getproperty
|
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)
|
2016-10-05 21:16:33 +02:00
|
|
|
if not _tag then return end -- FIXME: Turn this into an error?
|
|
|
|
if _tag.data.awful_tag_properties then
|
|
|
|
return _tag.data.awful_tag_properties[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.
|
2016-04-12 04:53:22 +02:00
|
|
|
--
|
|
|
|
-- Use `_tag.prop = value`
|
|
|
|
--
|
|
|
|
-- @deprecated awful.tag.setproperty
|
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.
|
2016-04-09 11:06:44 +02:00
|
|
|
function tag.setproperty(_tag, prop, value)
|
2016-10-05 21:16:33 +02:00
|
|
|
if not _tag.data.awful_tag_properties then
|
|
|
|
_tag.data.awful_tag_properties = {}
|
2008-11-25 17:01:06 +01:00
|
|
|
end
|
2016-01-03 09:29:21 +01:00
|
|
|
|
2016-10-05 21:16:33 +02:00
|
|
|
if _tag.data.awful_tag_properties[prop] ~= value then
|
|
|
|
_tag.data.awful_tag_properties[prop] = value
|
2016-04-09 11:06:44 +02:00
|
|
|
_tag:emit_signal("property::" .. prop)
|
2015-07-07 13:01:53 +02:00
|
|
|
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.
|
2016-04-05 09:02:00 +02:00
|
|
|
-- @deprecated awful.tag.withcurrent
|
2009-02-03 12:20:17 +01:00
|
|
|
-- @param c The client to tag.
|
2013-10-08 10:45:22 +02:00
|
|
|
function tag.withcurrent(c)
|
2017-03-15 06:08:40 +01:00
|
|
|
gdebug.deprecate("Use c:to_selected_tags() instead of awful.tag.selectedlist", {deprecated_in=4})
|
2016-04-05 09:02:00 +02:00
|
|
|
|
|
|
|
-- It can't use c:to_selected_tags() because awful.tag is loaded before
|
|
|
|
-- awful.client
|
|
|
|
|
2013-10-08 10:45:22 +02:00
|
|
|
local tags = {}
|
2016-02-07 15:02:25 +01:00
|
|
|
for _, t in ipairs(c:tags()) do
|
2016-04-05 09:02:00 +02:00
|
|
|
if get_screen(tag.getproperty(t, "screen")) == get_screen(c.screen) then
|
2013-10-08 10:45:22 +02:00
|
|
|
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
|
2016-04-05 09:02:00 +02:00
|
|
|
tags = c.screen.selected_tags
|
2013-10-08 10:45:22 +02:00
|
|
|
end
|
2014-03-26 14:29:02 +01:00
|
|
|
if #tags == 0 then
|
2016-04-05 09:02:00 +02:00
|
|
|
tags = c.screen.tags
|
2014-03-26 14:29:02 +01:00
|
|
|
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)
|
2016-02-26 20:07:26 +01:00
|
|
|
screen = get_screen(screen)
|
2016-02-07 15:02:25 +01:00
|
|
|
capi.tag.connect_signal(sig, function(_tag)
|
2016-04-05 09:02:00 +02:00
|
|
|
if get_screen(tag.getproperty(_tag, "screen")) == screen then
|
2012-10-20 17:35:09 +02:00
|
|
|
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.
|
2016-04-12 04:53:22 +02:00
|
|
|
--
|
|
|
|
-- @function awful.tag.attached_connect_signal
|
2017-01-22 15:31:56 +01:00
|
|
|
-- @screen screen The screen concerned, or all if nil.
|
|
|
|
-- @tparam[opt] string signal The signal name.
|
2016-11-09 21:46:58 +01:00
|
|
|
-- @tparam[opt] function Callback
|
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.
|
2016-08-23 05:18:07 +02:00
|
|
|
capi.client.connect_signal("property::screen", function(c)
|
|
|
|
-- First, the delayed timer is necessary to avoid a race condition with
|
|
|
|
-- awful.rules. It is also messing up the tags before the user have a chance
|
|
|
|
-- to set them manually.
|
|
|
|
timer.delayed_call(function()
|
2017-01-23 22:53:01 +01:00
|
|
|
if not c.valid then
|
|
|
|
return
|
|
|
|
end
|
2016-08-23 05:18:07 +02:00
|
|
|
local tags, new_tags = c:tags(), {}
|
|
|
|
|
|
|
|
for _, t in ipairs(tags) do
|
|
|
|
if t.screen == c.screen then
|
|
|
|
table.insert(new_tags, t)
|
2009-09-22 11:57:40 +02:00
|
|
|
end
|
|
|
|
end
|
2016-08-23 05:18:07 +02:00
|
|
|
|
|
|
|
if #new_tags == 0 then
|
|
|
|
c:emit_signal("request::tag", nil, {reason="screen"})
|
|
|
|
elseif #new_tags < #tags then
|
|
|
|
c:tags(new_tags)
|
|
|
|
end
|
|
|
|
end)
|
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.
|
2016-02-07 15:02:25 +01:00
|
|
|
local function update_urgent(t, modif)
|
2015-02-17 18:38:24 +01:00
|
|
|
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
|
2016-02-07 15:02:25 +01:00
|
|
|
update_urgent(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
|
2016-02-07 15:02:25 +01:00
|
|
|
update_urgent(t, -1)
|
2014-11-01 23:19:12 +01:00
|
|
|
end
|
2016-03-11 05:47:29 +01:00
|
|
|
|
|
|
|
if #t:clients() == 0 and tag.getproperty(t, "volatile") then
|
2016-04-05 09:02:00 +02:00
|
|
|
tag.object.delete(t)
|
2016-03-11 05:47:29 +01:00
|
|
|
end
|
2014-11-01 23:19:12 +01:00
|
|
|
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)
|
2016-02-07 15:02:25 +01:00
|
|
|
for _,t in ipairs(c:tags()) do
|
|
|
|
update_urgent(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 23:22:01 +01:00
|
|
|
capi.client.connect_signal("untagged", client_untagged)
|
|
|
|
capi.client.connect_signal("tagged", client_tagged)
|
2016-04-05 09:02:00 +02:00
|
|
|
capi.tag.connect_signal("request::select", tag.object.view_only)
|
2010-01-08 16:16:37 +01:00
|
|
|
|
2016-04-05 09:02:00 +02:00
|
|
|
--- True when a tagged client is urgent
|
|
|
|
-- @signal property::urgent
|
|
|
|
-- @see client.urgent
|
|
|
|
|
|
|
|
--- The number of urgent tagged clients
|
|
|
|
-- @signal property::urgent_count
|
|
|
|
-- @see client.urgent
|
|
|
|
|
2017-03-19 21:28:38 +01:00
|
|
|
--- Emitted when a screen is removed.
|
|
|
|
-- This can be used to salvage existing tags by moving them to a new
|
|
|
|
-- screen (or creating a virtual screen). By default, there is no
|
|
|
|
-- handler for this request. The tags will be deleted. To prevent
|
|
|
|
-- this, an handler for this request must simply set a new screen
|
|
|
|
-- for the tag.
|
|
|
|
-- @signal request::screen
|
|
|
|
|
|
|
|
--- Emitted after `request::screen` if no new screen has been set.
|
|
|
|
-- The tag will be deleted, this is a last chance to move its clients
|
|
|
|
-- before they are sent to a fallback tag. Connect to `request::screen`
|
|
|
|
-- if you wish to salvage the tag.
|
|
|
|
-- @signal removal-pending
|
|
|
|
|
2016-03-06 11:37:38 +01:00
|
|
|
capi.screen.connect_signal("tag::history::update", tag.history.update)
|
2009-08-27 16:03:45 +02:00
|
|
|
|
2017-06-11 05:52:13 +02:00
|
|
|
-- Make sure the history is set early
|
|
|
|
timer.delayed_call(function()
|
|
|
|
for s in capi.screen do
|
|
|
|
s:emit_signal("tag::history::update")
|
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2016-05-01 19:41:40 +02:00
|
|
|
capi.screen.connect_signal("removed", function(s)
|
2016-05-08 15:00:14 +02:00
|
|
|
-- First give other code a chance to move the tag to another screen
|
|
|
|
for _, t in pairs(s.tags) do
|
|
|
|
t:emit_signal("request::screen")
|
|
|
|
end
|
|
|
|
-- Everything that's left: Tell everyone that these tags go away (other code
|
|
|
|
-- could e.g. save clients)
|
2016-05-01 19:41:40 +02:00
|
|
|
for _, t in pairs(s.tags) do
|
|
|
|
t:emit_signal("removal-pending")
|
|
|
|
end
|
2016-05-08 15:00:14 +02:00
|
|
|
-- Give other code yet another change to save clients
|
|
|
|
for _, c in pairs(capi.client.get(s)) do
|
|
|
|
c:emit_signal("request::tag", nil, { reason = "screen-removed" })
|
|
|
|
end
|
2016-05-01 19:41:40 +02:00
|
|
|
-- Then force all clients left to go somewhere random
|
|
|
|
local fallback = nil
|
|
|
|
for other_screen in capi.screen do
|
|
|
|
if #other_screen.tags > 0 then
|
|
|
|
fallback = other_screen.tags[1]
|
|
|
|
break
|
|
|
|
end
|
|
|
|
end
|
|
|
|
for _, t in pairs(s.tags) do
|
|
|
|
t:delete(fallback, true)
|
|
|
|
end
|
|
|
|
-- If any tag survived until now, forcefully get rid of it
|
|
|
|
for _, t in pairs(s.tags) do
|
|
|
|
t.activated = false
|
2016-05-17 01:17:17 +02:00
|
|
|
|
2016-10-05 21:16:33 +02:00
|
|
|
if t.data.awful_tag_properties then
|
|
|
|
t.data.awful_tag_properties.screen = nil
|
2016-05-17 01:17:17 +02:00
|
|
|
end
|
2016-05-01 19:41:40 +02:00
|
|
|
end
|
|
|
|
end)
|
|
|
|
|
2012-06-12 20:13:09 +02:00
|
|
|
function tag.mt:__call(...)
|
|
|
|
return tag.new(...)
|
|
|
|
end
|
|
|
|
|
2016-03-13 08:43:50 +01:00
|
|
|
-- Extend the luaobject
|
|
|
|
-- `awful.tag.setproperty` currently handle calling the setter method itself
|
|
|
|
-- while `awful.tag.getproperty`.
|
|
|
|
object.properties(capi.tag, {
|
2016-04-05 09:02:00 +02:00
|
|
|
getter_class = tag.object,
|
|
|
|
setter_class = tag.object,
|
2016-03-13 08:43:50 +01:00
|
|
|
getter_fallback = tag.getproperty,
|
2016-04-05 09:02:00 +02:00
|
|
|
setter_fallback = tag.setproperty,
|
2016-03-13 08:43:50 +01:00
|
|
|
})
|
|
|
|
|
2012-06-12 20:13:09 +02:00
|
|
|
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
|