Merge pull request #687 from psychon/fix-harmless-luacheck-warnings

Fix harmless luacheck warnings
This commit is contained in:
Daniel Hahler 2016-02-11 23:36:56 +01:00
commit 66b93ffded
56 changed files with 331 additions and 403 deletions

View File

@ -79,7 +79,7 @@ install:
script: script:
- export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION" - export CMAKE_ARGS="-DLUA_LIBRARY=${LUALIBRARY} -DLUA_INCLUDE_DIR=${LUAINCLUDE} -D OVERRIDE_VERSION=$AWESOME_VERSION"
- make && sudo env PATH=$PATH make install && awesome --version && tests/run.sh - make && sudo env PATH=$PATH make install && awesome --version && make check
after_success: after_success:
# Push updated API docs for relevant branches, e.g. non-PRs builds on master. # Push updated API docs for relevant branches, e.g. non-PRs builds on master.

View File

@ -297,7 +297,7 @@ globalkeys = awful.util.table.join(
awful.key({ modkey, "Control" }, "n", awful.key({ modkey, "Control" }, "n",
function () function ()
c = awful.client.restore() local c = awful.client.restore()
-- Focus restored client -- Focus restored client
if c then if c then
client.focus = c client.focus = c

View File

@ -11,7 +11,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local client = client local client = client
local screen = screen
local aclient = require("awful.client") local aclient = require("awful.client")
local atag = require("awful.tag") local atag = require("awful.tag")
local timer = require("gears.timer") local timer = require("gears.timer")

View File

@ -44,10 +44,10 @@ function button.new(mod, _button, press, release)
ret[#ret + 1] = capi.button({ modifiers = util.table.join(mod, set), ret[#ret + 1] = capi.button({ modifiers = util.table.join(mod, set),
button = _button }) button = _button })
if press then if press then
ret[#ret]:connect_signal("press", function(bobj, ...) press(...) end) ret[#ret]:connect_signal("press", function(_, ...) press(...) end)
end end
if release then if release then
ret[#ret]:connect_signal("release", function (bobj, ...) release(...) end) ret[#ret]:connect_signal("release", function (_, ...) release(...) end)
end end
end end
return ret return ret

View File

@ -29,7 +29,7 @@ local capi =
local screen local screen
do do
screen = setmetatable({}, { screen = setmetatable({}, {
__index = function(t, k) __index = function(_, k)
screen = require("awful.screen") screen = require("awful.screen")
return screen[k] return screen[k]
end, end,
@ -91,7 +91,7 @@ function client.urgent.get()
else else
-- fallback behaviour: iterate through clients and get the first urgent -- fallback behaviour: iterate through clients and get the first urgent
local clients = capi.client.get() local clients = capi.client.get()
for k, cl in pairs(clients) do for _, cl in pairs(clients) do
if cl.urgent then if cl.urgent then
return cl return cl
end end
@ -171,21 +171,21 @@ end
--- Get the latest focused client for a screen in history. --- Get the latest focused client for a screen in history.
-- --
-- @tparam int screen The screen number to look for. -- @tparam int s The screen number to look for.
-- @tparam int idx The index: 0 will return first candidate, -- @tparam int idx The index: 0 will return first candidate,
-- 1 will return second, etc. -- 1 will return second, etc.
-- @tparam function filter An optional filter. If no client is found in the -- @tparam function filter An optional filter. If no client is found in the
-- first iteration, client.focus.filter is used by default to get any -- first iteration, client.focus.filter is used by default to get any
-- client. -- client.
-- @treturn client.object A client. -- @treturn client.object A client.
function client.focus.history.get(screen, idx, filter) function client.focus.history.get(s, idx, filter)
-- When this counter is equal to idx, we return the client -- When this counter is equal to idx, we return the client
local counter = 0 local counter = 0
local vc = client.visible(screen, true) local vc = client.visible(s, true)
for k, c in ipairs(client.data.focus) do for _, c in ipairs(client.data.focus) do
if c.screen == screen then if c.screen == s then
if not filter or filter(c) then if not filter or filter(c) then
for j, vcc in ipairs(vc) do for _, vcc in ipairs(vc) do
if vcc == c then if vcc == c then
if counter == idx then if counter == idx then
return c return c
@ -200,9 +200,9 @@ function client.focus.history.get(screen, idx, filter)
end end
-- Argh nobody found in history, give the first one visible if there is one -- Argh nobody found in history, give the first one visible if there is one
-- that passes the filter. -- that passes the filter.
local filter = filter or client.focus.filter filter = filter or client.focus.filter
if counter == 0 then if counter == 0 then
for k, v in ipairs(vc) do for _, v in ipairs(vc) do
if filter(v) then if filter(v) then
return v return v
end end
@ -223,13 +223,13 @@ end
--- Get visible clients from a screen. --- Get visible clients from a screen.
-- --
-- @tparam[opt] integer screen The screen number, or nil for all screens. -- @tparam[opt] integer s The screen number, 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.
function client.visible(screen, stacked) function client.visible(s, stacked)
local cls = capi.client.get(screen, stacked) local cls = capi.client.get(s, stacked)
local vcls = {} local vcls = {}
for k, c in pairs(cls) do for _, c in pairs(cls) do
if c:isvisible() then if c:isvisible() then
table.insert(vcls, c) table.insert(vcls, c)
end end
@ -239,14 +239,14 @@ end
--- Get visible and tiled clients --- Get visible and tiled clients
-- --
-- @tparam integer screen The screen number, or nil for all screens. -- @tparam integer s The screen number, 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.
function client.tiled(screen, stacked) function client.tiled(s, stacked)
local clients = client.visible(screen, stacked) local clients = client.visible(s, stacked)
local tclients = {} local tclients = {}
-- Remove floating clients -- Remove floating clients
for k, c in pairs(clients) do for _, c in pairs(clients) do
if not client.floating.get(c) if not client.floating.get(c)
and not c.fullscreen and not c.fullscreen
and not c.maximized_vertical and not c.maximized_vertical
@ -261,7 +261,7 @@ end
-- If no client is passed, the focused client will be used. -- If no client is passed, the focused client will be used.
-- --
-- @tparam int i The index. Use 1 to get the next, -1 to get the previous. -- @tparam int i The index. Use 1 to get the next, -1 to get the previous.
-- @client[opt] c The client. -- @client[opt] sel The client.
-- @tparam[opt=false] boolean stacked Use stacking order? (top to bottom) -- @tparam[opt=false] boolean stacked Use stacking order? (top to bottom)
-- @return A client, or nil if no client is available. -- @return A client, or nil if no client is available.
-- --
@ -269,15 +269,15 @@ end
-- awful.client.next(1) -- awful.client.next(1)
-- -- focus the previous -- -- focus the previous
-- awful.client.next(-1) -- awful.client.next(-1)
function client.next(i, c, stacked) function client.next(i, sel, stacked)
-- Get currently focused client -- Get currently focused client
local sel = c or capi.client.focus sel = sel or capi.client.focus
if sel then if sel then
-- Get all visible clients -- Get all visible clients
local cls = client.visible(sel.screen, stacked) local cls = client.visible(sel.screen, stacked)
local fcls = {} local fcls = {}
-- Remove all non-normal clients -- Remove all non-normal clients
for idx, c in ipairs(cls) do for _, c in ipairs(cls) do
if client.focus.filter(c) or c == sel then if client.focus.filter(c) or c == sel then
table.insert(fcls, c) table.insert(fcls, c)
end end
@ -385,9 +385,9 @@ end
--- Swap a client with another client in the given direction. Swaps across screens. --- Swap a client with another client in the given direction. Swaps across screens.
-- @param dir The direction, can be either "up", "down", "left" or "right". -- @param dir The direction, can be either "up", "down", "left" or "right".
-- @client[opt] c The client. -- @client[opt] sel The client.
function client.swap.global_bydirection(dir, c) function client.swap.global_bydirection(dir, sel)
local sel = c or capi.client.focus sel = sel or capi.client.focus
local scr = sel and sel.screen or screen.focused() local scr = sel and sel.screen or screen.focused()
if sel then if sel then
@ -463,7 +463,7 @@ end
-- @client c The window to set as master. -- @client c The window to set as master.
function client.setmaster(c) function client.setmaster(c)
local cls = util.table.reverse(capi.client.get(c.screen)) local cls = util.table.reverse(capi.client.get(c.screen))
for k, v in pairs(cls) do for _, v in pairs(cls) do
c:swap(v) c:swap(v)
end end
end end
@ -472,7 +472,7 @@ end
-- @client c The window to set as slave. -- @client c The window to set as slave.
function client.setslave(c) function client.setslave(c)
local cls = capi.client.get(c.screen) local cls = capi.client.get(c.screen)
for k, v in pairs(cls) do for _, v in pairs(cls) do
c:swap(v) c:swap(v)
end end
end end
@ -565,7 +565,7 @@ end
function client.mark(c) function client.mark(c)
local cl = c or capi.client.focus local cl = c or capi.client.focus
if cl then if cl then
for k, v in pairs(client.data.marked) do for _, v in pairs(client.data.marked) do
if cl == v then if cl == v then
return false return false
end end
@ -601,7 +601,7 @@ end
function client.ismarked(c) function client.ismarked(c)
local cl = c or capi.client.focus local cl = c or capi.client.focus
if cl then if cl then
for k, v in pairs(client.data.marked) do for _, v in pairs(client.data.marked) do
if cl == v then if cl == v then
return true return true
end end
@ -613,8 +613,7 @@ end
--- Toggle a client as marked. --- Toggle a client as marked.
-- @client c The client to toggle mark. -- @client c The client to toggle mark.
function client.togglemarked(c) function client.togglemarked(c)
local cl = c or capi.client.focus c = c or capi.client.focus
if not client.mark(c) then if not client.mark(c) then
client.unmark(c) client.unmark(c)
end end
@ -623,11 +622,11 @@ end
--- Return the marked clients and empty the marked table. --- Return the marked clients and empty the marked table.
-- @return A table with all marked clients. -- @return A table with all marked clients.
function client.getmarked() function client.getmarked()
for k, v in pairs(client.data.marked) do for _, v in pairs(client.data.marked) do
v:emit_signal("unmarked") v:emit_signal("unmarked")
end end
t = client.data.marked local t = client.data.marked
client.data.marked = {} client.data.marked = {}
return t return t
end end
@ -637,7 +636,7 @@ end
-- @client c A client. -- @client c A client.
-- @param s True or false. -- @param s True or false.
function client.floating.set(c, s) function client.floating.set(c, s)
local c = c or capi.client.focus c = c or capi.client.focus
if c and client.property.get(c, "floating") ~= s then if c and client.property.get(c, "floating") ~= s then
client.property.set(c, "floating", s) client.property.set(c, "floating", s)
local scr = c.screen local scr = c.screen
@ -655,12 +654,12 @@ local function store_floating_geometry(c)
end end
-- Store the initial client geometry. -- Store the initial client geometry.
capi.client.connect_signal("new", function(c) capi.client.connect_signal("new", function(cl)
local function store_init_geometry(c) local function store_init_geometry(c)
client.property.set(c, "floating_geometry", c:geometry()) client.property.set(c, "floating_geometry", c:geometry())
c:disconnect_signal("property::border_width", store_init_geometry) c:disconnect_signal("property::border_width", store_init_geometry)
end end
c:connect_signal("property::border_width", store_init_geometry) cl:connect_signal("property::border_width", store_init_geometry)
end) end)
capi.client.connect_signal("property::geometry", store_floating_geometry) capi.client.connect_signal("property::geometry", store_floating_geometry)
@ -668,7 +667,7 @@ capi.client.connect_signal("property::geometry", store_floating_geometry)
--- Return if a client has a fixe size or not. --- Return if a client has a fixe size or not.
-- @client c The client. -- @client c The client.
function client.isfixed(c) function client.isfixed(c)
local 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 h = c.size_hints local h = c.size_hints
if h.min_width and h.max_width if h.min_width and h.max_width
@ -688,7 +687,7 @@ end
-- did not set them manually. For example, windows with a type different than -- did not set them manually. For example, windows with a type different than
-- normal. -- normal.
function client.floating.get(c) function client.floating.get(c)
local c = c or capi.client.focus c = c or capi.client.focus
if c then if c then
local value = client.property.get(c, "floating") local value = client.property.get(c, "floating")
if value ~= nil then if value ~= nil then
@ -708,7 +707,7 @@ end
--- Toggle the floating state of a client between 'auto' and 'true'. --- Toggle the floating state of a client between 'auto' and 'true'.
-- @client c A client. -- @client c A client.
function client.floating.toggle(c) function client.floating.toggle(c)
local c = c or capi.client.focus c = c or capi.client.focus
-- If it has been set to floating -- If it has been set to floating
if client.floating.get(c) then if client.floating.get(c) then
client.floating.set(c, false) client.floating.set(c, false)
@ -730,11 +729,10 @@ 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 = tag.selectedlist(s)
local mcls = {} for _, c in pairs(cls) do
for k, c in pairs(cls) do
local ctags = c:tags() local ctags = c:tags()
if c.minimized then if c.minimized then
for k, t in ipairs(tags) do for _, t in ipairs(tags) do
if util.table.hasitem(ctags, t) then if util.table.hasitem(ctags, t) then
c.minimized = false c.minimized = false
return c return c
@ -749,7 +747,7 @@ end
-- @param set the set of numbers to normalize -- @param set the set of numbers to normalize
-- @param num the number of numbers to normalize -- @param num the number of numbers to normalize
local function normalize(set, num) local function normalize(set, num)
local num = num or #set num = num or #set
local total = 0 local total = 0
if num then if num then
for i = 1,num do for i = 1,num do
@ -759,7 +757,7 @@ local function normalize(set, num)
set[i] = set[i] / total set[i] = set[i] / total
end end
else else
for i,v in ipairs(set) do for _,v in ipairs(set) do
total = total + v total = total + v
end end
@ -777,7 +775,7 @@ end
-- @return idx index of the client in the column -- @return idx index of the client in the column
-- @return num the number of visible clients in the column -- @return num the number of visible clients in the column
function client.idx(c) function client.idx(c)
local c = c or capi.client.focus c = c or capi.client.focus
if not c then return end if not c then return end
-- Only check the tiled clients, the others un irrelevant -- Only check the tiled clients, the others un irrelevant
@ -836,7 +834,7 @@ end
-- @client c the client -- @client c the client
function client.setwfact(wfact, c) function client.setwfact(wfact, c)
-- get the currently selected window -- get the currently selected window
local c = c or capi.client.focus c = c or capi.client.focus
if not c or not c:isvisible() then return end if not c or not c:isvisible() then return end
local w = client.idx(c) local w = client.idx(c)
@ -845,9 +843,6 @@ function client.setwfact(wfact, c)
local t = tag.selected(c.screen) local t = tag.selected(c.screen)
local cls = client.tiled(tag.getscreen(t))
local nmaster = tag.getnmaster(t)
-- 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 = tag.getproperty(t, "windowfact") or {}
local colfact = data[w.col] local colfact = data[w.col]
@ -890,17 +885,16 @@ end
-- @param add amount to increase the client's window -- @param add amount to increase the client's window
-- @client c the client -- @client c the client
function client.incwfact(add, c) function client.incwfact(add, c)
local 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 = tag.selected(c.screen)
local w = client.idx(c) local w = client.idx(c)
local nmaster = tag.getnmaster(t)
local data = tag.getproperty(t, "windowfact") or {} local data = tag.getproperty(t, "windowfact") or {}
local colfact = data[w.col] or {} local colfact = data[w.col] or {}
curr = colfact[w.idx] or 1 local curr = colfact[w.idx] or 1
colfact[w.idx] = curr + add colfact[w.idx] = curr + add
-- keep our ratios normalized -- keep our ratios normalized
@ -982,15 +976,15 @@ end
--- Set a client property to be persistent across restarts (via X properties). --- Set a client property to be persistent across restarts (via X properties).
-- --
-- @param prop The property name. -- @param prop The property name.
-- @param type The type (used for register_xproperty). -- @param kind The type (used for register_xproperty).
-- One of "string", "number" or "boolean". -- One of "string", "number" or "boolean".
function client.property.persist(prop, type) function client.property.persist(prop, kind)
local xprop = "awful.client.property." .. prop local xprop = "awful.client.property." .. prop
capi.awesome.register_xproperty(xprop, type) capi.awesome.register_xproperty(xprop, kind)
client.data.persistent_properties_registered[prop] = true client.data.persistent_properties_registered[prop] = true
-- Make already-set properties persistent -- Make already-set properties persistent
for c, tab in pairs(client.data.properties) do for c in pairs(client.data.properties) do
if client.data.properties[c] and client.data.properties[c][prop] ~= nil then if client.data.properties[c] and client.data.properties[c][prop] ~= nil then
c:set_xproperty(xprop, client.data.properties[c][prop]) c:set_xproperty(xprop, client.data.properties[c][prop])
end end
@ -1017,7 +1011,7 @@ end
function client.iterate(filter, start, s) function client.iterate(filter, start, s)
local clients = capi.client.get(s) local clients = capi.client.get(s)
local focused = capi.client.focus local focused = capi.client.focus
local start = start or util.table.hasitem(clients, focused) start = start or util.table.hasitem(clients, focused)
return util.table.iterate(clients, filter, start) return util.table.iterate(clients, filter, start)
end end
@ -1041,13 +1035,13 @@ function client.run_or_raise(cmd, matcher, merge)
local findex = util.table.hasitem(clients, capi.client.focus) or 1 local findex = util.table.hasitem(clients, capi.client.focus) or 1
local start = util.cycle(#clients, findex + 1) local start = util.cycle(#clients, findex + 1)
for c in client.iterate(matcher, start) do local c = client.iterate(matcher, start)()
if c then
client.jumpto(c, merge) client.jumpto(c, merge)
return else
end
-- client not found, spawn it -- client not found, spawn it
spawn(cmd) spawn(cmd)
end
end end
--- Get a matching transient_for client (if any). --- Get a matching transient_for client (if any).

View File

@ -20,11 +20,11 @@ shape.update = {}
--- Get one of a client's shapes and transform it to include window decorations --- Get one of a client's shapes and transform it to include window decorations
-- @client c The client whose shape should be retrieved -- @client c The client whose shape should be retrieved
-- @tparam string shape Either "bounding" or "clip" -- @tparam string shape_name Either "bounding" or "clip"
function shape.get_transformed(c, shape) function shape.get_transformed(c, shape_name)
local border = shape == "bounding" and c.border_width or 0 local border = shape_name == "bounding" and c.border_width or 0
local shape = surface.load_silently(c["client_shape_" .. shape], false) local shape_img = surface.load_silently(c["client_shape_" .. shape_name], false)
if not shape then return end if not shape_img then return end
-- Get information about various sizes on the client -- Get information about various sizes on the client
local geom = c:geometry() local geom = c:geometry()
@ -44,7 +44,7 @@ function shape.get_transformed(c, shape)
-- Draw the client's shape in the middle -- Draw the client's shape in the middle
cr:set_operator(cairo.Operator.SOURCE) cr:set_operator(cairo.Operator.SOURCE)
cr:set_source_surface(shape, border + l, border + t) cr:set_source_surface(shape_img, border + l, border + t)
cr:rectangle(border + l, border + t, geom.width - l - r, geom.height - t - b) cr:rectangle(border + l, border + t, geom.width - l - r, geom.height - t - b)
cr:fill() cr:fill()

View File

@ -18,7 +18,6 @@ local math = math
local print = print local print = print
local pairs = pairs local pairs = pairs
local string = string local string = string
local util = require("awful.util")
local completion = {} local completion = {}
@ -128,7 +127,6 @@ function completion.shell(command, cur_pos, ncomp, shell)
end end
local c, err = io.popen(shell_cmd .. " | sort -u") local c, err = io.popen(shell_cmd .. " | sort -u")
local output = {} local output = {}
i = 0
if c then if c then
while true do while true do
local line = c:read("*line") local line = c:read("*line")
@ -168,7 +166,7 @@ end
-- @param ncomp The number of yet requested completion using current text. -- @param ncomp The number of yet requested completion using current text.
-- @param keywords The keywords table uised for completion. -- @param keywords The keywords table uised for completion.
-- @return The new match, the new cursor position, the table of all matches. -- @return The new match, the new cursor position, the table of all matches.
function completion.generic(text, cur_pos, ncomp, keywords) function completion.generic(text, cur_pos, ncomp, keywords) -- luacheck: no unused args
-- The keywords table may be empty -- The keywords table may be empty
if #keywords == 0 then if #keywords == 0 then
return text, #text + 1 return text, #text + 1

View File

@ -70,7 +70,6 @@ local function fullscreen(window, set)
if set then if set then
store_geometry(window, "fullscreen") store_geometry(window, "fullscreen")
data[window].fullscreen.border_width = window.border_width data[window].fullscreen.border_width = window.border_width
local g = screen[window.screen].geometry
window:geometry(screen[window.screen].geometry) window:geometry(screen[window.screen].geometry)
window.border_width = 0 window.border_width = 0
elseif data[window] and data[window].fullscreen then elseif data[window] and data[window].fullscreen then
@ -163,7 +162,7 @@ end
-- @tparam string context The context where this signal was used. -- @tparam string context The context where this signal was used.
-- @tparam[opt] table hints A table with additional hints: -- @tparam[opt] table hints A table with additional hints:
-- @tparam[opt=false] boolean hints.raise should the client be raised? -- @tparam[opt=false] boolean hints.raise should the client be raised?
function ewmh.activate(c, context, hints) function ewmh.activate(c, context, hints) -- luacheck: no unused args
if c:isvisible() then if c:isvisible() then
client.focus = c client.focus = c
end end

View File

@ -159,7 +159,7 @@ local function sort_hotkeys(target)
for group, _ in pairs(group_list) do for group, _ in pairs(group_list) do
if target[group] then if target[group] then
local sorted_table = {} local sorted_table = {}
for index, key in pairs(target[group]) do for _, key in pairs(target[group]) do
table.insert(sorted_table, key) table.insert(sorted_table, key)
end end
table.sort( table.sort(

View File

@ -10,7 +10,7 @@
-- TODO: This is a hack for backwards-compatibility with 3.5, remove! -- TODO: This is a hack for backwards-compatibility with 3.5, remove!
local util = require("awful.util") local util = require("awful.util")
local gtimer = require("gears.timer") local gtimer = require("gears.timer")
function timer(...) function timer(...) -- luacheck: ignore
util.deprecate("gears.timer") util.deprecate("gears.timer")
return gtimer(...) return gtimer(...)
end end

View File

@ -54,10 +54,10 @@ function key.new(mod, _key, press, release, data)
ret[#ret + 1] = capi.key({ modifiers = util.table.join(mod, set), ret[#ret + 1] = capi.key({ modifiers = util.table.join(mod, set),
key = _key }) key = _key })
if press then if press then
ret[#ret]:connect_signal("press", function(kobj, ...) press(...) end) ret[#ret]:connect_signal("press", function(_, ...) press(...) end)
end end
if release then if release then
ret[#ret]:connect_signal("release", function(kobj, ...) release(...) end) ret[#ret]:connect_signal("release", function(_, ...) release(...) end)
end end
end end

View File

@ -20,7 +20,7 @@ local keygrabbing = false
local function grabber(mod, key, event) local function grabber(mod, key, event)
for i, keygrabber_function in ipairs(grabbers) do for _, keygrabber_function in ipairs(grabbers) do
-- continue if the grabber explicitly returns false -- continue if the grabber explicitly returns false
if keygrabber_function(mod, key, event) ~= false then if keygrabber_function(mod, key, event) ~= false then
break break

View File

@ -75,7 +75,7 @@ function layout.inc(i, s, layouts)
layouts, i, s = i, s, layouts layouts, i, s = i, s, layouts
end end
local t = tag.selected(s) local t = tag.selected(s)
local 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)
local curindex local curindex
@ -192,7 +192,7 @@ end
-- @param _layout The layout. -- @param _layout The layout.
-- @return The layout name. -- @return The layout name.
function layout.getname(_layout) function layout.getname(_layout)
local _layout = _layout or layout.get() _layout = _layout or layout.get()
return _layout.name return _layout.name
end end

View File

@ -109,7 +109,7 @@ local function do_corner(p, orientation)
end end
for i, c in ipairs(cls) do for i, c in ipairs(cls) do
local g = nil local g
-- Handle master window -- Handle master window
if i == 1 then if i == 1 then
g = { g = {

View File

@ -24,7 +24,7 @@ local function do_fair(p, orientation)
end end
if #cls > 0 then if #cls > 0 then
local rows, cols = 0, 0 local rows, cols
if #cls == 2 then if #cls == 2 then
rows, cols = 1, 2 rows, cols = 1, 2
else else
@ -36,11 +36,11 @@ local function do_fair(p, orientation)
k = k - 1 k = k - 1
local g = {} local g = {}
local row, col = 0, 0 local row, col
row = k % rows row = k % rows
col = math.floor(k / rows) col = math.floor(k / rows)
local lrows, lcols = 0, 0 local lrows, lcols
if k >= rows * cols - rows then if k >= rows * cols - rows then
lrows = #cls - (rows * cols - rows) lrows = #cls - (rows * cols - rows)
lcols = cols lcols = cols

View File

@ -8,7 +8,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- Grab environment we need -- Grab environment we need
local math = math
local ipairs = ipairs local ipairs = ipairs
local capi = local capi =
{ {
@ -44,7 +43,7 @@ function floating.mouse_resize_handler(c, corner, x, y)
capi.mousegrabber.run(function (_mouse) capi.mousegrabber.run(function (_mouse)
_mouse.x = _mouse.x + coordinates_delta.x _mouse.x = _mouse.x + coordinates_delta.x
_mouse.y = _mouse.y + coordinates_delta.y _mouse.y = _mouse.y + coordinates_delta.y
for k, v in ipairs(_mouse.buttons) do for _, v in ipairs(_mouse.buttons) do
if v then if v then
local ng local ng
prev_coords = { x =_mouse.x, y = _mouse.y } prev_coords = { x =_mouse.x, y = _mouse.y }

View File

@ -32,7 +32,7 @@ function magnifier.mouse_resize_handler(c, corner, x, y)
local prev_coords = {} local prev_coords = {}
capi.mousegrabber.run(function (_mouse) capi.mousegrabber.run(function (_mouse)
for k, v in ipairs(_mouse.buttons) do for _, v in ipairs(_mouse.buttons) do
if v then if v then
prev_coords = { x =_mouse.x, y = _mouse.y } prev_coords = { x =_mouse.x, y = _mouse.y }
local dx = center_x - _mouse.x local dx = center_x - _mouse.x
@ -126,13 +126,12 @@ function magnifier.arrange(p)
-- Then move clients that are after focused client. -- Then move clients that are after focused client.
-- So the next focused window will be the one at the top of the screen. -- So the next focused window will be the one at the top of the screen.
for k = 1, fidx - 1 do for k = 1, fidx - 1 do
local g = { p.geometries[cls[k]] = {
x = geometry.x, x = geometry.x,
y = geometry.y, y = geometry.y,
width = geometry.width, width = geometry.width,
height = geometry.height height = geometry.height
} }
p.geometries[cls[k]] = g
geometry.y = geometry.y + geometry.height geometry.y = geometry.y + geometry.height
end end
end end

View File

@ -9,7 +9,6 @@
-- Grab environment we need -- Grab environment we need
local pairs = pairs local pairs = pairs
local client = require("awful.client")
local max = {} local max = {}
@ -22,7 +21,7 @@ local function fmax(p, fs)
area = p.workarea area = p.workarea
end end
for k, c in pairs(p.clients) do for _, c in pairs(p.clients) do
local g = { local g = {
x = area.x, x = area.x,
y = area.y, y = area.y,

View File

@ -26,8 +26,8 @@ local tile = {}
--- Jump mouse cursor to the client's corner when resizing it. --- Jump mouse cursor to the client's corner when resizing it.
tile.resize_jump_to_corner = true tile.resize_jump_to_corner = true
local function mouse_resize_handler(c, corner, x, y, orientation) local function mouse_resize_handler(c, _, _, _, orientation)
local 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 = tag.getmwfact()
local cursor local cursor
@ -87,47 +87,46 @@ local function mouse_resize_handler(c, corner, x, y, orientation)
capi.mousegrabber.run(function (_mouse) capi.mousegrabber.run(function (_mouse)
_mouse.x = _mouse.x + coordinates_delta.x _mouse.x = _mouse.x + coordinates_delta.x
_mouse.y = _mouse.y + coordinates_delta.y _mouse.y = _mouse.y + coordinates_delta.y
for k, v in ipairs(_mouse.buttons) do for _, v in ipairs(_mouse.buttons) do
if v then if v then
prev_coords = { x =_mouse.x, y = _mouse.y } prev_coords = { x =_mouse.x, y = _mouse.y }
local fact_x = (_mouse.x - wa.x) / wa.width local fact_x = (_mouse.x - wa.x) / wa.width
local fact_y = (_mouse.y - wa.y) / wa.height local fact_y = (_mouse.y - wa.y) / wa.height
local mwfact local new_mwfact
local g = c:geometry()
local geom = c:geometry()
-- we have to make sure we're not on the last visible client where we have to use different settings. -- we have to make sure we're not on the last visible client where we have to use different settings.
local wfact local wfact
local wfact_x, wfact_y local wfact_x, wfact_y
if (g.y+g.height+15) > (wa.y+wa.height) then if (geom.y+geom.height+15) > (wa.y+wa.height) then
wfact_y = (g.y + g.height - _mouse.y) / wa.height wfact_y = (geom.y + geom.height - _mouse.y) / wa.height
else else
wfact_y = (_mouse.y - g.y) / wa.height wfact_y = (_mouse.y - geom.y) / wa.height
end end
if (g.x+g.width+15) > (wa.x+wa.width) then if (geom.x+geom.width+15) > (wa.x+wa.width) then
wfact_x = (g.x + g.width - _mouse.x) / wa.width wfact_x = (geom.x + geom.width - _mouse.x) / wa.width
else else
wfact_x = (_mouse.x - g.x) / wa.width wfact_x = (_mouse.x - geom.x) / wa.width
end end
if orientation == "tile" then if orientation == "tile" then
mwfact = fact_x new_mwfact = fact_x
wfact = wfact_y wfact = wfact_y
elseif orientation == "left" then elseif orientation == "left" then
mwfact = 1 - fact_x new_mwfact = 1 - fact_x
wfact = wfact_y wfact = wfact_y
elseif orientation == "bottom" then elseif orientation == "bottom" then
mwfact = fact_y new_mwfact = fact_y
wfact = wfact_x wfact = wfact_x
else else
mwfact = 1 - fact_y new_mwfact = 1 - fact_y
wfact = wfact_x wfact = wfact_x
end end
tag.setmwfact(math.min(math.max(mwfact, 0.01), 0.99), tag.selected(c.screen)) tag.setmwfact(math.min(math.max(new_mwfact, 0.01), 0.99), tag.selected(c.screen))
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
@ -200,15 +199,11 @@ local function do_tile(param, orientation)
orientation = orientation or "right" orientation = orientation or "right"
-- This handles all different orientations. -- This handles all different orientations.
local height = "height"
local width = "width" local width = "width"
local x = "x" local x = "x"
local y = "y"
if orientation == "top" or orientation == "bottom" then if orientation == "top" or orientation == "bottom" then
height = "width"
width = "height" width = "height"
x = "y" x = "y"
y = "x"
end end
local gs = param.geometries local gs = param.geometries
@ -236,7 +231,7 @@ local function do_tile(param, orientation)
local grow_master = tag.getmfpol(t) == "expand" local grow_master = tag.getmfpol(t) == "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 d = 1,2 do for _ = 1,2 do
if place_master and nmaster > 0 then if place_master and nmaster > 0 then
local size = wa[width] local size = wa[width]
if nother > 0 or not grow_master then if nother > 0 or not grow_master then

View File

@ -99,7 +99,7 @@ end
local function item_position(_menu, child) local function item_position(_menu, child)
local in_dir, other, a, b = 0, 0, "height", "width" local a, b = "height", "width"
local dir = _menu.layout.dir or "y" local dir = _menu.layout.dir or "y"
if dir == "x" then a, b = b, a end if dir == "x" then a, b = b, a end
@ -191,7 +191,7 @@ local function check_access_key(_menu, key)
end end
local function grabber(_menu, mod, key, event) local function grabber(_menu, _, key, event)
if event ~= "press" then return end if event ~= "press" then return end
local sel = _menu.sel or 0 local sel = _menu.sel or 0
@ -499,10 +499,10 @@ end
-------------------------------------------------------------------------------- --------------------------------------------------------------------------------
--- Default awful.menu.entry constructor --- Default awful.menu.entry constructor
-- @param parent The parent menu -- @param parent The parent menu (TODO: This is apparently unused)
-- @param args the item params -- @param args the item params
-- @return table with 'widget', 'cmd', 'akey' and all the properties the user wants to change -- @return table with 'widget', 'cmd', 'akey' and all the properties the user wants to change
function menu.entry(parent, args) function menu.entry(parent, args) -- luacheck: no unused args
args = args or {} args = args or {}
args.text = args[1] or args.text or "" args.text = args[1] or args.text or ""
args.cmd = args[2] or args.cmd args.cmd = args[2] or args.cmd
@ -651,9 +651,9 @@ function menu.new(args, parent)
end end
-- Create items -- Create items
for i, v in ipairs(args) do _menu:add(v) end for _, v in ipairs(args) do _menu:add(v) end
if args.items then if args.items then
for i, v in pairs(args.items) do _menu:add(v) end for _, v in pairs(args.items) do _menu:add(v) end
end end
_menu._keygrabber = function (...) _menu._keygrabber = function (...)

View File

@ -38,12 +38,9 @@
-- @module awful.mouse.finder -- @module awful.mouse.finder
------------------------------------------------------------------------- -------------------------------------------------------------------------
local mouse = mouse
local screen = screen
local timer = require("gears.timer") local timer = require("gears.timer")
local wibox = require("wibox") local wibox = require("wibox")
local a_placement = require("awful.placement") local a_placement = require("awful.placement")
local a_wibox = require("awful.wibox")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local setmetatable = setmetatable local setmetatable = setmetatable

View File

@ -11,7 +11,6 @@
local layout = require("awful.layout") local layout = require("awful.layout")
local tag = require("awful.tag") local tag = require("awful.tag")
local aclient = require("awful.client") local aclient = require("awful.client")
local widget = require("awful.widget")
local awibox = require("awful.wibox") local awibox = require("awful.wibox")
local util = require("awful.util") local util = require("awful.util")
local type = type local type = type
@ -99,14 +98,13 @@ end
-- @param fixed_x True if the client isn't allowed to move in the x direction. -- @param fixed_x True if the client isn't allowed to move in the x direction.
-- @param fixed_y True if the client isn't allowed to move in the y direction. -- @param fixed_y True if the client isn't allowed to move in the y direction.
function mouse.client.snap(c, snap, x, y, fixed_x, fixed_y) function mouse.client.snap(c, snap, x, y, fixed_x, fixed_y)
local snap = snap or 8 snap = snap or 8
local c = c or mouse.client.focus c = c or mouse.client.focus
local cur_geom = c:geometry() local cur_geom = c:geometry()
local geom = c:geometry() local geom = c:geometry()
geom.width = geom.width + (2 * c.border_width) geom.width = geom.width + (2 * c.border_width)
geom.height = geom.height + (2 * c.border_width) geom.height = geom.height + (2 * c.border_width)
local edge = "none" local edge
local edge2 = "none"
geom.x = x or geom.x geom.x = x or geom.x
geom.y = y or geom.y geom.y = y or geom.y
@ -134,7 +132,7 @@ function mouse.client.snap(c, snap, x, y, fixed_x, fixed_y)
geom.x = geom.x - (2 * c.border_width) geom.x = geom.x - (2 * c.border_width)
geom.y = geom.y - (2 * c.border_width) geom.y = geom.y - (2 * c.border_width)
for k, snapper in ipairs(aclient.visible(c.screen)) do for _, snapper in ipairs(aclient.visible(c.screen)) do
if snapper ~= c then if snapper ~= c then
geom = snap_outside(geom, snapper:geometry(), snap) geom = snap_outside(geom, snapper:geometry(), snap)
end end
@ -159,7 +157,7 @@ end
-- when moving the client has been finished. The client -- when moving the client has been finished. The client
-- that has been moved will be passed to that function. -- that has been moved will be passed to that function.
function mouse.client.move(c, snap, finished_cb) function mouse.client.move(c, snap, finished_cb)
local c = c or capi.client.focus c = c or capi.client.focus
if not c if not c
or c.fullscreen or c.fullscreen
@ -178,7 +176,7 @@ function mouse.client.move(c, snap, finished_cb)
local fixed_y = c.maximized_vertical local fixed_y = c.maximized_vertical
capi.mousegrabber.run(function (_mouse) capi.mousegrabber.run(function (_mouse)
for k, v in ipairs(_mouse.buttons) do for _, v in ipairs(_mouse.buttons) do
if v then if v then
local lay = layout.get(c.screen) local lay = layout.get(c.screen)
if lay == layout.suit.floating or aclient.floating.get(c) then if lay == layout.suit.floating or aclient.floating.get(c) then
@ -259,7 +257,7 @@ end
--- Move the wibox under the cursor --- Move the wibox under the cursor
--@param w The wibox to move, or none to use that under the pointer --@param w The wibox to move, or none to use that under the pointer
function mouse.wibox.move(w) function mouse.wibox.move(w)
local w = w or mouse.wibox_under_pointer() w = w or mouse.wibox_under_pointer()
if not w then return end if not w then return end
local offset = { local offset = {
@ -286,7 +284,7 @@ function mouse.wibox.move(w)
end end
w.screen = capi.mouse.screen w.screen = capi.mouse.screen
end end
for k, v in ipairs(_mouse.buttons) do for _, v in ipairs(_mouse.buttons) do
if v then button_down = true end if v then button_down = true end
end end
if not button_down then if not button_down then
@ -302,7 +300,7 @@ end
-- bottom_right. Default is auto, and auto find the nearest corner. -- bottom_right. Default is auto, and auto find the nearest corner.
-- @return Actual used corner and x and y coordinates. -- @return Actual used corner and x and y coordinates.
function mouse.client.corner(c, corner) function mouse.client.corner(c, corner)
local 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 g = c:geometry() local g = c:geometry()
@ -346,7 +344,7 @@ end
-- @param c The client to resize, or the focused one by default. -- @param c The client to resize, or the focused one by default.
-- @param corner The corner to grab on resize. Auto detected by default. -- @param corner The corner to grab on resize. Auto detected by default.
function mouse.client.resize(c, corner) function mouse.client.resize(c, corner)
local c = c or capi.client.focus c = c or capi.client.focus
if not c then return end if not c then return end
@ -358,12 +356,12 @@ function mouse.client.resize(c, corner)
end end
local lay = layout.get(c.screen) local lay = layout.get(c.screen)
local corner, x, y = mouse.client.corner(c, corner) local corner2, x, y = mouse.client.corner(c, corner)
if lay == layout.suit.floating or aclient.floating.get(c) then if lay == layout.suit.floating or aclient.floating.get(c) then
return layout.suit.floating.mouse_resize_handler(c, corner, x, y) return layout.suit.floating.mouse_resize_handler(c, corner2, x, y)
elseif lay.mouse_resize_handler then elseif lay.mouse_resize_handler then
return lay.mouse_resize_handler(c, corner, x, y) return lay.mouse_resize_handler(c, corner2, x, y)
end end
end end

View File

@ -119,9 +119,9 @@ end
-- @tparam[opt=client's screen] integer screen The screen. -- @tparam[opt=client's screen] integer screen The screen.
-- @treturn table The new client geometry. -- @treturn table The new client geometry.
function placement.no_offscreen(c, screen) function placement.no_offscreen(c, screen)
local c = c or capi.client.focus c = c or capi.client.focus
local geometry = get_area(c) local geometry = get_area(c)
local screen = screen or c.screen or a_screen.getbycoord(geometry.x, geometry.y) screen = screen or c.screen or a_screen.getbycoord(geometry.x, geometry.y)
local screen_geometry = capi.screen[screen].workarea local screen_geometry = capi.screen[screen].workarea
if geometry.x + geometry.width > screen_geometry.x + screen_geometry.width then if geometry.x + geometry.width > screen_geometry.x + screen_geometry.width then
@ -149,7 +149,7 @@ function placement.no_overlap(c)
local cls = client.visible(screen) local cls = client.visible(screen)
local curlay = layout.get() local curlay = layout.get()
local areas = { capi.screen[screen].workarea } local areas = { capi.screen[screen].workarea }
for i, cl in pairs(cls) do for _, cl in pairs(cls) do
if cl ~= c and cl.type ~= "desktop" and (client.floating.get(cl) or curlay == layout.suit.floating) then if cl ~= c and cl.type ~= "desktop" and (client.floating.get(cl) or curlay == layout.suit.floating) then
areas = area_remove(areas, get_area(cl)) areas = area_remove(areas, get_area(cl))
end end
@ -158,7 +158,7 @@ function placement.no_overlap(c)
-- Look for available space -- Look for available space
local found = false local found = false
local new = { x = geometry.x, y = geometry.y, width = 0, height = 0 } local new = { x = geometry.x, y = geometry.y, width = 0, height = 0 }
for i, r in ipairs(areas) do for _, r in ipairs(areas) do
if r.width >= geometry.width if r.width >= geometry.width
and r.height >= geometry.height and r.height >= geometry.height
and r.width * r.height > new.width * new.height then and r.width * r.height > new.width * new.height then
@ -179,7 +179,7 @@ function placement.no_overlap(c)
-- We did not find an area with enough space for our size: -- We did not find an area with enough space for our size:
-- just take the biggest available one and go in -- just take the biggest available one and go in
if not found then if not found then
for i, r in ipairs(areas) do for _, r in ipairs(areas) do
if r.width * r.height > new.width * new.height then if r.width * r.height > new.width * new.height then
new = r new = r
end end
@ -197,7 +197,7 @@ end
-- @param c The client. -- @param c The client.
-- @return The new client geometry. -- @return The new client geometry.
function placement.under_mouse(c) function placement.under_mouse(c)
local c = c or capi.client.focus c = c or capi.client.focus
local c_geometry = get_area(c) local c_geometry = get_area(c)
local m_coords = capi.mouse.coords() local m_coords = capi.mouse.coords()
return c:geometry({ x = m_coords.x - c_geometry.width / 2, return c:geometry({ x = m_coords.x - c_geometry.width / 2,
@ -220,8 +220,10 @@ function placement.next_to_mouse(c, offset)
local m_coords = capi.mouse.coords() local m_coords = capi.mouse.coords()
local screen_geometry = capi.screen[capi.mouse.screen].workarea local screen_geometry = capi.screen[capi.mouse.screen].workarea
local x, y
-- Prefer it to be on the right. -- Prefer it to be on the right.
local x = m_coords.x + offset x = m_coords.x + offset
if x + c_width > screen_geometry.width then if x + c_width > screen_geometry.width then
-- Then to the left. -- Then to the left.
x = m_coords.x - c_width - offset x = m_coords.x - c_width - offset
@ -245,7 +247,7 @@ end
-- @param[opt] p The parent (nil for screen centering). -- @param[opt] p The parent (nil for screen centering).
-- @return The new client geometry. -- @return The new client geometry.
function placement.centered(c, p) function placement.centered(c, p)
local c = c or capi.client.focus c = c or capi.client.focus
local c_geometry = get_area(c) local c_geometry = get_area(c)
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y) local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
local s_geometry local s_geometry
@ -263,7 +265,7 @@ end
-- @param[opt] p The parent (nil for screen centering). -- @param[opt] p The parent (nil for screen centering).
-- @return The new client geometry. -- @return The new client geometry.
function placement.center_horizontal(c, p) function placement.center_horizontal(c, p)
local c = c or capi.client.focus c = c or capi.client.focus
local c_geometry = get_area(c) local c_geometry = get_area(c)
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y) local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
local s_geometry local s_geometry
@ -280,7 +282,7 @@ end
-- @param[opt] p The parent (nil for screen centering). -- @param[opt] p The parent (nil for screen centering).
-- @return The new client geometry. -- @return The new client geometry.
function placement.center_vertical(c, p) function placement.center_vertical(c, p)
local c = c or capi.client.focus c = c or capi.client.focus
local c_geometry = get_area(c) local c_geometry = get_area(c)
local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y) local screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
local s_geometry local s_geometry

View File

@ -290,9 +290,9 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
end end
-- Build the hook map -- Build the hook map
for k,v in ipairs(args.hooks or {}) do for _,v in ipairs(args.hooks or {}) do
if #v == 3 then if #v == 3 then
local mods,key,callback = unpack(v) local _,key,callback = unpack(v)
if type(callback) == "function" then if type(callback) == "function" then
hooks[key] = hooks[key] or {} hooks[key] = hooks[key] or {}
hooks[key][#hooks[key]+1] = v hooks[key][#hooks[key]+1] = v
@ -332,7 +332,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
if event ~= "press" then return end if event ~= "press" then return end
-- Convert index array to hash table -- Convert index array to hash table
local mod = {} local mod = {}
for k, v in ipairs(modifiers) do mod[v] = true end for _, v in ipairs(modifiers) do mod[v] = true end
-- Call the user specified callback. If it returns true as -- Call the user specified callback. If it returns true as
-- the first result then return from the function. Treat the -- the first result then return from the function. Treat the
@ -360,10 +360,10 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
-- User defined cases -- User defined cases
if hooks[key] then if hooks[key] then
for k,v in ipairs(hooks[key]) do for _,v in ipairs(hooks[key]) do
if #modifiers == #v[1] then if #modifiers == #v[1] then
local match = true local match = true
for k2,v2 in ipairs(v[1]) do for _,v2 in ipairs(v[1]) do
match = match and mod[v2] match = match and mod[v2]
end end
if match or #modifiers == 0 then if match or #modifiers == 0 then
@ -489,19 +489,19 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
elseif key == "w" or key == "BackSpace" then elseif key == "w" or key == "BackSpace" then
local wstart = 1 local wstart = 1
local wend = 1 local wend = 1
local cword_start = 1 local cword_start_pos = 1
local cword_end = 1 local cword_end_pos = 1
while wend < cur_pos do while wend < cur_pos do
wend = command:find("[{[(,.:;_-+=@/ ]", wstart) wend = command:find("[{[(,.:;_-+=@/ ]", wstart)
if not wend then wend = #command + 1 end if not wend then wend = #command + 1 end
if cur_pos >= wstart and cur_pos <= wend + 1 then if cur_pos >= wstart and cur_pos <= wend + 1 then
cword_start = wstart cword_start_pos = wstart
cword_end = cur_pos - 1 cword_end_pos = cur_pos - 1
break break
end end
wstart = wend + 1 wstart = wend + 1
end end
command = command:sub(1, cword_start - 1) .. command:sub(cword_end + 1) command = command:sub(1, cword_start_pos - 1) .. command:sub(cword_end_pos + 1)
cur_pos = cword_start cur_pos = cword_start
elseif key == "Delete" then elseif key == "Delete" then
-- delete from history only if: -- delete from history only if:
@ -531,7 +531,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
elseif key == "d" then elseif key == "d" then
command = command:sub(1, cur_pos - 1) .. command:sub(cword_end(command, cur_pos)) command = command:sub(1, cur_pos - 1) .. command:sub(cword_end(command, cur_pos))
elseif key == "BackSpace" then elseif key == "BackSpace" then
wstart = cword_start(command, cur_pos) local wstart = cword_start(command, cur_pos)
command = command:sub(1, wstart - 1) .. command:sub(cur_pos) command = command:sub(1, wstart - 1) .. command:sub(cur_pos)
cur_pos = wstart cur_pos = wstart
end end

View File

@ -9,11 +9,11 @@
-- Grab environment we need -- Grab environment we need
require("awful.dbus") require("awful.dbus")
local load = loadstring or load -- v5.1 - loadstring, v5.2 - load local load = loadstring or load -- luacheck: globals loadstring (compatibility with Lua 5.1)
local tostring = tostring local tostring = tostring
local ipairs = ipairs local ipairs = ipairs
local table = table local table = table
local unpack = unpack or table.unpack -- v5.1: unpack, v5.2: table.unpack local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
local dbus = dbus local dbus = dbus
local type = type local type = type

View File

@ -213,6 +213,7 @@ function rules.execute(c, props, callbacks)
c:geometry(geo); c:geometry(geo);
elseif property == "focus" then elseif property == "focus" then
-- This will be handled below -- This will be handled below
(function() end)() -- I haven't found a nice way to silence luacheck here
elseif type(c[property]) == "function" then elseif type(c[property]) == "function" then
c[property](c, value) c[property](c, value)
else else
@ -222,7 +223,7 @@ function rules.execute(c, props, callbacks)
-- Apply all callbacks. -- Apply all callbacks.
if callbacks then if callbacks then
for i, callback in pairs(callbacks) do for _, callback in pairs(callbacks) do
callback(c) callback(c)
end end
end end

View File

@ -110,7 +110,7 @@ function spawn.with_line_callback(cmd, callbacks)
local stdout_callback, stderr_callback, done_callback, exit_callback = local stdout_callback, stderr_callback, done_callback, exit_callback =
callbacks.stdout, callbacks.stderr, callbacks.output_done, callbacks.exit callbacks.stdout, callbacks.stderr, callbacks.output_done, callbacks.exit
local have_stdout, have_stderr = stdout_callback ~= nil, stderr_callback ~= nil local have_stdout, have_stderr = stdout_callback ~= nil, stderr_callback ~= nil
local pid, sn_id, stdin, stdout, stderr = capi.awesome.spawn(cmd, local pid, _, stdin, stdout, stderr = capi.awesome.spawn(cmd,
false, false, have_stdout, have_stderr, exit_callback) false, false, have_stdout, have_stderr, exit_callback)
if type(pid) == "string" then if type(pid) == "string" then
-- Error -- Error

View File

@ -10,9 +10,7 @@
-- Grab environment we need -- Grab environment we need
local util = require("awful.util") local util = require("awful.util")
local ascreen = require("awful.screen") local ascreen = require("awful.screen")
local timer = require("gears.timer")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local tostring = tostring
local pairs = pairs local pairs = pairs
local ipairs = ipairs local ipairs = ipairs
local table = table local table = table
@ -46,7 +44,7 @@ tag.history.limit = 20
-- @param target_tag The tag that should be moved. If null, the currently -- @param target_tag The tag that should be moved. If null, the currently
-- selected tag is used. -- selected tag is used.
function tag.move(new_index, target_tag) function tag.move(new_index, target_tag)
local target_tag = target_tag or tag.selected() target_tag = target_tag or tag.selected()
local scr = tag.getscreen(target_tag) local scr = tag.getscreen(target_tag)
local tmp_tags = tag.gettags(scr) local tmp_tags = tag.gettags(scr)
@ -121,7 +119,7 @@ end
-- @param layout The layout or layout table to set for this tags by default. -- @param layout The layout or layout table to set for this tags by default.
-- @return A table with all created tags. -- @return A table with all created tags.
function tag.new(names, screen, layout) function tag.new(names, screen, layout)
local screen = screen or 1 screen = screen or 1
local tags = {} local tags = {}
for id, name in ipairs(names) do for id, name in ipairs(names) do
table.insert(tags, id, tag.add(name, {screen = screen, table.insert(tags, id, tag.add(name, {screen = screen,
@ -158,7 +156,7 @@ end
-- history or select the first tag on the screen. -- history or select the first tag on the screen.
function tag.delete(target_tag, fallback_tag) function tag.delete(target_tag, fallback_tag)
-- abort if no tag is passed or currently selected -- abort if no tag is passed or currently selected
local target_tag = target_tag or tag.selected() target_tag = target_tag or tag.selected()
if target_tag == nil or target_tag.activated == false then return end if target_tag == nil or target_tag.activated == false then return end
local target_scr = tag.getscreen(target_tag) local target_scr = tag.getscreen(target_tag)
@ -167,7 +165,6 @@ function tag.delete(target_tag, fallback_tag)
local ntags = #tags local ntags = #tags
-- We can't use the target tag as a fallback. -- We can't use the target tag as a fallback.
local fallback_tag = fallback_tag
if fallback_tag == target_tag then return end if fallback_tag == target_tag then return end
-- No fallback_tag provided, try and get one. -- No fallback_tag provided, try and get one.
@ -292,7 +289,7 @@ end
-- @return A table with all available tags -- @return A table with all available tags
function tag.gettags(s) function tag.gettags(s)
local tags = {} local tags = {}
for i, t in ipairs(root.tags()) do for _, t in ipairs(root.tags()) do
if tag.getscreen(t) == s then if tag.getscreen(t) == s then
table.insert(tags, t) table.insert(tags, t)
end end
@ -315,7 +312,7 @@ function tag.setscreen(s, t)
s, t = t, s s, t = t, s
end end
local s = s or ascreen.focused() s = s or ascreen.focused()
local sel = tag.selected local sel = tag.selected
local old_screen = tag.getproperty(t, "screen") local old_screen = tag.getproperty(t, "screen")
if s == old_screen then return end if s == old_screen then return end
@ -327,15 +324,15 @@ function tag.setscreen(s, t)
tag.setproperty(t, "screen", s, true) tag.setproperty(t, "screen", s, true)
-- Make sure the client's screen matches its tags -- Make sure the client's screen matches its tags
for k,c in ipairs(t:clients()) do for _,c in ipairs(t:clients()) do
c.screen = s --Move all clients c.screen = s --Move all clients
c:tags({t}) c:tags({t})
end end
-- Update all indexes -- Update all indexes
for _,screen in ipairs {old_screen, s} do for _,screen in ipairs {old_screen, s} do
for i,t in ipairs(tag.gettags(screen)) do for i,t2 in ipairs(tag.gettags(screen)) do
tag.setproperty(t, "index", i, true) tag.setproperty(t2, "index", i, true)
end end
end end
@ -349,7 +346,7 @@ end
-- @param[opt] t tag object -- @param[opt] t tag object
-- @return Screen number -- @return Screen number
function tag.getscreen(t) function tag.getscreen(t)
local t = t or tag.selected() t = t or tag.selected()
return tag.getproperty(t, "screen") return tag.getproperty(t, "screen")
end end
@ -360,7 +357,7 @@ function tag.selectedlist(s)
local screen = s or ascreen.focused() local screen = s or ascreen.focused()
local tags = tag.gettags(screen) local tags = tag.gettags(screen)
local vtags = {} local vtags = {}
for i, t in pairs(tags) do for _, t in pairs(tags) do
if t.selected then if t.selected then
vtags[#vtags + 1] = t vtags[#vtags + 1] = t
end end
@ -378,7 +375,7 @@ end
-- @param mwfact Master width factor. -- @param mwfact Master width factor.
-- @param t The tag to modify, if null tag.selected() is used. -- @param t The tag to modify, if null tag.selected() is used.
function tag.setmwfact(mwfact, t) function tag.setmwfact(mwfact, t)
local t = t or tag.selected() t = t or tag.selected()
if mwfact >= 0 and mwfact <= 1 then if mwfact >= 0 and mwfact <= 1 then
tag.setproperty(t, "mwfact", mwfact, true) tag.setproperty(t, "mwfact", mwfact, true)
end end
@ -394,7 +391,7 @@ end
--- Get master width factor. --- Get master width factor.
-- @param[opt] t The tag. -- @param[opt] t The tag.
function tag.getmwfact(t) function tag.getmwfact(t)
local t = t or tag.selected() t = t or tag.selected()
return tag.getproperty(t, "mwfact") or 0.5 return tag.getproperty(t, "mwfact") or 0.5
end end
@ -438,7 +435,7 @@ end
-- @param useless_gap The spacing between clients -- @param useless_gap The spacing between clients
-- @param t The tag to modify, if null tag.selected() is used. -- @param t The tag to modify, if null tag.selected() is used.
function tag.setgap(useless_gap, t) function tag.setgap(useless_gap, t)
local t = t or tag.selected() t = t or tag.selected()
if useless_gap >= 0 then if useless_gap >= 0 then
tag.setproperty(t, "useless_gap", useless_gap, true) tag.setproperty(t, "useless_gap", useless_gap, true)
end end
@ -457,7 +454,7 @@ end
-- return 0 for a single client. You can override this function to change -- return 0 for a single client. You can override this function to change
-- this behavior. -- this behavior.
function tag.getgap(t, numclients) function tag.getgap(t, numclients)
local t = t or tag.selected() t = t or tag.selected()
if numclients == 1 then if numclients == 1 then
return 0 return 0
end end
@ -470,7 +467,7 @@ end
-- "mwfact" (fill only an area inside the master width factor) -- "mwfact" (fill only an area inside the master width factor)
-- @tparam[opt=tag.selected()] tag t The tag to modify -- @tparam[opt=tag.selected()] tag t The tag to modify
function tag.setmfpol(policy, t) function tag.setmfpol(policy, t)
local t = t or tag.selected() t = t or tag.selected()
tag.setproperty(t, "master_fill_policy", policy, true) tag.setproperty(t, "master_fill_policy", policy, true)
end end
@ -491,7 +488,7 @@ end
-- "expand" (fill all the available workarea, default one) or -- "expand" (fill all the available workarea, default one) or
-- "mwfact" (fill only an area inside the master width factor) -- "mwfact" (fill only an area inside the master width factor)
function tag.getmfpol(t) function tag.getmfpol(t)
local t = t or tag.selected() t = t or tag.selected()
return tag.getproperty(t, "master_fill_policy") or "expand" return tag.getproperty(t, "master_fill_policy") or "expand"
end end
@ -499,7 +496,7 @@ end
-- @param nmaster The number of master windows. -- @param nmaster The number of master windows.
-- @param[opt] t The tag. -- @param[opt] t The tag.
function tag.setnmaster(nmaster, t) function tag.setnmaster(nmaster, t)
local t = t or tag.selected() t = t or tag.selected()
if nmaster >= 0 then if nmaster >= 0 then
tag.setproperty(t, "nmaster", nmaster, true) tag.setproperty(t, "nmaster", nmaster, true)
end end
@ -508,7 +505,7 @@ end
--- Get the number of master windows. --- Get the number of master windows.
-- @param[opt] t The tag. -- @param[opt] t The tag.
function tag.getnmaster(t) function tag.getnmaster(t)
local t = t or tag.selected() t = t or tag.selected()
return tag.getproperty(t, "nmaster") or 1 return tag.getproperty(t, "nmaster") or 1
end end
@ -542,14 +539,14 @@ end
-- @param icon the icon to set, either path or image object -- @param icon the icon to set, either path or image object
-- @param _tag the tag -- @param _tag the tag
function tag.seticon(icon, _tag) function tag.seticon(icon, _tag)
local _tag = _tag or tag.selected() _tag = _tag or tag.selected()
tag.setproperty(_tag, "icon", icon, true) tag.setproperty(_tag, "icon", icon, true)
end end
--- Get the tag icon --- Get the tag icon
-- @param _tag the tag -- @param _tag the tag
function tag.geticon(_tag) function tag.geticon(_tag)
local _tag = _tag or tag.selected() _tag = _tag or tag.selected()
return tag.getproperty(_tag, "icon") return tag.getproperty(_tag, "icon")
end end
@ -557,7 +554,7 @@ end
-- @param ncol The number of column. -- @param ncol The number of column.
-- @param t The tag to modify, if null tag.selected() is used. -- @param t The tag to modify, if null tag.selected() is used.
function tag.setncol(ncol, t) function tag.setncol(ncol, t)
local t = t or tag.selected() t = t or tag.selected()
if ncol >= 1 then if ncol >= 1 then
tag.setproperty(t, "ncol", ncol, true) tag.setproperty(t, "ncol", ncol, true)
end end
@ -566,7 +563,7 @@ end
--- Get number of column windows. --- Get number of column windows.
-- @param[opt] t The tag. -- @param[opt] t The tag.
function tag.getncol(t) function tag.getncol(t)
local t = t or tag.selected() t = t or tag.selected()
return tag.getproperty(t, "ncol") or 1 return tag.getproperty(t, "ncol") or 1
end end
@ -601,7 +598,7 @@ end
-- @tparam[opt] int screen The screen number. -- @tparam[opt] int screen The screen number.
function tag.viewnone(screen) function tag.viewnone(screen)
local tags = tag.gettags(screen or ascreen.focused()) local tags = tag.gettags(screen or ascreen.focused())
for i, t in pairs(tags) do for _, t in pairs(tags) do
t.selected = false t.selected = false
end end
end end
@ -610,10 +607,10 @@ end
-- @param i The relative index to see. -- @param i The relative index to see.
-- @param[opt] screen The screen number. -- @param[opt] screen The screen number.
function tag.viewidx(i, screen) function tag.viewidx(i, screen)
local screen = screen or ascreen.focused() screen = screen or ascreen.focused()
local tags = tag.gettags(screen) local tags = tag.gettags(screen)
local showntags = {} local showntags = {}
for k, t in ipairs(tags) do for _, t in ipairs(tags) do
if not tag.getproperty(t, "hide") then if not tag.getproperty(t, "hide") then
table.insert(showntags, t) table.insert(showntags, t)
end end
@ -632,7 +629,7 @@ end
-- @param query_tag The tag object to find. [selected()] -- @param query_tag The tag object to find. [selected()]
-- @return The index of the tag, nil if the tag is not found. -- @return The index of the tag, nil if the tag is not found.
function tag.getidx(query_tag) function tag.getidx(query_tag)
local query_tag = query_tag or tag.selected() query_tag = query_tag or tag.selected()
if query_tag == nil then return end if query_tag == nil then return end
for i, t in ipairs(tag.gettags(tag.getscreen(query_tag))) do for i, t in ipairs(tag.gettags(tag.getscreen(query_tag))) do
@ -675,7 +672,7 @@ end
-- @param tags A table with tags to view only. -- @param tags A table with tags to view only.
-- @param[opt] screen The screen number of the tags. -- @param[opt] screen The screen number of the tags.
function tag.viewmore(tags, screen) function tag.viewmore(tags, screen)
local screen = screen or ascreen.focused() screen = screen or ascreen.focused()
local screen_tags = tag.gettags(screen) local screen_tags = tag.gettags(screen)
for _, _tag in ipairs(screen_tags) do for _, _tag in ipairs(screen_tags) do
if not util.table.hasitem(tags, _tag) then if not util.table.hasitem(tags, _tag) then
@ -738,7 +735,7 @@ end
-- @param c The client to tag. -- @param c The client to tag.
function tag.withcurrent(c) function tag.withcurrent(c)
local tags = {} local tags = {}
for k, t in ipairs(c:tags()) do for _, t in ipairs(c:tags()) do
if tag.getscreen(t) == c.screen then if tag.getscreen(t) == c.screen then
table.insert(tags, t) table.insert(tags, t)
end end
@ -755,7 +752,7 @@ function tag.withcurrent(c)
end end
local function attached_connect_signal_screen(screen, sig, func) local function attached_connect_signal_screen(screen, sig, func)
capi.tag.connect_signal(sig, function(_tag, ...) capi.tag.connect_signal(sig, function(_tag)
if tag.getscreen(_tag) == screen then if tag.getscreen(_tag) == screen then
func(_tag) func(_tag)
end end
@ -792,7 +789,7 @@ capi.client.connect_signal("manage", function(c)
end) end)
-- Keep track of the number of urgent clients. -- Keep track of the number of urgent clients.
local function update_urgent(c, t, modif) local function update_urgent(t, modif)
local count = tag.getproperty(t, "urgent_count") or 0 local count = tag.getproperty(t, "urgent_count") or 0
count = (count + modif) >= 0 and (count + modif) or 0 count = (count + modif) >= 0 and (count + modif) or 0
tag.setproperty(t, "urgent" , count > 0) tag.setproperty(t, "urgent" , count > 0)
@ -802,21 +799,21 @@ end
-- Update the urgent counter when a client is tagged. -- Update the urgent counter when a client is tagged.
local function client_tagged(c, t) local function client_tagged(c, t)
if c.urgent then if c.urgent then
update_urgent(c, t, 1) update_urgent(t, 1)
end end
end end
-- Update the urgent counter when a client is untagged. -- Update the urgent counter when a client is untagged.
local function client_untagged(c, t) local function client_untagged(c, t)
if c.urgent then if c.urgent then
update_urgent(c, t, -1) update_urgent(t, -1)
end end
end end
-- Count the urgent clients. -- Count the urgent clients.
local function urgent_callback(c) local function urgent_callback(c)
for k,t in ipairs(c:tags()) do for _,t in ipairs(c:tags()) do
update_urgent(c, t, c.urgent and 1 or -1) update_urgent(t, c.urgent and 1 or -1)
end end
end end

View File

@ -14,9 +14,7 @@ local abutton = require("awful.button")
local aclient = require("awful.client") local aclient = require("awful.client")
local atooltip = require("awful.tooltip") local atooltip = require("awful.tooltip")
local beautiful = require("beautiful") local beautiful = require("beautiful")
local object = require("gears.object")
local drawable = require("wibox.drawable") local drawable = require("wibox.drawable")
local base = require("wibox.widget.base")
local imagebox = require("wibox.widget.imagebox") local imagebox = require("wibox.widget.imagebox")
local textbox = require("wibox.widget.textbox") local textbox = require("wibox.widget.textbox")
local capi = { local capi = {
@ -72,7 +70,7 @@ end
-- can be configured via e.g. "bg_normal" and "bg_focus". -- can be configured via e.g. "bg_normal" and "bg_focus".
-- @name titlebar -- @name titlebar
local function new(c, args) local function new(c, args)
local args = args or {} args = args or {}
local position = args.position or "top" local position = args.position or "top"
local size = args.size or util.round(beautiful.get_font_height(args.font) * 1.5) local size = args.size or util.round(beautiful.get_font_height(args.font) * 1.5)
local d = get_titlebar_function(c, position)(c, size) local d = get_titlebar_function(c, position)(c, size)
@ -92,10 +90,10 @@ local function new(c, args)
} }
ret = drawable(d, context, "awful.titlebar") ret = drawable(d, context, "awful.titlebar")
local function update_colors() local function update_colors()
local args = bars[position].args local args_ = bars[position].args
ret:set_bg(get_color("bg", c, args)) ret:set_bg(get_color("bg", c, args_))
ret:set_fg(get_color("fg", c, args)) ret:set_fg(get_color("fg", c, args_))
ret:set_bgimage(get_color("bgimage", c, args)) ret:set_bgimage(get_color("bgimage", c, args_))
end end
bars[position] = { bars[position] = {
@ -126,7 +124,7 @@ end
-- @param[opt] position The position of the titlebar. Must be one of "left", -- @param[opt] position The position of the titlebar. Must be one of "left",
-- "right", "top", "bottom". Default is "top". -- "right", "top", "bottom". Default is "top".
function titlebar.show(c, position) function titlebar.show(c, position)
local position = position or "top" position = position or "top"
local bars = all_titlebars[c] local bars = all_titlebars[c]
local data = bars and bars[position] local data = bars and bars[position]
local args = data and data.args local args = data and data.args
@ -138,7 +136,7 @@ end
-- @param[opt] position The position of the titlebar. Must be one of "left", -- @param[opt] position The position of the titlebar. Must be one of "left",
-- "right", "top", "bottom". Default is "top". -- "right", "top", "bottom". Default is "top".
function titlebar.hide(c, position) function titlebar.hide(c, position)
local position = position or "top" position = position or "top"
get_titlebar_function(c, position)(c, 0) get_titlebar_function(c, position)(c, 0)
end end
@ -147,8 +145,8 @@ end
-- @param[opt] position The position of the titlebar. Must be one of "left", -- @param[opt] position The position of the titlebar. Must be one of "left",
-- "right", "top", "bottom". Default is "top". -- "right", "top", "bottom". Default is "top".
function titlebar.toggle(c, position) function titlebar.toggle(c, position)
local position = position or "top" position = position or "top"
local drawable, size = get_titlebar_function(c, position)(c) local _, size = get_titlebar_function(c, position)(c)
if size == 0 then if size == 0 then
titlebar.show(c, position) titlebar.show(c, position)
else else
@ -265,11 +263,11 @@ end
--- Create a new maximize button for a client. --- Create a new maximize button for a client.
-- @param c The client for which the button is wanted. -- @param c The client for which the button is wanted.
function titlebar.widget.maximizedbutton(c) function titlebar.widget.maximizedbutton(c)
local widget = titlebar.widget.button(c, "maximized", function(c) local widget = titlebar.widget.button(c, "maximized", function(cl)
return c.maximized_horizontal or c.maximized_vertical return cl.maximized_horizontal or cl.maximized_vertical
end, function(c, state) end, function(cl, state)
c.maximized_horizontal = not state cl.maximized_horizontal = not state
c.maximized_vertical = not state cl.maximized_vertical = not state
end) end)
c:connect_signal("property::maximized_vertical", widget.update) c:connect_signal("property::maximized_vertical", widget.update)
c:connect_signal("property::maximized_horizontal", widget.update) c:connect_signal("property::maximized_horizontal", widget.update)
@ -279,7 +277,7 @@ end
--- Create a new minimize button for a client. --- Create a new minimize button for a client.
-- @param c The client for which the button is wanted. -- @param c The client for which the button is wanted.
function titlebar.widget.minimizebutton(c) function titlebar.widget.minimizebutton(c)
local widget = titlebar.widget.button(c, "minimize", function() return c.minimized end, function(c) c.minimized = not c.minimized end) local widget = titlebar.widget.button(c, "minimize", function(cl) return cl.minimized end, function(cl) cl.minimized = not cl.minimized end)
c:connect_signal("property::minimized", widget.update) c:connect_signal("property::minimized", widget.update)
return widget return widget
end end
@ -287,13 +285,13 @@ end
--- Create a new closing button for a client. --- Create a new closing button for a client.
-- @param c The client for which the button is wanted. -- @param c The client for which the button is wanted.
function titlebar.widget.closebutton(c) function titlebar.widget.closebutton(c)
return titlebar.widget.button(c, "close", function() return "" end, function(c) c:kill() end) return titlebar.widget.button(c, "close", function() return "" end, function(cl) cl:kill() end)
end end
--- Create a new ontop button for a client. --- Create a new ontop button for a client.
-- @param c The client for which the button is wanted. -- @param c The client for which the button is wanted.
function titlebar.widget.ontopbutton(c) function titlebar.widget.ontopbutton(c)
local widget = titlebar.widget.button(c, "ontop", function(c) return c.ontop end, function(c, state) c.ontop = not state end) local widget = titlebar.widget.button(c, "ontop", function(cl) return cl.ontop end, function(cl, state) cl.ontop = not state end)
c:connect_signal("property::ontop", widget.update) c:connect_signal("property::ontop", widget.update)
return widget return widget
end end
@ -301,7 +299,7 @@ end
--- Create a new sticky button for a client. --- Create a new sticky button for a client.
-- @param c The client for which the button is wanted. -- @param c The client for which the button is wanted.
function titlebar.widget.stickybutton(c) function titlebar.widget.stickybutton(c)
local widget = titlebar.widget.button(c, "sticky", function(c) return c.sticky end, function(c, state) c.sticky = not state end) local widget = titlebar.widget.button(c, "sticky", function(cl) return cl.sticky end, function(cl, state) cl.sticky = not state end)
c:connect_signal("property::sticky", widget.update) c:connect_signal("property::sticky", widget.update)
return widget return widget
end end

View File

@ -41,7 +41,6 @@
------------------------------------------------------------------------- -------------------------------------------------------------------------
local mouse = mouse local mouse = mouse
local screen = screen
local timer = require("gears.timer") local timer = require("gears.timer")
local wibox = require("wibox") local wibox = require("wibox")
local a_placement = require("awful.placement") local a_placement = require("awful.placement")

View File

@ -11,14 +11,13 @@
local os = os local os = os
local io = io local io = io
local assert = assert local assert = assert
local load = loadstring or load -- v5.1 - loadstring, v5.2 - load local load = loadstring or load -- luacheck: globals loadstring (compatibility with Lua 5.1)
local loadfile = loadfile local loadfile = loadfile
local debug = debug local debug = debug
local pairs = pairs local pairs = pairs
local ipairs = ipairs local ipairs = ipairs
local type = type local type = type
local rtable = table local rtable = table
local pairs = pairs
local string = string local string = string
local lgi = require("lgi") local lgi = require("lgi")
local Gio = require("lgi").Gio local Gio = require("lgi").Gio
@ -195,8 +194,8 @@ end
-- @tparam[opt] string size The size. If this is specified, subdirectories `x` -- @tparam[opt] string size The size. If this is specified, subdirectories `x`
-- of the dirs are searched first. -- of the dirs are searched first.
function util.geticonpath(iconname, exts, dirs, size) function util.geticonpath(iconname, exts, dirs, size)
local exts = exts or { 'png', 'gif' } exts = exts or { 'png', 'gif' }
local dirs = dirs or { '/usr/share/pixmaps/', '/usr/share/icons/hicolor/' } dirs = dirs or { '/usr/share/pixmaps/', '/usr/share/icons/hicolor/' }
local icontypes = { 'apps', 'actions', 'categories', 'emblems', local icontypes = { 'apps', 'actions', 'categories', 'emblems',
'mimetypes', 'status', 'devices', 'extras', 'places', 'stock' } 'mimetypes', 'status', 'devices', 'extras', 'places', 'stock' }
for _, d in pairs(dirs) do for _, d in pairs(dirs) do
@ -385,7 +384,7 @@ end
-- @return A new table containing all keys from the arguments. -- @return A new table containing all keys from the arguments.
function util.table.join(...) function util.table.join(...)
local ret = {} local ret = {}
for i, t in pairs({...}) do for _, t in pairs({...}) do
if t then if t then
for k, v in pairs(t) do for k, v in pairs(t) do
if type(k) == "number" then if type(k) == "number" then
@ -422,7 +421,7 @@ end
-- @treturn table A packed table with all numeric keys -- @treturn table A packed table with all numeric keys
function util.table.from_sparse(t) function util.table.from_sparse(t)
local keys= {} local keys= {}
for k,v in pairs(t) do for k in pairs(t) do
if type(k) == "number" then if type(k) == "number" then
keys[#keys+1] = k keys[#keys+1] = k
end end
@ -462,7 +461,7 @@ function util.linewrap(text, width, indent)
local pos = 1 local pos = 1
return text:gsub("(%s+)()(%S+)()", return text:gsub("(%s+)()(%S+)()",
function(sp, st, word, fi) function(_, st, word, fi)
if fi - pos > width then if fi - pos > width then
pos = st pos = st
return "\n" .. string.rep(" ", indent) .. word return "\n" .. string.rep(" ", indent) .. word
@ -532,7 +531,7 @@ end
-- @param deep Create a deep clone? (default: true) -- @param deep Create a deep clone? (default: true)
-- @return a clone of t -- @return a clone of t
function util.table.clone(t, deep) function util.table.clone(t, deep)
local deep = deep == nil and true or deep deep = deep == nil and true or deep
local c = { } local c = { }
for k, v in pairs(t) do for k, v in pairs(t) do
if deep and type(v) == "table" then if deep and type(v) == "table" then
@ -592,7 +591,7 @@ end
-- Generate a pattern matching expression that ignores case. -- Generate a pattern matching expression that ignores case.
-- @param s Original pattern matching expression. -- @param s Original pattern matching expression.
function util.query_to_pattern(q) function util.query_to_pattern(q)
s = util.quote_pattern(q) local s = util.quote_pattern(q)
-- Poor man's case-insensitive character matching. -- Poor man's case-insensitive character matching.
s = string.gsub(s, "%a", s = string.gsub(s, "%a",
function (c) function (c)

View File

@ -32,11 +32,11 @@ local awfulwibox = { mt = {} }
local wiboxes = {} local wiboxes = {}
--- Get a wibox position if it has been set, or return top. --- Get a wibox position if it has been set, or return top.
-- @param wibox The wibox -- @param wb The wibox
-- @return The wibox position. -- @return The wibox position.
function awfulwibox.get_position(wibox) function awfulwibox.get_position(wb)
for _, wprop in ipairs(wiboxes) do for _, wprop in ipairs(wiboxes) do
if wprop.wibox == wibox then if wprop.wibox == wb then
return wprop.position return wprop.position
end end
end end
@ -44,28 +44,28 @@ function awfulwibox.get_position(wibox)
end end
--- Put a wibox on a screen at this position. --- Put a wibox on a screen at this position.
-- @param wibox The wibox to attach. -- @param wb The wibox to attach.
-- @param position The position: top, bottom left or right. -- @param position The position: top, bottom left or right.
-- @param screen If the wibox it not attached to a screen, specified on which -- @param screen If the wibox it not attached to a screen, specified on which
-- screen the position should be set. -- screen the position should be set.
function awfulwibox.set_position(wibox, position, screen) function awfulwibox.set_position(wb, position, screen)
local area = capi.screen[screen].geometry local area = capi.screen[screen].geometry
-- The "length" of a wibox is always chosen to be the optimal size -- The "length" of a wibox is always chosen to be the optimal size
-- (non-floating). -- (non-floating).
-- The "width" of a wibox is kept if it exists. -- The "width" of a wibox is kept if it exists.
if position == "right" then if position == "right" then
wibox.x = area.x + area.width - (wibox.width + 2 * wibox.border_width) wb.x = area.x + area.width - (wb.width + 2 * wb.border_width)
elseif position == "left" then elseif position == "left" then
wibox.x = area.x wb.x = area.x
elseif position == "bottom" then elseif position == "bottom" then
wibox.y = (area.y + area.height) - (wibox.height + 2 * wibox.border_width) wb.y = (area.y + area.height) - (wb.height + 2 * wb.border_width)
elseif position == "top" then elseif position == "top" then
wibox.y = area.y wb.y = area.y
end end
for _, wprop in ipairs(wiboxes) do for _, wprop in ipairs(wiboxes) do
if wprop.wibox == wibox then if wprop.wibox == wb then
wprop.position = position wprop.position = position
break break
end end
@ -79,23 +79,23 @@ local function update_all_wiboxes_position()
end end
end end
local function call_wibox_position_hook_on_prop_update(w) local function call_wibox_position_hook_on_prop_update()
update_all_wiboxes_position() update_all_wiboxes_position()
end end
local function wibox_update_strut(wibox) local function wibox_update_strut(wb)
for _, wprop in ipairs(wiboxes) do for _, wprop in ipairs(wiboxes) do
if wprop.wibox == wibox then if wprop.wibox == wb then
if not wibox.visible then if not wb.visible then
wibox:struts { left = 0, right = 0, bottom = 0, top = 0 } wb:struts { left = 0, right = 0, bottom = 0, top = 0 }
elseif wprop.position == "top" then elseif wprop.position == "top" then
wibox:struts { left = 0, right = 0, bottom = 0, top = wibox.height + 2 * wibox.border_width } wb:struts { left = 0, right = 0, bottom = 0, top = wb.height + 2 * wb.border_width }
elseif wprop.position == "bottom" then elseif wprop.position == "bottom" then
wibox:struts { left = 0, right = 0, bottom = wibox.height + 2 * wibox.border_width, top = 0 } wb:struts { left = 0, right = 0, bottom = wb.height + 2 * wb.border_width, top = 0 }
elseif wprop.position == "left" then elseif wprop.position == "left" then
wibox:struts { left = wibox.width + 2 * wibox.border_width, right = 0, bottom = 0, top = 0 } wb:struts { left = wb.width + 2 * wb.border_width, right = 0, bottom = 0, top = 0 }
elseif wprop.position == "right" then elseif wprop.position == "right" then
wibox:struts { left = 0, right = wibox.width + 2 * wibox.border_width, bottom = 0, top = 0 } wb:struts { left = 0, right = wb.width + 2 * wb.border_width, bottom = 0, top = 0 }
end end
break break
end end
@ -105,10 +105,10 @@ end
--- Attach a wibox to a screen. --- Attach a wibox to a screen.
-- If a wibox is attached, it will be automatically be moved when other wiboxes -- If a wibox is attached, it will be automatically be moved when other wiboxes
-- will be attached. -- will be attached.
-- @param wibox The wibox to attach. -- @param wb The wibox to attach.
-- @param position The position of the wibox: top, bottom, left or right. -- @param position The position of the wibox: top, bottom, left or right.
-- @param screen TODO, this seems to be unused -- @param screen TODO, this seems to be unused
function awfulwibox.attach(wibox, position, screen) function awfulwibox.attach(wb, position, screen)
-- Store wibox as attached in a weak-valued table -- Store wibox as attached in a weak-valued table
local wibox_prop_table local wibox_prop_table
-- Start from end since we sometimes remove items -- Start from end since we sometimes remove items
@ -117,7 +117,7 @@ function awfulwibox.attach(wibox, position, screen)
-- If they did, remove their entries -- If they did, remove their entries
if wiboxes[i].wibox == nil then if wiboxes[i].wibox == nil then
table.remove(wiboxes, i) table.remove(wiboxes, i)
elseif wiboxes[i].wibox == wibox then elseif wiboxes[i].wibox == wb then
wibox_prop_table = wiboxes[i] wibox_prop_table = wiboxes[i]
-- We could break here, but well, let's check if there is no other -- We could break here, but well, let's check if there is no other
-- table with their wiboxes been garbage collected. -- table with their wiboxes been garbage collected.
@ -125,81 +125,81 @@ function awfulwibox.attach(wibox, position, screen)
end end
if not wibox_prop_table then if not wibox_prop_table then
table.insert(wiboxes, setmetatable({ wibox = wibox, position = position, screen = screen }, { __mode = 'v' })) table.insert(wiboxes, setmetatable({ wibox = wb, position = position, screen = screen }, { __mode = 'v' }))
else else
wibox_prop_table.position = position wibox_prop_table.position = position
end end
wibox:connect_signal("property::width", wibox_update_strut) wb:connect_signal("property::width", wibox_update_strut)
wibox:connect_signal("property::height", wibox_update_strut) wb:connect_signal("property::height", wibox_update_strut)
wibox:connect_signal("property::visible", wibox_update_strut) wb:connect_signal("property::visible", wibox_update_strut)
wibox:connect_signal("property::width", call_wibox_position_hook_on_prop_update) wb:connect_signal("property::width", call_wibox_position_hook_on_prop_update)
wibox:connect_signal("property::height", call_wibox_position_hook_on_prop_update) wb:connect_signal("property::height", call_wibox_position_hook_on_prop_update)
wibox:connect_signal("property::visible", call_wibox_position_hook_on_prop_update) wb:connect_signal("property::visible", call_wibox_position_hook_on_prop_update)
wibox:connect_signal("property::border_width", call_wibox_position_hook_on_prop_update) wb:connect_signal("property::border_width", call_wibox_position_hook_on_prop_update)
end end
--- Align a wibox. --- Align a wibox.
-- @param wibox The wibox. -- @param wb The wibox.
-- @param align The alignment: left, right or center. -- @param align The alignment: left, right or center.
-- @param screen If the wibox is not attached to any screen, you can specify the -- @param screen If the wibox is not attached to any screen, you can specify the
-- screen where to align. Otherwise 1 is assumed. -- screen where to align. Otherwise 1 is assumed.
function awfulwibox.align(wibox, align, screen) function awfulwibox.align(wb, align, screen)
local position = awfulwibox.get_position(wibox) local position = awfulwibox.get_position(wb)
local area = capi.screen[screen].workarea local area = capi.screen[screen].workarea
if position == "right" then if position == "right" then
if align == "right" then if align == "right" then
wibox.y = area.y wb.y = area.y
elseif align == "left" then elseif align == "left" then
wibox.y = area.y + area.height - (wibox.height + 2 * wibox.border_width) wb.y = area.y + area.height - (wb.height + 2 * wb.border_width)
elseif align == "center" then elseif align == "center" then
wibox.y = area.y + round((area.height - wibox.height) / 2) wb.y = area.y + round((area.height - wb.height) / 2)
end end
elseif position == "left" then elseif position == "left" then
if align == "right" then if align == "right" then
wibox.y = (area.y + area.height) - (wibox.height + 2 * wibox.border_width) wb.y = (area.y + area.height) - (wb.height + 2 * wb.border_width)
elseif align == "left" then elseif align == "left" then
wibox.y = area.y wb.y = area.y
elseif align == "center" then elseif align == "center" then
wibox.y = area.y + round((area.height - wibox.height) / 2) wb.y = area.y + round((area.height - wb.height) / 2)
end end
elseif position == "bottom" then elseif position == "bottom" then
if align == "right" then if align == "right" then
wibox.x = area.x + area.width - (wibox.width + 2 * wibox.border_width) wb.x = area.x + area.width - (wb.width + 2 * wb.border_width)
elseif align == "left" then elseif align == "left" then
wibox.x = area.x wb.x = area.x
elseif align == "center" then elseif align == "center" then
wibox.x = area.x + round((area.width - wibox.width) / 2) wb.x = area.x + round((area.width - wb.width) / 2)
end end
elseif position == "top" then elseif position == "top" then
if align == "right" then if align == "right" then
wibox.x = area.x + area.width - (wibox.width + 2 * wibox.border_width) wb.x = area.x + area.width - (wb.width + 2 * wb.border_width)
elseif align == "left" then elseif align == "left" then
wibox.x = area.x wb.x = area.x
elseif align == "center" then elseif align == "center" then
wibox.x = area.x + round((area.width - wibox.width) / 2) wb.x = area.x + round((area.width - wb.width) / 2)
end end
end end
-- Update struts regardless of changes -- Update struts regardless of changes
wibox_update_strut(wibox) wibox_update_strut(wb)
end end
--- Stretch a wibox so it takes all screen width or height. --- Stretch a wibox so it takes all screen width or height.
-- @param wibox The wibox. -- @param wb The wibox.
-- @param screen The screen to stretch on, or the wibox screen. -- @param screen The screen to stretch on, or the wibox screen.
function awfulwibox.stretch(wibox, screen) function awfulwibox.stretch(wb, screen)
if screen then if screen then
local position = awfulwibox.get_position(wibox) local position = awfulwibox.get_position(wb)
local area = capi.screen[screen].workarea local area = capi.screen[screen].workarea
if position == "right" or position == "left" then if position == "right" or position == "left" then
wibox.height = area.height - (2 * wibox.border_width) wb.height = area.height - (2 * wb.border_width)
wibox.y = area.y wb.y = area.y
else else
wibox.width = area.width - (2 * wibox.border_width) wb.width = area.width - (2 * wb.border_width)
wibox.x = area.x wb.x = area.x
end end
end end
end end
@ -213,7 +213,7 @@ end
-- If not specified, 1 is assumed. -- If not specified, 1 is assumed.
-- @return The wibox created. -- @return The wibox created.
function awfulwibox.new(arg) function awfulwibox.new(arg)
local arg = arg or {} arg = arg or {}
local position = arg.position or "top" local position = arg.position or "top"
local has_to_stretch = true local has_to_stretch = true
local screen = arg.screen or 1 local screen = arg.screen or 1

View File

@ -6,13 +6,11 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local setmetatable = setmetatable local setmetatable = setmetatable
local type = type
local abutton = require("awful.button") local abutton = require("awful.button")
local imagebox = require("wibox.widget.imagebox") local imagebox = require("wibox.widget.imagebox")
local widget = require("wibox.widget.base") local widget = require("wibox.widget.base")
local surface = require("gears.surface") local surface = require("gears.surface")
local cairo = require("lgi").cairo local cairo = require("lgi").cairo
local capi = { mouse = mouse }
local button = { mt = {} } local button = { mt = {} }
@ -31,13 +29,13 @@ function button.new(args)
local img_release local img_release
local img_press local img_press
w.set_image = function(w, image) function w:set_image(image)
img_release = surface.load(image) img_release = surface.load(image)
img_press = img_release:create_similar(cairo.Content.COLOR_ALPHA, img_release.width, img_release.height) img_press = img_release:create_similar(cairo.Content.COLOR_ALPHA, img_release.width, img_release.height)
local cr = cairo.Context(img_press) local cr = cairo.Context(img_press)
cr:set_source_surface(img_release, 2, 2) cr:set_source_surface(img_release, 2, 2)
cr:paint() cr:paint()
orig_set_image(w, img_release) orig_set_image(self, img_release)
end end
w:set_image(args.image) w:set_image(args.image)
w:buttons(abutton({}, 1, function () orig_set_image(w, img_press) end, function () orig_set_image(w, img_release) end)) w:buttons(abutton({}, 1, function () orig_set_image(w, img_press) end, function () orig_set_image(w, img_release) end))

View File

@ -6,17 +6,10 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
-- Grab environment we need -- Grab environment we need
local math = math
local type = type local type = type
local ipairs = ipairs local ipairs = ipairs
local pairs = pairs
local pcall = pcall
local setmetatable = setmetatable
local capi = { button = button } local capi = { button = button }
local util = require("awful.util")
local wibox = require("wibox") local wibox = require("wibox")
local imagebox = require("wibox.widget.imagebox")
local textbox = require("wibox.widget.textbox")
local dpi = require("beautiful").xresources.apply_dpi local dpi = require("beautiful").xresources.apply_dpi
--- Common utilities for awful widgets --- Common utilities for awful widgets
@ -29,7 +22,7 @@ local common = {}
function common.create_buttons(buttons, object) function common.create_buttons(buttons, object)
if buttons then if buttons then
local btns = {} local btns = {}
for kb, b in ipairs(buttons) do for _, b in ipairs(buttons) do
-- Create a proxy button object: it will receive the real -- Create a proxy button object: it will receive the real
-- press and release events, and will propagate them the the -- press and release events, and will propagate them the the
-- button object the user provided, but with the object as -- button object the user provided, but with the object as

View File

@ -69,7 +69,7 @@ local properties = { "width", "height", "border_color", "stack",
"stack_colors", "color", "background_color", "stack_colors", "color", "background_color",
"max_value", "scale" } "max_value", "scale" }
function graph.draw(_graph, context, cr, width, height) function graph.draw(_graph, _, cr, width, height)
local max_value = data[_graph].max_value local max_value = data[_graph].max_value
local values = data[_graph].values local values = data[_graph].values
@ -91,7 +91,7 @@ function graph.draw(_graph, context, cr, width, height)
if data[_graph].scale then if data[_graph].scale then
for _, v in ipairs(values) do for _, v in ipairs(values) do
for __, sv in ipairs(v) do for _, sv in ipairs(v) do
if sv > max_value then if sv > max_value then
max_value = sv max_value = sv
end end
@ -169,7 +169,7 @@ end
local function add_value(_graph, value, group) local function add_value(_graph, value, group)
if not _graph then return end if not _graph then return end
local value = value or 0 value = value or 0
local values = data[_graph].values local values = data[_graph].values
local max_value = data[_graph].max_value local max_value = data[_graph].max_value
value = math.max(0, value) value = math.max(0, value)
@ -243,7 +243,7 @@ end
-- key to set graph geometry. -- key to set graph geometry.
-- @return A graph widget. -- @return A graph widget.
function graph.new(args) function graph.new(args)
local args = args or {} args = args or {}
local width = args.width or 100 local width = args.width or 100
local height = args.height or 20 local height = args.height or 20

View File

@ -7,7 +7,6 @@
local capi = {awesome = awesome} local capi = {awesome = awesome}
local setmetatable = setmetatable local setmetatable = setmetatable
local os = os
local textbox = require("wibox.widget.textbox") local textbox = require("wibox.widget.textbox")
local button = require("awful.button") local button = require("awful.button")
local util = require("awful.util") local util = require("awful.util")
@ -264,8 +263,7 @@ function keyboardlayout.new()
update_layout(self); update_layout(self);
self.next_layout = function() self.next_layout = function()
new_layout = (self._current + 1) % (#self._layout + 1) self.set_layout((self._current + 1) % (#self._layout + 1))
self.set_layout(new_layout)
end end
self.set_layout = function(group_number) self.set_layout = function(group_number)

View File

@ -8,8 +8,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local setmetatable = setmetatable local setmetatable = setmetatable
local ipairs = ipairs
local button = require("awful.button")
local layout = require("awful.layout") local layout = require("awful.layout")
local tooltip = require("awful.tooltip") local tooltip = require("awful.tooltip")
local tag = require("awful.tag") local tag = require("awful.tag")
@ -21,9 +19,9 @@ local layoutbox = { mt = {} }
local boxes = nil local boxes = nil
local function update(w, screen) local function update(w, screen)
local layout = layout.getname(layout.get(screen)) local name = layout.getname(layout.get(screen))
w._layoutbox_tooltip:set_text(layout or "[no name]") w._layoutbox_tooltip:set_text(name or "[no name]")
w:set_image(layout and beautiful["layout_" .. layout]) w:set_image(name and beautiful["layout_" .. name])
end end
local function update_from_tag(t) local function update_from_tag(t)
@ -39,7 +37,7 @@ end
-- @param screen The screen number that the layout will be represented for. -- @param screen The screen number that the layout will be represented for.
-- @return An imagebox widget configured as a layoutbox. -- @return An imagebox widget configured as a layoutbox.
function layoutbox.new(screen) function layoutbox.new(screen)
local screen = screen or 1 screen = screen or 1
-- Do we already have the update callbacks registered? -- Do we already have the update callbacks registered?
if boxes == nil then if boxes == nil then

View File

@ -71,7 +71,7 @@ local properties = { "width", "height", "border_color",
"vertical", "value", "max_value", "vertical", "value", "max_value",
"ticks", "ticks_gap", "ticks_size" } "ticks", "ticks_gap", "ticks_size" }
function progressbar.draw(pbar, context, cr, width, height) function progressbar.draw(pbar, _, cr, width, height)
local ticks_gap = data[pbar].ticks_gap or 1 local ticks_gap = data[pbar].ticks_gap or 1
local ticks_size = data[pbar].ticks_size or 4 local ticks_size = data[pbar].ticks_size or 4
@ -161,7 +161,7 @@ end
--- Set the progressbar value. --- Set the progressbar value.
-- @param value The progress bar value between 0 and 1. -- @param value The progress bar value between 0 and 1.
function progressbar:set_value(value) function progressbar:set_value(value)
local value = value or 0 value = value or 0
local max_value = data[self].max_value local max_value = data[self].max_value
data[self].value = math.min(max_value, math.max(0, value)) data[self].value = math.min(max_value, math.max(0, value))
self:emit_signal("widget::redraw_needed") self:emit_signal("widget::redraw_needed")
@ -200,7 +200,7 @@ end
-- key to set progressbar geometry. -- key to set progressbar geometry.
-- @return A progressbar widget. -- @return A progressbar widget.
function progressbar.new(args) function progressbar.new(args)
local args = args or {} args = args or {}
local width = args.width or 100 local width = args.width or 100
local height = args.height or 20 local height = args.height or 20

View File

@ -42,7 +42,7 @@ end
-- @param args Arguments table. "prompt" is the prompt to use. -- @param args Arguments table. "prompt" is the prompt to use.
-- @return A launcher widget. -- @return A launcher widget.
function widgetprompt.new(args) function widgetprompt.new(args)
local args = args or {} args = args or {}
local widget = textbox() local widget = textbox()
local promptbox = widget_base.make_widget(widget) local promptbox = widget_base.make_widget(widget)

View File

@ -11,7 +11,6 @@
local capi = { screen = screen, local capi = { screen = screen,
awesome = awesome, awesome = awesome,
client = client } client = client }
local type = type
local setmetatable = setmetatable local setmetatable = setmetatable
local pairs = pairs local pairs = pairs
local ipairs = ipairs local ipairs = ipairs
@ -53,7 +52,8 @@ function taglist.taglist_label(t, args)
local fg_color = nil local fg_color = nil
local bg_image local bg_image
local icon local icon
local bg_resize = false -- TODO: Re-implement bg_resize
local bg_resize = false -- luacheck: ignore
local is_selected = false local is_selected = false
local cls = t:clients() local cls = t:clients()
@ -117,7 +117,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 k, t in ipairs(tag.gettags(s)) do for _, t in ipairs(tag.gettags(s)) do
if not tag.getproperty(t, "hide") and filter(t) then if not tag.getproperty(t, "hide") and filter(t) then
table.insert(tags, t) table.insert(tags, t)
end end
@ -211,25 +211,21 @@ end
--- Filtering function to include all nonempty tags on the screen. --- Filtering function to include all nonempty tags on the screen.
-- @param t The tag. -- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true if t is not empty, else false -- @return true if t is not empty, else false
function taglist.filter.noempty(t, args) function taglist.filter.noempty(t)
return #t:clients() > 0 or t.selected return #t:clients() > 0 or t.selected
end end
--- Filtering function to include selected tags on the screen. --- Filtering function to include selected tags on the screen.
-- @param t The tag. -- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true if t is not empty, else false -- @return true if t is not empty, else false
function taglist.filter.selected(t, args) function taglist.filter.selected(t)
return t.selected return t.selected
end end
--- Filtering function to include all tags on the screen. --- Filtering function to include all tags on the screen.
-- @param t The tag.
-- @param args unused list of extra arguments.
-- @return true -- @return true
function taglist.filter.all(t, args) function taglist.filter.all()
return true return true
end end

View File

@ -48,10 +48,10 @@ local function tasklist_label(c, args, tb)
local font_focus = args.font_focus or theme.tasklist_font_focus or theme.font_focus or font or "" local font_focus = args.font_focus or theme.tasklist_font_focus or theme.font_focus or font or ""
local font_minimized = args.font_minimized or theme.tasklist_font_minimized or theme.font_minimized or font or "" local font_minimized = args.font_minimized or theme.tasklist_font_minimized or theme.font_minimized or font or ""
local font_urgent = args.font_urgent or theme.tasklist_font_urgent or theme.font_urgent or font or "" local font_urgent = args.font_urgent or theme.tasklist_font_urgent or theme.font_urgent or font or ""
local bg = nil
local text = "" local text = ""
local name = "" local name = ""
local bg_image = nil local bg
local bg_image
-- symbol to use to indicate certain client properties -- symbol to use to indicate certain client properties
local sticky = args.sticky or theme.tasklist_sticky or "" local sticky = args.sticky or theme.tasklist_sticky or ""
@ -89,8 +89,8 @@ local function tasklist_label(c, args, tb)
-- is considered to be focused, if the real client has skip_taskbar. -- is considered to be focused, if the real client has skip_taskbar.
if not focused and capi.client.focus and capi.client.focus.skip_taskbar if not focused and capi.client.focus and capi.client.focus.skip_taskbar
and client.get_transient_for_matching(capi.client.focus, and client.get_transient_for_matching(capi.client.focus,
function(c) function(cl)
return not c.skip_taskbar return not cl.skip_taskbar
end) == c then end) == c then
focused = true focused = true
end end
@ -120,7 +120,7 @@ end
local function tasklist_update(s, w, buttons, filter, data, style, update_function) local function tasklist_update(s, w, buttons, filter, data, style, update_function)
local clients = {} local clients = {}
for k, c in ipairs(capi.client.get()) do for _, c in ipairs(capi.client.get()) do
if not (c.skip_taskbar or c.hidden if not (c.skip_taskbar or c.hidden
or c.type == "splash" or c.type == "dock" or c.type == "desktop") or c.type == "splash" or c.type == "dock" or c.type == "desktop")
and filter(c, s) then and filter(c, s) then
@ -245,10 +245,8 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg
end end
--- Filtering function to include all clients. --- Filtering function to include all clients.
-- @param c The client.
-- @param screen The screen we are drawing on.
-- @return true -- @return true
function tasklist.filter.allscreen(c, screen) function tasklist.filter.allscreen()
return true return true
end end
@ -271,7 +269,7 @@ function tasklist.filter.currenttags(c, screen)
-- 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 = tag.gettags(screen)
for k, 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()
for _, v in ipairs(ctags) do for _, v in ipairs(ctags) do
@ -296,7 +294,7 @@ function tasklist.filter.minimizedcurrenttags(c, screen)
-- 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 = tag.gettags(screen)
for k, 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
local ctags = c:tags() local ctags = c:tags()

View File

@ -27,8 +27,8 @@ end
-- @param timeout How often update the time. Default is 60. -- @param timeout How often update the time. Default is 60.
-- @return A textbox widget. -- @return A textbox widget.
function textclock.new(format, timeout) function textclock.new(format, timeout)
local format = format or " %a %b %d, %H:%M " format = format or " %a %b %d, %H:%M "
local timeout = timeout or 60 timeout = timeout or 60
local w = textbox() local w = textbox()
local t local t

View File

@ -10,22 +10,13 @@
-- Grab environment -- Grab environment
local os = os local os = os
local print = print
local pcall = pcall
local pairs = pairs local pairs = pairs
local type = type local type = type
local dofile = dofile local dofile = dofile
local setmetatable = setmetatable local setmetatable = setmetatable
local util = require("awful.util")
local lgi = require("lgi") local lgi = require("lgi")
local cairo = lgi.cairo
local Pango = lgi.Pango local Pango = lgi.Pango
local PangoCairo = lgi.PangoCairo local PangoCairo = lgi.PangoCairo
local capi =
{
screen = screen,
awesome = awesome
}
local gears_debug = require("gears.debug") local gears_debug = require("gears.debug")
local xresources = require("beautiful.xresources") local xresources = require("beautiful.xresources")
@ -99,7 +90,7 @@ end
-- @treturn lgi.Pango.FontDescription -- @treturn lgi.Pango.FontDescription
function beautiful.get_merged_font(name, merge) function beautiful.get_merged_font(name, merge)
local font = beautiful.get_font(name) local font = beautiful.get_font(name)
local merge = Pango.FontDescription.from_string(merge) merge = Pango.FontDescription.from_string(merge)
local merged = font:copy_static() local merged = font:copy_static()
merged:merge(merge, true) merged:merge(merge, true)
return beautiful.get_font(merged:to_string()) return beautiful.get_font(merged:to_string())

View File

@ -8,7 +8,6 @@
---------------------------------------------------------------------------- ----------------------------------------------------------------------------
-- Grab environment -- Grab environment
local print = print
local awesome = awesome local awesome = awesome
local round = require("awful.util").round local round = require("awful.util").round
local gears_debug = require("gears.debug") local gears_debug = require("gears.debug")

View File

@ -21,21 +21,6 @@ local setmetatable = setmetatable
local string = string local string = string
local table = table local table = table
local math = math local math = math
local io = io
-- Returns a table whose element is a path used for icon lookup.
-- The names of the directories and the order of them are based on the spec.
local get_default_base_directories = function()
local dirs = {}
table.insert(dirs, GLib.get_home_dir() .. "/.icons")
for _, dir in ipairs(GLib.get_system_data_dirs()) do
table.insert(dirs, dir .. "/icons")
end
table.insert(dirs, "/usr/share/pixmaps")
return dirs
end
local get_pragmatic_base_directories = function() local get_pragmatic_base_directories = function()
local dirs = {} local dirs = {}
@ -98,8 +83,8 @@ local index_theme_cache = {}
-- @tparam table base_directories Paths used for lookup -- @tparam table base_directories Paths used for lookup
-- @treturn table An instance of the class `icon_theme` -- @treturn table An instance of the class `icon_theme`
icon_theme.new = function(icon_theme_name, base_directories) icon_theme.new = function(icon_theme_name, base_directories)
local icon_theme_name = icon_theme_name or beautiful.icon_theme or get_default_icon_theme_name() icon_theme_name = icon_theme_name or beautiful.icon_theme or get_default_icon_theme_name()
local base_directories = base_directories or get_pragmatic_base_directories() base_directories = base_directories or get_pragmatic_base_directories()
local self = {} local self = {}
self.icon_theme_name = icon_theme_name self.icon_theme_name = icon_theme_name
@ -238,10 +223,10 @@ end
-- @tparam number icon_size Prefereable icon size -- @tparam number icon_size Prefereable icon size
-- @treturn string Absolute path to the icon file, or nil if not found -- @treturn string Absolute path to the icon file, or nil if not found
function icon_theme:find_icon_path(icon_name, icon_size) function icon_theme:find_icon_path(icon_name, icon_size)
icon_size = icon_size or 16
if not icon_name or icon_name == "" then if not icon_name or icon_name == "" then
return nil return nil
end end
local icon_size = icon_size or 16
local filename = find_icon_path_helper(self, icon_name, icon_size) local filename = find_icon_path_helper(self, icon_name, icon_size)
if filename then if filename then

View File

@ -189,7 +189,7 @@ local function menulist_update(query, scr)
end end
-- Add the applications according to their name and cmdline -- Add the applications according to their name and cmdline
for i, v in ipairs(menubar.menu_entries) do for _, v in ipairs(menubar.menu_entries) do
v.focused = false v.focused = false
if not current_category or v.category == current_category then if not current_category or v.category == current_category then
if string.match(v.name, pattern) if string.match(v.name, pattern)
@ -205,7 +205,7 @@ local function menulist_update(query, scr)
end end
-- Now add items from match_inside to shownitems -- Now add items from match_inside to shownitems
for i, v in ipairs(match_inside) do for _, v in ipairs(match_inside) do
table.insert(shownitems, v) table.insert(shownitems, v)
end end
@ -315,7 +315,7 @@ function menubar.show(scr)
local prompt_args = menubar.prompt_args or {} local prompt_args = menubar.prompt_args or {}
prompt_args.prompt = "Run: " prompt_args.prompt = "Run: "
awful.prompt.run(prompt_args, instance.prompt.widget, awful.prompt.run(prompt_args, instance.prompt.widget,
function(s) end, -- exe_callback function set to do nothing function() end, -- exe_callback function set to do nothing
awful.completion.shell, -- completion_callback awful.completion.shell, -- completion_callback
awful.util.get_cache_dir() .. "/history_menu", awful.util.get_cache_dir() .. "/history_menu",
nil, nil,

View File

@ -83,7 +83,7 @@ local function get_icon_lookup_path()
table.insert(paths, 1, glib.get_user_data_dir()) table.insert(paths, 1, glib.get_user_data_dir())
table.insert(paths, 1, glib.build_filenamev({glib.get_home_dir(), table.insert(paths, 1, glib.build_filenamev({glib.get_home_dir(),
'.icons'})) '.icons'}))
for k,dir in ipairs(paths) do for _,dir in ipairs(paths) do
local icons_dir = glib.build_filenamev({dir, 'icons'}) local icons_dir = glib.build_filenamev({dir, 'icons'})
if awful_util.dir_readable(icons_dir) then if awful_util.dir_readable(icons_dir) then
if icon_theme then if icon_theme then
@ -96,14 +96,14 @@ local function get_icon_lookup_path()
glib.build_filenamev({icons_dir, 'hicolor'})) glib.build_filenamev({icons_dir, 'hicolor'}))
end end
end end
for i, icon_theme_directory in ipairs(icon_theme_paths) do for _, icon_theme_directory in ipairs(icon_theme_paths) do
for j, size in ipairs(all_icon_sizes) do for _, size in ipairs(all_icon_sizes) do
add_if_readable(icon_lookup_path, add_if_readable(icon_lookup_path,
glib.build_filenamev({icon_theme_directory, glib.build_filenamev({icon_theme_directory,
size, 'apps'})) size, 'apps'}))
end end
end end
for k,dir in ipairs(paths)do for _,dir in ipairs(paths)do
-- lowest priority fallbacks -- lowest priority fallbacks
add_if_readable(icon_lookup_path, add_if_readable(icon_lookup_path,
glib.build_filenamev({dir, 'pixmaps'})) glib.build_filenamev({dir, 'pixmaps'}))
@ -127,7 +127,7 @@ function utils.lookup_icon_uncached(icon_file)
-- supported, do not perform a lookup. -- supported, do not perform a lookup.
return awful_util.file_readable(icon_file) and icon_file or nil return awful_util.file_readable(icon_file) and icon_file or nil
else else
for i, directory in ipairs(get_icon_lookup_path()) do for _, directory in ipairs(get_icon_lookup_path()) do
if is_format_supported(icon_file) and if is_format_supported(icon_file) and
awful_util.file_readable(directory .. "/" .. icon_file) then awful_util.file_readable(directory .. "/" .. icon_file) then
return directory .. "/" .. icon_file return directory .. "/" .. icon_file
@ -170,6 +170,7 @@ function utils.parse(file)
for line in io.lines(file) do for line in io.lines(file) do
if line:find("^%s*#") then if line:find("^%s*#") then
-- Skip comments. -- Skip comments.
(function() end)() -- I haven't found a nice way to silence luacheck here
elseif not desktop_entry and line == "[Desktop Entry]" then elseif not desktop_entry and line == "[Desktop Entry]" then
desktop_entry = true desktop_entry = true
else else
@ -260,7 +261,7 @@ end
-- @treturn int Text width. -- @treturn int Text width.
function utils.compute_textbox_width(textbox, s) function utils.compute_textbox_width(textbox, s)
s = s or mouse.screen s = s or mouse.screen
local w, h = textbox:get_preferred_size(s) local w, _ = textbox:get_preferred_size(s)
return w return w
end end

View File

@ -4,7 +4,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local util = require("awful.util") local util = require("awful.util")
local say = require("say")
describe("awful.util", function() describe("awful.util", function()
it("table.keys_filter", function() it("table.keys_filter", function()

View File

@ -162,7 +162,7 @@ describe("gears.color", function()
describe("create_opaque_pattern", function() describe("create_opaque_pattern", function()
-- Assertion to check if a pattern is opaque -- Assertion to check if a pattern is opaque
local function opaque(state, arguments) local function opaque(_, arguments)
assert(arguments.n >= 1, say("assertions.argtolittle", { "opaque", 1, tostring(arguments.n) })) assert(arguments.n >= 1, say("assertions.argtolittle", { "opaque", 1, tostring(arguments.n) }))
local pattern = color.create_opaque_pattern(arguments[1]) local pattern = color.create_opaque_pattern(arguments[1])
return pattern ~= nil return pattern ~= nil

View File

@ -54,7 +54,7 @@ describe("gears.object", function()
obj:weak_connect_signal("signal", cb) obj:weak_connect_signal("signal", cb)
-- Check that the GC doesn't disconnect the signal -- Check that the GC doesn't disconnect the signal
for i = 1, 10 do for _ = 1, 10 do
collectgarbage("collect") collectgarbage("collect")
end end
@ -149,7 +149,8 @@ describe("gears.object", function()
finalized = true finalized = true
end end
if _VERSION <= "Lua 5.1" then if _VERSION <= "Lua 5.1" then
local userdata = newproxy(true) -- luacheck: globals newproxy
userdata = newproxy(true)
getmetatable(userdata).__gc = gc getmetatable(userdata).__gc = gc
getmetatable(userdata).callback = callback getmetatable(userdata).callback = callback
else else

View File

@ -6,24 +6,24 @@
-- Hack so that beautiful can be loaded -- Hack so that beautiful can be loaded
_G.awesome = { _G.awesome = {
xrdb_get_value = function() end, xrdb_get_value = function() end,
connect_signal = function(...) end, connect_signal = function() end,
register_xproperty = function(...) end register_xproperty = function() end
} }
-- Additional hacks to load menubar -- Additional hacks to load menubar
_G.screen = { _G.screen = {
add_signal = function(...) end, add_signal = function() end,
count = function() return 0 end count = function() return 0 end
} }
_G.client = { _G.client = {
connect_signal = function(...) end, connect_signal = function() end,
add_signal = function(...) end add_signal = function() end
} }
_G.tag = { _G.tag = {
connect_signal = function(...) end, connect_signal = function() end,
add_signal = function(...) end add_signal = function() end
} }
_G.root = { _G.root = {
cursor = function(...) end cursor = function() end
} }
local os = os local os = os

View File

@ -7,7 +7,6 @@ local hierarchy = require("wibox.hierarchy")
local Region = require("lgi").cairo.Region local Region = require("lgi").cairo.Region
local matrix = require("gears.matrix") local matrix = require("gears.matrix")
local object = require("gears.object")
local utils = require("wibox.test_utils") local utils = require("wibox.test_utils")
local function make_widget(children) local function make_widget(children)
@ -18,8 +17,8 @@ local function make_widget(children)
return result return result
end end
local function make_child(widget, width, height, matrix) local function make_child(widget, width, height, mat)
return { _widget = widget, _width = width, _height = height, _matrix = matrix } return { _widget = widget, _width = width, _height = height, _matrix = mat }
end end
describe("wibox.hierarchy", function() describe("wibox.hierarchy", function()
@ -95,7 +94,7 @@ describe("wibox.hierarchy", function()
end end
end end
local context = {} local context = {}
local instance = hierarchy.new(context, parent, 15, 20, redraw, layout, extra_arg) local instance = hierarchy.new(context, parent, 15, 20, redraw, layout, extra_arg) -- luacheck: no unused
-- There should be a connection -- There should be a connection
parent:emit_signal("widget::redraw_needed") parent:emit_signal("widget::redraw_needed")
@ -140,7 +139,7 @@ describe("wibox.hierarchy", function()
assert.is.equal(#children, 1) assert.is.equal(#children, 1)
hierarchy_intermediate = children[1] hierarchy_intermediate = children[1]
local children = hierarchy_intermediate:get_children() children = hierarchy_intermediate:get_children()
assert.is.equal(#children, 1) assert.is.equal(#children, 1)
hierarchy_child = children[1] hierarchy_child = children[1]
end) end)

View File

@ -4,7 +4,6 @@
--------------------------------------------------------------------------- ---------------------------------------------------------------------------
local object = require("gears.object") local object = require("gears.object")
local cache = require("gears.cache")
local matrix_equals = require("gears.matrix").equals local matrix_equals = require("gears.matrix").equals
local base = require("wibox.widget.base") local base = require("wibox.widget.base")
local say = require("say") local say = require("say")
@ -53,11 +52,11 @@ local function widget_layout(state, arguments)
fits = false fits = false
else else
for i = 1, #children do for i = 1, #children do
local child, expected = children[i], expected[i] local child, exp = children[i], expected[i]
if child._widget ~= expected._widget or if child._widget ~= exp._widget or
child._width ~= expected._width or child._width ~= exp._width or
child._height ~= expected._height or child._height ~= exp._height or
not matrix_equals(child._matrix, expected._matrix) then not matrix_equals(child._matrix, exp._matrix) then
fits = false fits = false
break break
end end

View File

@ -2,7 +2,7 @@
-- Default awesome theme -- -- Default awesome theme --
--------------------------- ---------------------------
theme = {} local theme = {}
theme.font = "sans 8" theme.font = "sans 8"

View File

@ -5,7 +5,7 @@
-- If you want SVGs and extras, get them from garoth.com/awesome/sky-theme -- If you want SVGs and extras, get them from garoth.com/awesome/sky-theme
-- BASICS -- BASICS
theme = {} local theme = {}
theme.font = "sans 8" theme.font = "sans 8"
theme.bg_focus = "#e2eeea" theme.bg_focus = "#e2eeea"

View File

@ -7,7 +7,7 @@
-- * http://awesome.naquadah.org/wiki/Nice_Icons -- * http://awesome.naquadah.org/wiki/Nice_Icons
-- {{{ Main -- {{{ Main
theme = {} local theme = {}
theme.wallpaper = "@AWESOME_THEMES_PATH@/zenburn/zenburn-background.png" theme.wallpaper = "@AWESOME_THEMES_PATH@/zenburn/zenburn-background.png"
-- }}} -- }}}