awful.tag: Move functions to awful.client and screen

This commit is contained in:
Emmanuel Lepage Vallee 2016-04-05 03:02:00 -04:00
parent 643e35af22
commit dd52f1ce86
21 changed files with 787 additions and 265 deletions

View File

@ -141,7 +141,7 @@ mypromptbox = {}
mylayoutbox = {} mylayoutbox = {}
mytaglist = {} mytaglist = {}
mytaglist.buttons = awful.util.table.join( mytaglist.buttons = awful.util.table.join(
awful.button({ }, 1, awful.tag.viewonly), awful.button({ }, 1, function(t) t:view_only() end),
awful.button({ modkey }, 1, function(t) awful.button({ modkey }, 1, function(t)
if client.focus then if client.focus then
client.focus:move_to_tag(t) client.focus:move_to_tag(t)
@ -153,8 +153,8 @@ mytaglist.buttons = awful.util.table.join(
client.focus:toggle_tag(t) client.focus:toggle_tag(t)
end end
end), end),
awful.button({ }, 4, function(t) awful.tag.viewnext(awful.tag.getscreen(t)) end), awful.button({ }, 4, function(t) awful.tag.viewnext(t.screen) end),
awful.button({ }, 5, function(t) awful.tag.viewprev(awful.tag.getscreen(t)) end) awful.button({ }, 5, function(t) awful.tag.viewprev(t.screen) end)
) )
mytasklist = {} mytasklist = {}
@ -166,8 +166,8 @@ mytasklist.buttons = awful.util.table.join(
-- Without this, the following -- Without this, the following
-- :isvisible() makes no sense -- :isvisible() makes no sense
c.minimized = false c.minimized = false
if not c:isvisible() then if not c:isvisible() and c.first_tag then
awful.tag.viewonly(c.first_tag) c.first_tag:view_only()
end end
-- This will also un-minimize -- This will also un-minimize
-- the client, if needed -- the client, if needed
@ -371,9 +371,9 @@ for i = 1, 9 do
awful.key({ modkey }, "#" .. i + 9, awful.key({ modkey }, "#" .. i + 9,
function () function ()
local screen = awful.screen.focused() local screen = awful.screen.focused()
local tag = awful.tag.gettags(screen)[i] local tag = screen.tags[i]
if tag then if tag then
awful.tag.viewonly(tag) tag:view_only()
end end
end, end,
{description = "view tag #"..i, group = "tag"}), {description = "view tag #"..i, group = "tag"}),
@ -381,7 +381,7 @@ for i = 1, 9 do
awful.key({ modkey, "Control" }, "#" .. i + 9, awful.key({ modkey, "Control" }, "#" .. i + 9,
function () function ()
local screen = awful.screen.focused() local screen = awful.screen.focused()
local tag = awful.tag.gettags(screen)[i] local tag = screen.tags[i]
if tag then if tag then
awful.tag.viewtoggle(tag) awful.tag.viewtoggle(tag)
end end
@ -391,7 +391,7 @@ for i = 1, 9 do
awful.key({ modkey, "Shift" }, "#" .. i + 9, awful.key({ modkey, "Shift" }, "#" .. i + 9,
function () function ()
if client.focus then if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
client.focus:move_to_tag(tag) client.focus:move_to_tag(tag)
end end
@ -402,7 +402,7 @@ for i = 1, 9 do
awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9, awful.key({ modkey, "Control", "Shift" }, "#" .. i + 9,
function () function ()
if client.focus then if client.focus then
local tag = awful.tag.gettags(client.focus.screen)[i] local tag = client.focus.screen.tags[i]
if tag then if tag then
client.focus:toggle_tag(tag) client.focus:toggle_tag(tag)
end end

View File

@ -12,7 +12,6 @@
local client = client local client = client
local aclient = require("awful.client") local aclient = require("awful.client")
local atag = require("awful.tag")
local timer = require("gears.timer") local timer = require("gears.timer")
--- Give focus when clients appear/disappear. --- Give focus when clients appear/disappear.
@ -39,7 +38,7 @@ end
-- --
-- @param tag A tag object -- @param tag A tag object
local function check_focus_tag(t) local function check_focus_tag(t)
local s = atag.getscreen(t) local s = t.screen
if not s then return end if not s then return end
s = screen[s] s = screen[s]
check_focus({ screen = s }) check_focus({ screen = s })

View File

@ -11,7 +11,6 @@
local util = require("awful.util") local util = require("awful.util")
local spawn = require("awful.spawn") local spawn = require("awful.spawn")
local object = require("gears.object") local object = require("gears.object")
local tag = require("awful.tag")
local pairs = pairs local pairs = pairs
local type = type local type = type
local ipairs = ipairs local ipairs = ipairs
@ -102,7 +101,7 @@ function client.object.jump_to(self, merge)
t.selected = true t.selected = true
end end
elseif t then elseif t then
tag.viewonly(t) t:view_only()
end end
end end
@ -111,7 +110,8 @@ end
--- Get visible clients from a screen. --- Get visible clients from a screen.
-- --
-- @function awful.client.visible -- @deprecated awful.client.visible
-- @see screen.clients
-- @tparam[opt] integer|screen s The screen, or nil for all screens. -- @tparam[opt] integer|screen s The screen, or nil for all screens.
-- @tparam[opt=false] boolean stacked Use stacking order? (top to bottom) -- @tparam[opt=false] boolean stacked Use stacking order? (top to bottom)
-- @treturn table A table with all visible clients. -- @treturn table A table with all visible clients.
@ -128,7 +128,8 @@ end
--- Get visible and tiled clients --- Get visible and tiled clients
-- --
-- @function awful.client.tiled -- @deprecated awful.client.tiled
-- @see screen.tiled_clients
-- @tparam integer|screen s The screen, or nil for all screens. -- @tparam integer|screen s The screen, or nil for all screens.
-- @tparam[opt=false] boolean stacked Use stacking order? (top to bottom) -- @tparam[opt=false] boolean stacked Use stacking order? (top to bottom)
-- @treturn table A table with all visible and tiled clients. -- @treturn table A table with all visible and tiled clients.
@ -230,7 +231,7 @@ function client.swap.global_bydirection(dir, sel)
-- swapping to a nonempty screen -- swapping to a nonempty screen
elseif get_screen(sel.screen) ~= get_screen(c.screen) and sel ~= c then elseif get_screen(sel.screen) ~= get_screen(c.screen) and sel ~= c then
sel:move_to_screen(c.screen) sel:move_to_screen(c.screen)
sel:move_to_screen(scr) c:move_to_screen(scr)
end end
screen.focus(sel.screen) screen.focus(sel.screen)
@ -313,20 +314,20 @@ end
-- @param w The relative width. -- @param w The relative width.
-- @param h The relative height. -- @param h The relative height.
-- @client[opt] c The client, otherwise focused one is used. -- @client[opt] c The client, otherwise focused one is used.
-- @see client.move_resize -- @see client.relative_move
function client.moveresize(x, y, w, h, c) function client.moveresize(x, y, w, h, c)
util.deprecate "Use c:move_resize(x, y, w, h) instead of awful.client.moveresize" util.deprecate "Use c:relative_move(x, y, w, h) instead of awful.client.moveresize"
client.object.move_resize(c or capi.client.focus, x, y, w, h) client.object.relative_move(c or capi.client.focus, x, y, w, h)
end end
--- Move/resize a client relative to current coordinates. --- Move/resize a client relative to current coordinates.
-- @function client.move_resize -- @function client.relative_move
-- @see geometry -- @see geometry
-- @tparam[opt=c.x] number x The relative x coordinate. -- @tparam[opt=c.x] number x The relative x coordinate.
-- @tparam[opt=c.y] number y The relative y coordinate. -- @tparam[opt=c.y] number y The relative y coordinate.
-- @tparam[opt=c.width] number w The relative width. -- @tparam[opt=c.width] number w The relative width.
-- @tparam[opt=c.height] number h The relative height. -- @tparam[opt=c.height] number h The relative height.
function client.object.move_resize(self, x, y, w, h) function client.object.relative_move(self, x, y, w, h)
local geometry = self:geometry() local geometry = self:geometry()
geometry['x'] = geometry['x'] + x geometry['x'] = geometry['x'] + x
geometry['y'] = geometry['y'] + y geometry['y'] = geometry['y'] + y
@ -349,7 +350,7 @@ end
-- @function client.move_to_tag -- @function client.move_to_tag
-- @tparam tag target The tag to move the client to. -- @tparam tag target The tag to move the client to.
function client.object.move_to_tag(self, target) function client.object.move_to_tag(self, target)
local s = tag.getscreen(target) local s = target.screen
if self and s then if self and s then
if self == capi.client.focus then if self == capi.client.focus then
self:emit_signal("request::activate", "client.movetotag", {raise=true}) self:emit_signal("request::activate", "client.movetotag", {raise=true})
@ -375,7 +376,7 @@ end
-- @tparam tag target The tag to move the client to. -- @tparam tag target The tag to move the client to.
function client.object.toggle_tag(self, target) function client.object.toggle_tag(self, target)
-- Check that tag and client screen are identical -- Check that tag and client screen are identical
if self and get_screen(self.screen) == get_screen(tag.getscreen(target)) then if self and get_screen(self.screen) == get_screen(target.screen) then
local tags = self:tags() local tags = self:tags()
local index = nil; local index = nil;
for i, v in ipairs(tags) do for i, v in ipairs(tags) do
@ -435,6 +436,31 @@ function client.object.move_to_screen(self, s)
end end
end end
--- Tag a client with the set of current tags.
-- @function client.to_selected_tags
-- @see screen.selected_tags
function client.object.to_selected_tags(self)
local tags = {}
for _, t in ipairs(self:tags()) do
if get_screen(t.screen) == get_screen(self.screen) then
table.insert(tags, t)
end
end
if #tags == 0 then
tags = self.screen.selected_tags
end
if #tags == 0 then
tags = self.screen.tags
end
if #tags ~= 0 then
self:tags(tags)
end
end
--- If a client is marked or not. --- If a client is marked or not.
-- --
-- **Signal:** -- **Signal:**
@ -678,7 +704,7 @@ end
function client.restore(s) function client.restore(s)
s = s or screen.focused() s = s or screen.focused()
local cls = capi.client.get(s) local cls = capi.client.get(s)
local tags = tag.selectedlist(s) local tags = s.selected_tags
for _, c in pairs(cls) do for _, c in pairs(cls) do
local ctags = c:tags() local ctags = c:tags()
if c.minimized then if c.minimized then
@ -739,8 +765,8 @@ function client.idx(c)
end end
end end
local t = tag.selected(c.screen) local t = c.screen.selected_tag
local nmaster = tag.getnmaster(t) local nmaster = t.nmaster
-- This will happen for floating or maximized clients -- This will happen for floating or maximized clients
if not idx then return nil end if not idx then return nil end
@ -755,7 +781,7 @@ function client.idx(c)
-- based on the how the tiling algorithm places clients we calculate -- based on the how the tiling algorithm places clients we calculate
-- the column, we could easily use the for loop in the program but we can -- the column, we could easily use the for loop in the program but we can
-- calculate it. -- calculate it.
local ncol = tag.getncol(t) local ncol = t.ncol
-- minimum number of clients per column -- minimum number of clients per column
local percol = math.floor(nother / ncol) local percol = math.floor(nother / ncol)
-- number of columns with an extra client -- number of columns with an extra client
@ -793,10 +819,10 @@ function client.setwfact(wfact, c)
if not w then return end if not w then return end
local t = tag.selected(c.screen) local t = c.screen.selected_tag
-- n is the number of windows currently visible for which we have to be concerned with the properties -- n is the number of windows currently visible for which we have to be concerned with the properties
local data = tag.getproperty(t, "windowfact") or {} local data = t.windowfact or {}
local colfact = data[w.col] local colfact = data[w.col]
local need_normalize = colfact ~= nil local need_normalize = colfact ~= nil
@ -841,11 +867,11 @@ function client.incwfact(add, c)
c = c or capi.client.focus c = c or capi.client.focus
if not c then return end if not c then return end
local t = tag.selected(c.screen) local t = c.screen.selected_tag
local w = client.idx(c) local w = client.idx(c)
local data = tag.getproperty(t, "windowfact") or {} local data = t.windowfact or {}
local colfact = data[w.col] or {} local colfact = data[w.col] or {}
local curr = colfact[w.idx] or 1 local curr = colfact[w.idx] or 1
colfact[w.idx] = curr + add colfact[w.idx] = curr + add

View File

@ -12,7 +12,6 @@ local client = client
local screen = screen local screen = screen
local ipairs = ipairs local ipairs = ipairs
local math = math local math = math
local atag = require("awful.tag")
local aclient = require("awful.client") local aclient = require("awful.client")
local ewmh = {} local ewmh = {}
@ -182,7 +181,7 @@ function ewmh.tag(c, t)
if not t then if not t then
c.sticky = true c.sticky = true
else else
c.screen = atag.getscreen(t) c.screen = t.screen
c:tags({ t }) c:tags({ t })
end end
end end

View File

@ -20,6 +20,7 @@ local capi = {
} }
local tag = require("awful.tag") local tag = require("awful.tag")
local client = require("awful.client") local client = require("awful.client")
local ascreen = require("awful.screen")
local timer = require("gears.timer") local timer = require("gears.timer")
local function get_screen(s) local function get_screen(s)
@ -63,7 +64,8 @@ local delayed_arrange = {}
-- @param screen The screen. -- @param screen The screen.
-- @return The layout function. -- @return The layout function.
function layout.get(screen) function layout.get(screen)
local t = tag.selected(screen) screen = screen or capi.mouse.screen
local t = get_screen(screen).selected_tag
return tag.getproperty(t, "layout") or layout.suit.floating return tag.getproperty(t, "layout") or layout.suit.floating
end end
@ -77,8 +79,8 @@ function layout.inc(i, s, layouts)
-- this was changed so that 'layouts' can be an optional parameter -- this was changed so that 'layouts' can be an optional parameter
layouts, i, s = i, s, layouts layouts, i, s = i, s, layouts
end end
s = get_screen(s) s = get_screen(s or ascreen.focused())
local t = tag.selected(s) local t = s.selected_tag
layouts = layouts or layout.layouts layouts = layouts or layout.layouts
if t then if t then
local curlayout = layout.get(s) local curlayout = layout.get(s)
@ -108,10 +110,10 @@ end
--- Set the layout function of the current tag. --- Set the layout function of the current tag.
-- @param _layout Layout name. -- @param _layout Layout name.
-- @param t The tag to modify, if null tag.selected() is used. -- @tparam[opt=mouse.screen.selected_tag] tag t The tag to modify.
function layout.set(_layout, t) function layout.set(_layout, t)
t = t or tag.selected() t = t or capi.mouse.screen.selected_tag
tag.setproperty(t, "layout", _layout) t.layout = _layout
end end
--- Get the layout parameters used for the screen --- Get the layout parameters used for the screen
@ -129,13 +131,13 @@ end
-- "geometries" table with client as keys and geometry as value -- "geometries" table with client as keys and geometry as value
function layout.parameters(t, screen) function layout.parameters(t, screen)
screen = get_screen(screen) screen = get_screen(screen)
t = t or tag.selected(screen) t = t or screen.selected_tag
screen = get_screen(t and tag.getscreen(t) or 1) screen = get_screen(t and t.screen or 1)
local p = {} local p = {}
local useless_gap = t and tag.getgap(t, #client.tiled(screen)) or 0 local useless_gap = t and t.gap or 0
p.workarea = screen:get_bounding_geometry { p.workarea = screen:get_bounding_geometry {
honor_padding = true, honor_padding = true,
@ -212,7 +214,7 @@ capi.client.connect_signal("property::screen", function(c, old_screen)
end) end)
local function arrange_tag(t) local function arrange_tag(t)
layout.arrange(tag.getscreen(t)) layout.arrange(t.screen)
end end
capi.screen.add_signal("arrange") capi.screen.add_signal("arrange")

View File

@ -11,6 +11,7 @@
-- Grab environment we need -- Grab environment we need
local ipairs = ipairs local ipairs = ipairs
local math = math local math = math
local capi = {screen = screen}
local tag = require("awful.tag") local tag = require("awful.tag")
--- Actually arrange clients of p.clients for corner layout --- Actually arrange clients of p.clients for corner layout
@ -19,7 +20,7 @@ local tag = require("awful.tag")
-- @param orientation String indicating in which corner is the master window. -- @param orientation String indicating in which corner is the master window.
-- Available values are : NE, NW, SW, SE -- Available values are : NE, NW, SW, SE
local function do_corner(p, orientation) local function do_corner(p, orientation)
local t = p.tag or tag.selected(p.screen) local t = p.tag or capi.screen[p.screen].selected_tag
local wa = p.workarea local wa = p.workarea
local cls = p.clients local cls = p.clients
@ -29,9 +30,9 @@ local function do_corner(p, orientation)
local column = {} local column = {}
local row = {} local row = {}
-- Use the nmaster field of the tag in a cheaty way -- Use the nmaster field of the tag in a cheaty way
local row_privileged = ((tag.getnmaster(tag.selected(cls[1].screen)) % 2) == 0) local row_privileged = ((cls[1].screen.selected_tag.nmaster % 2) == 0)
local master_factor = tag.getmwfact(tag.selected(cls[1].screen)) local master_factor = cls[1].screen.selected_tag.mwfact
master.width = master_factor * wa.width master.width = master_factor * wa.width
master.height = master_factor * wa.height master.height = master_factor * wa.height

View File

@ -10,7 +10,6 @@
-- Grab environment we need -- Grab environment we need
local ipairs = ipairs local ipairs = ipairs
local math = math local math = math
local tag = require("awful.tag")
local capi = local capi =
{ {
client = client, client = client,
@ -40,7 +39,7 @@ function magnifier.mouse_resize_handler(c, corner, x, y)
-- New master width factor -- New master width factor
local mwfact = dist / maxdist_pow local mwfact = dist / maxdist_pow
tag.setmwfact(math.min(math.max(0.01, mwfact), 0.99), tag.selected(c.screen)) c.screen.selected_tag.mwfact = math.min(math.max(0.01, mwfact), 0.99)
return true return true
end end
end end
@ -53,8 +52,8 @@ function magnifier.arrange(p)
local area = p.workarea local area = p.workarea
local cls = p.clients local cls = p.clients
local focus = p.focus or capi.client.focus local focus = p.focus or capi.client.focus
local t = p.tag or tag.selected(p.screen) local t = p.tag or capi.screen[p.screen].selected_tag
local mwfact = tag.getmwfact(t) local mwfact = t.mwfact
local fidx local fidx
-- Check that the focused window is on the right screen -- Check that the focused window is on the right screen

View File

@ -29,7 +29,7 @@ tile.resize_jump_to_corner = true
local function mouse_resize_handler(c, _, _, _, orientation) local function mouse_resize_handler(c, _, _, _, orientation)
orientation = orientation or "tile" orientation = orientation or "tile"
local wa = capi.screen[c.screen].workarea local wa = capi.screen[c.screen].workarea
local mwfact = tag.getmwfact() local mwfact = c.screen.selected_tag.mwfact
local cursor local cursor
local g = c:geometry() local g = c:geometry()
local offset = 0 local offset = 0
@ -126,7 +126,7 @@ local function mouse_resize_handler(c, _, _, _, orientation)
wfact = wfact_x wfact = wfact_x
end end
tag.setmwfact(math.min(math.max(new_mwfact, 0.01), 0.99), tag.selected(c.screen)) c.screen.selected_tag.mwfact = math.min(math.max(new_mwfact, 0.01), 0.99)
client.setwfact(math.min(math.max(wfact,0.01), 0.99), c) client.setwfact(math.min(math.max(wfact,0.01), 0.99), c)
return true return true
end end
@ -195,7 +195,7 @@ local function tile_group(gs, cls, wa, orientation, fact, group)
end end
local function do_tile(param, orientation) local function do_tile(param, orientation)
local t = param.tag or tag.selected(param.screen) local t = param.tag or capi.screen[param.screen].selected_tag
orientation = orientation or "right" orientation = orientation or "right"
-- This handles all different orientations. -- This handles all different orientations.
@ -208,12 +208,12 @@ local function do_tile(param, orientation)
local gs = param.geometries local gs = param.geometries
local cls = param.clients local cls = param.clients
local nmaster = math.min(tag.getnmaster(t), #cls) local nmaster = math.min(t.nmaster, #cls)
local nother = math.max(#cls - nmaster,0) local nother = math.max(#cls - nmaster,0)
local mwfact = tag.getmwfact(t) local mwfact = t.mwfact
local wa = param.workarea local wa = param.workarea
local ncol = tag.getncol(t) local ncol = t.ncol
local data = tag.getdata(t).windowfact local data = tag.getdata(t).windowfact
@ -229,7 +229,7 @@ local function do_tile(param, orientation)
place_master = false place_master = false
end end
local grow_master = tag.getmfpol(t) == "expand" local grow_master = t.master_fill_policy == "expand"
-- this was easier than writing functions because there is a lot of data we need -- this was easier than writing functions because there is a lot of data we need
for _ = 1,2 do for _ = 1,2 do
if place_master and nmaster > 0 then if place_master and nmaster > 0 then

View File

@ -609,7 +609,7 @@ end
-- terms[i] = -- terms[i] =
-- {c.name, -- {c.name,
-- function() -- function()
-- awful.tag.viewonly(c.first_tag) -- c.first_tag:view_only()
-- client.focus = c -- client.focus = c
-- end, -- end,
-- c.icon -- c.icon

View File

@ -229,8 +229,8 @@ function mouse.client.dragtotag.border(c)
capi.mouse.coords({ x = wa.x + 1 }) capi.mouse.coords({ x = wa.x + 1 })
end end
if not button_down then if not button_down then
local tags = tag.gettags(c.screen) local tags = c.screen.tags
local t = tag.selected() local t = c.screen.selected_tag
local idx local idx
for i, v in ipairs(tags) do for i, v in ipairs(tags) do
if v == t then if v == t then

View File

@ -13,7 +13,6 @@ local table = table
local type = type local type = type
local ipairs = ipairs local ipairs = ipairs
local pairs = pairs local pairs = pairs
local atag = require("awful.tag")
local rules = {} local rules = {}
@ -199,10 +198,10 @@ function rules.execute(c, props, callbacks)
value = value(c) value = value(c)
end end
if property == "tag" then if property == "tag" then
c.screen = atag.getscreen(value) c.screen = value.screen
c:tags({ value }) c:tags({ value })
elseif property == "switchtotag" and value and props.tag then elseif property == "switchtotag" and value and props.tag then
atag.viewonly(props.tag) props.tag:view_only()
elseif property == "height" or property == "width" or elseif property == "height" or property == "width" or
property == "x" or property == "y" then property == "x" or property == "y" then
local geo = c:geometry(); local geo = c:geometry();

View File

@ -306,8 +306,13 @@ end
-- Minimized and unmanaged clients are not included in this list as they are -- Minimized and unmanaged clients are not included in this list as they are
-- technically not on the screen. -- technically not on the screen.
-- --
-- The clients on tags currently not visible are not part of this list.
--
-- @property clients -- @property clients
-- @param table The clients list, ordered top to bottom -- @param table The clients list, ordered top to bottom
-- @see all_clients
-- @see hidden_clients
-- @see client.get
function screen.object.get_clients(s) function screen.object.get_clients(s)
local cls = capi.client.get(s, true) local cls = capi.client.get(s, true)
@ -322,6 +327,44 @@ end
function screen.object.set_clients() end function screen.object.set_clients() end
--- Get the list of the clients assigned to the screen but not currently
-- visible.
--
-- This include minimized clients and clients on hidden tags.
--
-- @property hidden_clients
-- @param table The clients list, ordered top to bottom
-- @see clients
-- @see all_clients
-- @see client.get
function screen.object.get_hidden_clients(s)
local cls = capi.client.get(s, true)
local vcls = {}
for _, c in pairs(cls) do
if not c:isvisible() then
table.insert(vcls, c)
end
end
return vcls
end
function screen.object.set_hidden_clients() end
--- Get all clients assigned to the screen.
--
-- @property all_clients
-- @param table The clients list, ordered top to bottom
-- @see clients
-- @see hidden_clients
-- @see client.get
function screen.object.get_all_clients(s)
return capi.client.get(s, true)
end
function screen.object.set_all_clients() end
--- Get the list of the screen tiled clients. --- Get the list of the screen tiled clients.
-- --
-- Same as s.clients, but excluding: -- Same as s.clients, but excluding:
@ -368,6 +411,71 @@ function screen.disconnect_for_each_screen(func)
capi.screen.disconnect_signal("added", func) capi.screen.disconnect_signal("added", func)
end end
--- A list of all tags on the screen.
--
-- This property is read only, use `tag.screen`, `awful.tag.add`, `awful.tag.new`
-- or `t:delete()` to alter this list.
--
-- @property tags
-- @param table
-- @treturn table A table with all available tags
function screen.object.get_tags(s, unordered)
local tags = {}
for _, t in ipairs(root.tags()) do
if get_screen(t.screen) == s then
table.insert(tags, t)
end
end
-- Avoid infinite loop, + save some time
if not unordered then
table.sort(tags, function(a, b)
return (a.index or 9999) < (b.index or 9999)
end)
end
return tags
end
function screen.object.set_tags() end
--- A list of all selected tags on the screen.
-- @property selected_tags
-- @param table
-- @treturn table A table with all selected tags.
-- @see tag.selected
-- @see client.to_selected_tags
function screen.object.get_selected_tags(s)
local tags = screen.object.get_tags(s, true)
local vtags = {}
for _, t in pairs(tags) do
if t.selected then
vtags[#vtags + 1] = t
end
end
return vtags
end
function screen.object.set_selected_tags() end
--- The first selected tag.
-- @property selected_tag
-- @param table
-- @treturn ?tag The first selected tag or nil
-- @see tag.selected
-- @see selected_tags
function screen.object.get_selected_tag(s)
return screen.object.get_selected_tags(s)[1]
end
function screen.object.set_selected_tag() end
--- When the tag history changed. --- When the tag history changed.
-- @signal tag::history::update -- @signal tag::history::update

File diff suppressed because it is too large Load Diff

View File

@ -31,7 +31,7 @@ local function update(w, screen)
end end
local function update_from_tag(t) local function update_from_tag(t)
local screen = get_screen(tag.getscreen(t)) local screen = get_screen(t.screen)
local w = boxes[screen] local w = boxes[screen]
if w then if w then
update(w, screen) update(w, screen)

View File

@ -111,8 +111,8 @@ function taglist.taglist_label(t, args)
text = text .. "</span>" text = text .. "</span>"
end end
if not taglist_disable_icon then if not taglist_disable_icon then
if tag.geticon(t) then if t.icon then
icon = surface.load(tag.geticon(t)) icon = surface.load(t.icon)
end end
end end
@ -121,7 +121,7 @@ end
local function taglist_update(s, w, buttons, filter, data, style, update_function) local function taglist_update(s, w, buttons, filter, data, style, update_function)
local tags = {} local tags = {}
for _, t in ipairs(tag.gettags(s)) do for _, t in ipairs(s.tags) do
if not tag.getproperty(t, "hide") and filter(t) then if not tag.getproperty(t, "hide") and filter(t) then
table.insert(tags, t) table.insert(tags, t)
end end
@ -185,7 +185,7 @@ function taglist.new(screen, filter, buttons, style, update_function, base_widge
end end
end end
local uc = function (c) return u(c.screen) end local uc = function (c) return u(c.screen) end
local ut = function (t) return u(tag.getscreen(t)) end local ut = function (t) return u(t.screen) end
capi.client.connect_signal("focus", uc) capi.client.connect_signal("focus", uc)
capi.client.connect_signal("unfocus", uc) capi.client.connect_signal("unfocus", uc)
tag.attached_connect_signal(nil, "property::selected", ut) tag.attached_connect_signal(nil, "property::selected", ut)

View File

@ -276,7 +276,7 @@ function tasklist.filter.currenttags(c, screen)
if get_screen(c.screen) ~= screen then return false end if get_screen(c.screen) ~= screen then return false end
-- Include sticky client too -- Include sticky client too
if c.sticky then return true end if c.sticky then return true end
local tags = tag.gettags(screen) local tags = screen.tags
for _, t in ipairs(tags) do for _, t in ipairs(tags) do
if t.selected then if t.selected then
local ctags = c:tags() local ctags = c:tags()
@ -302,7 +302,7 @@ function tasklist.filter.minimizedcurrenttags(c, screen)
if not c.minimized then return false end if not c.minimized then return false end
-- Include sticky client -- Include sticky client
if c.sticky then return true end if c.sticky then return true end
local tags = tag.gettags(screen) local tags = screen.tags
for _, t in ipairs(tags) do for _, t in ipairs(tags) do
-- Select only minimized clients -- Select only minimized clients
if t.selected then if t.selected then

View File

@ -8,7 +8,7 @@ local function _shim_fake_class()
local meta = { local meta = {
__index = function()end, __index = function()end,
__new_index = function()end, __newindex = function()end,
} }
obj._connect_signal = obj.connect_signal obj._connect_signal = obj.connect_signal
@ -28,7 +28,7 @@ local function _shim_fake_class()
end end
function obj.set_newindex_miss_handler(handler) function obj.set_newindex_miss_handler(handler)
meta.__new_index = handler meta.__newindex = handler
end end
function obj.emit_signal(name, c, ...) function obj.emit_signal(name, c, ...)

View File

@ -2,7 +2,7 @@ local gears_obj = require("gears.object")
local clients = {} local clients = {}
local client = awesome._shim_fake_class() local client, meta = awesome._shim_fake_class()
local function add_signals(c) local function add_signals(c)
c:add_signal("property::width") c:add_signal("property::width")
@ -119,7 +119,10 @@ function client.gen_fake(args)
client.emit_signal("manage", ret) client.emit_signal("manage", ret)
assert(not args.screen or (args.screen == ret.screen)) assert(not args.screen or (args.screen == ret.screen))
return ret return setmetatable(ret, {
__index = function(...) return meta.__index(...) end,
__newindex = function(...) return meta.__newindex(...) end
})
end end
function client.get(s) function client.get(s)

View File

@ -8,6 +8,7 @@ local function create_screen(args)
local s = gears_obj() local s = gears_obj()
s:add_signal("property::workarea") s:add_signal("property::workarea")
s:add_signal("property::index")
s:add_signal("padding") s:add_signal("padding")
-- Copy the geo in case the args are mutated -- Copy the geo in case the args are mutated
@ -46,7 +47,7 @@ local function create_screen(args)
return meta.__index(_, key) return meta.__index(_, key)
end end
end, end,
__new_index = function(...) return meta.__new_index(...) end __newindex = function(...) return meta.__newindex(...) end
}) })
end end

View File

@ -35,7 +35,7 @@ local function new_tag(_, args)
return setmetatable(ret, { return setmetatable(ret, {
__index = function(...) return meta.__index(...) end, __index = function(...) return meta.__index(...) end,
__new_index = function(...) return meta.__new_index(...) end __newindex = function(...) return meta.__newindex(...) end
}) })
end end

View File

@ -32,7 +32,7 @@ local steps = {
if count == 1 then -- Setup. if count == 1 then -- Setup.
urgent_cb_done = false urgent_cb_done = false
-- Select first tag. -- Select first tag.
awful.tag.viewonly(tags[awful.screen.focused()][1]) tags[awful.screen.focused()][1]:view_only()
runner.add_to_default_rules({ rule = { class = "XTerm" }, runner.add_to_default_rules({ rule = { class = "XTerm" },
properties = { tag = tags[awful.screen.focused()][2], focus = true } }) properties = { tag = tags[awful.screen.focused()][2], focus = true } })
@ -72,7 +72,7 @@ local steps = {
urgent_cb_done = false urgent_cb_done = false
-- Select first tag. -- Select first tag.
awful.tag.viewonly(tags[awful.screen.focused()][1]) tags[awful.screen.focused()][1]:view_only()
runner.add_to_default_rules({ rule = { class = "XTerm" }, runner.add_to_default_rules({ rule = { class = "XTerm" },
properties = { tag = tags[awful.screen.focused()][2], focus = true, switchtotag = true }}) properties = { tag = tags[awful.screen.focused()][2], focus = true, switchtotag = true }})