Support screen objects in more of awful
This commit makes the code in awful.widget work with screen objects. Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
parent
2792fe731e
commit
b3f43f9110
|
@ -8,24 +8,30 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
local setmetatable = setmetatable
|
||||
local capi = { screen = screen }
|
||||
local layout = require("awful.layout")
|
||||
local tooltip = require("awful.tooltip")
|
||||
local tag = require("awful.tag")
|
||||
local beautiful = require("beautiful")
|
||||
local imagebox = require("wibox.widget.imagebox")
|
||||
|
||||
local function get_screen(s)
|
||||
return s and capi.screen[s]
|
||||
end
|
||||
|
||||
local layoutbox = { mt = {} }
|
||||
|
||||
local boxes = nil
|
||||
|
||||
local function update(w, screen)
|
||||
local name = layout.getname(layout.get(screen))
|
||||
screen = get_screen(screen)
|
||||
local name = layout.getname(layout.get(screen and screen.index))
|
||||
w._layoutbox_tooltip:set_text(name or "[no name]")
|
||||
w:set_image(name and beautiful["layout_" .. name])
|
||||
end
|
||||
|
||||
local function update_from_tag(t)
|
||||
local screen = tag.getscreen(t)
|
||||
local screen = get_screen(tag.getscreen(t))
|
||||
local w = boxes[screen]
|
||||
if w then
|
||||
update(w, screen)
|
||||
|
@ -37,7 +43,7 @@ end
|
|||
-- @param screen The screen number that the layout will be represented for.
|
||||
-- @return An imagebox widget configured as a layoutbox.
|
||||
function layoutbox.new(screen)
|
||||
screen = screen or 1
|
||||
screen = get_screen(screen or 1)
|
||||
|
||||
-- Do we already have the update callbacks registered?
|
||||
if boxes == nil then
|
||||
|
|
|
@ -23,6 +23,10 @@ local fixed = require("wibox.layout.fixed")
|
|||
local surface = require("gears.surface")
|
||||
local timer = require("gears.timer")
|
||||
|
||||
local function get_screen(s)
|
||||
return s and capi.screen[s]
|
||||
end
|
||||
|
||||
local taglist = { mt = {} }
|
||||
taglist.filter = {}
|
||||
|
||||
|
@ -153,6 +157,7 @@ end
|
|||
-- @param[opt] base_widget.squares_resize True or false to resize squares.
|
||||
-- @param base_widget.font The font.
|
||||
function taglist.new(screen, filter, buttons, style, update_function, base_widget)
|
||||
screen = get_screen(screen)
|
||||
local uf = update_function or common.list_update
|
||||
local w = base_widget or fixed.horizontal()
|
||||
|
||||
|
@ -172,7 +177,7 @@ function taglist.new(screen, filter, buttons, style, update_function, base_widge
|
|||
if instances == nil then
|
||||
instances = {}
|
||||
local function u(s)
|
||||
local i = instances[s]
|
||||
local i = instances[get_screen(s)]
|
||||
if i then
|
||||
for _, tlist in pairs(i) do
|
||||
tlist._do_taglist_update()
|
||||
|
|
|
@ -21,6 +21,10 @@ local tag = require("awful.tag")
|
|||
local flex = require("wibox.layout.flex")
|
||||
local timer = require("gears.timer")
|
||||
|
||||
local function get_screen(s)
|
||||
return s and screen[s]
|
||||
end
|
||||
|
||||
local tasklist = { mt = {} }
|
||||
|
||||
local instances
|
||||
|
@ -165,6 +169,7 @@ end
|
|||
-- @param base_widget.maximized_vertical Symbol to use for clients that have been vertically maximized.
|
||||
-- @param base_widget.font The font.
|
||||
function tasklist.new(screen, filter, buttons, style, update_function, base_widget)
|
||||
screen = get_screen(screen)
|
||||
local uf = update_function or common.list_update
|
||||
local w = base_widget or flex.horizontal()
|
||||
|
||||
|
@ -187,7 +192,7 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg
|
|||
if instances == nil then
|
||||
instances = {}
|
||||
local function us(s)
|
||||
local i = instances[s]
|
||||
local i = instances[get_screen(s)]
|
||||
if i then
|
||||
for _, tlist in pairs(i) do
|
||||
tlist._do_tasklist_update()
|
||||
|
@ -256,7 +261,7 @@ end
|
|||
-- @return true if c is on screen, false otherwise
|
||||
function tasklist.filter.alltags(c, screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
return c.screen == screen
|
||||
return get_screen(c.screen) == get_screen(screen)
|
||||
end
|
||||
|
||||
--- Filtering function to include only the clients from currently selected tags.
|
||||
|
@ -264,11 +269,12 @@ end
|
|||
-- @param screen The screen we are drawing on.
|
||||
-- @return true if c is in a selected tag on screen, false otherwise
|
||||
function tasklist.filter.currenttags(c, screen)
|
||||
screen = get_screen(screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
if c.screen ~= screen then return false end
|
||||
if get_screen(c.screen) ~= screen then return false end
|
||||
-- Include sticky client too
|
||||
if c.sticky then return true end
|
||||
local tags = tag.gettags(screen)
|
||||
local tags = tag.gettags(screen.index)
|
||||
for _, t in ipairs(tags) do
|
||||
if t.selected then
|
||||
local ctags = c:tags()
|
||||
|
@ -287,13 +293,14 @@ end
|
|||
-- @param screen The screen we are drawing on.
|
||||
-- @return true if c is in a selected tag on screen and is minimized, false otherwise
|
||||
function tasklist.filter.minimizedcurrenttags(c, screen)
|
||||
screen = get_screen(screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
if c.screen ~= screen then return false end
|
||||
if get_screen(c.screen) ~= screen then return false end
|
||||
-- Check client is minimized
|
||||
if not c.minimized then return false end
|
||||
-- Include sticky client
|
||||
if c.sticky then return true end
|
||||
local tags = tag.gettags(screen)
|
||||
local tags = tag.gettags(screen.index)
|
||||
for _, t in ipairs(tags) do
|
||||
-- Select only minimized clients
|
||||
if t.selected then
|
||||
|
@ -314,7 +321,7 @@ end
|
|||
-- @return true if c is focused on screen, false otherwise
|
||||
function tasklist.filter.focused(c, screen)
|
||||
-- Only print client on the same screen as this widget
|
||||
return c.screen == screen and capi.client.focus == c
|
||||
return get_screen(c.screen) == get_screen(screen) and capi.client.focus == c
|
||||
end
|
||||
|
||||
function tasklist.mt:__call(...)
|
||||
|
|
Loading…
Reference in New Issue