Merge pull request #687 from psychon/fix-harmless-luacheck-warnings
Fix harmless luacheck warnings
This commit is contained in:
commit
66b93ffded
|
@ -79,7 +79,7 @@ install:
|
|||
|
||||
script:
|
||||
- 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:
|
||||
# Push updated API docs for relevant branches, e.g. non-PRs builds on master.
|
||||
|
|
|
@ -297,7 +297,7 @@ globalkeys = awful.util.table.join(
|
|||
|
||||
awful.key({ modkey, "Control" }, "n",
|
||||
function ()
|
||||
c = awful.client.restore()
|
||||
local c = awful.client.restore()
|
||||
-- Focus restored client
|
||||
if c then
|
||||
client.focus = c
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
local client = client
|
||||
local screen = screen
|
||||
local aclient = require("awful.client")
|
||||
local atag = require("awful.tag")
|
||||
local timer = require("gears.timer")
|
||||
|
|
|
@ -44,10 +44,10 @@ function button.new(mod, _button, press, release)
|
|||
ret[#ret + 1] = capi.button({ modifiers = util.table.join(mod, set),
|
||||
button = _button })
|
||||
if press then
|
||||
ret[#ret]:connect_signal("press", function(bobj, ...) press(...) end)
|
||||
ret[#ret]:connect_signal("press", function(_, ...) press(...) end)
|
||||
end
|
||||
if release then
|
||||
ret[#ret]:connect_signal("release", function (bobj, ...) release(...) end)
|
||||
ret[#ret]:connect_signal("release", function (_, ...) release(...) end)
|
||||
end
|
||||
end
|
||||
return ret
|
||||
|
|
|
@ -29,7 +29,7 @@ local capi =
|
|||
local screen
|
||||
do
|
||||
screen = setmetatable({}, {
|
||||
__index = function(t, k)
|
||||
__index = function(_, k)
|
||||
screen = require("awful.screen")
|
||||
return screen[k]
|
||||
end,
|
||||
|
@ -91,7 +91,7 @@ function client.urgent.get()
|
|||
else
|
||||
-- fallback behaviour: iterate through clients and get the first urgent
|
||||
local clients = capi.client.get()
|
||||
for k, cl in pairs(clients) do
|
||||
for _, cl in pairs(clients) do
|
||||
if cl.urgent then
|
||||
return cl
|
||||
end
|
||||
|
@ -171,21 +171,21 @@ end
|
|||
|
||||
--- 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,
|
||||
-- 1 will return second, etc.
|
||||
-- @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
|
||||
-- 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
|
||||
local counter = 0
|
||||
local vc = client.visible(screen, true)
|
||||
for k, c in ipairs(client.data.focus) do
|
||||
if c.screen == screen then
|
||||
local vc = client.visible(s, true)
|
||||
for _, c in ipairs(client.data.focus) do
|
||||
if c.screen == s 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 counter == idx then
|
||||
return c
|
||||
|
@ -200,9 +200,9 @@ function client.focus.history.get(screen, idx, filter)
|
|||
end
|
||||
-- Argh nobody found in history, give the first one visible if there is one
|
||||
-- that passes the filter.
|
||||
local filter = filter or client.focus.filter
|
||||
filter = filter or client.focus.filter
|
||||
if counter == 0 then
|
||||
for k, v in ipairs(vc) do
|
||||
for _, v in ipairs(vc) do
|
||||
if filter(v) then
|
||||
return v
|
||||
end
|
||||
|
@ -223,13 +223,13 @@ end
|
|||
|
||||
--- 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)
|
||||
-- @treturn table A table with all visible clients.
|
||||
function client.visible(screen, stacked)
|
||||
local cls = capi.client.get(screen, stacked)
|
||||
function client.visible(s, stacked)
|
||||
local cls = capi.client.get(s, stacked)
|
||||
local vcls = {}
|
||||
for k, c in pairs(cls) do
|
||||
for _, c in pairs(cls) do
|
||||
if c:isvisible() then
|
||||
table.insert(vcls, c)
|
||||
end
|
||||
|
@ -239,14 +239,14 @@ end
|
|||
|
||||
--- 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)
|
||||
-- @treturn table A table with all visible and tiled clients.
|
||||
function client.tiled(screen, stacked)
|
||||
local clients = client.visible(screen, stacked)
|
||||
function client.tiled(s, stacked)
|
||||
local clients = client.visible(s, stacked)
|
||||
local tclients = {}
|
||||
-- Remove floating clients
|
||||
for k, c in pairs(clients) do
|
||||
for _, c in pairs(clients) do
|
||||
if not client.floating.get(c)
|
||||
and not c.fullscreen
|
||||
and not c.maximized_vertical
|
||||
|
@ -261,7 +261,7 @@ end
|
|||
-- 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.
|
||||
-- @client[opt] c The client.
|
||||
-- @client[opt] sel The client.
|
||||
-- @tparam[opt=false] boolean stacked Use stacking order? (top to bottom)
|
||||
-- @return A client, or nil if no client is available.
|
||||
--
|
||||
|
@ -269,15 +269,15 @@ end
|
|||
-- awful.client.next(1)
|
||||
-- -- focus the previous
|
||||
-- awful.client.next(-1)
|
||||
function client.next(i, c, stacked)
|
||||
function client.next(i, sel, stacked)
|
||||
-- Get currently focused client
|
||||
local sel = c or capi.client.focus
|
||||
sel = sel or capi.client.focus
|
||||
if sel then
|
||||
-- Get all visible clients
|
||||
local cls = client.visible(sel.screen, stacked)
|
||||
local fcls = {}
|
||||
-- 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
|
||||
table.insert(fcls, c)
|
||||
end
|
||||
|
@ -385,9 +385,9 @@ end
|
|||
|
||||
--- 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".
|
||||
-- @client[opt] c The client.
|
||||
function client.swap.global_bydirection(dir, c)
|
||||
local sel = c or capi.client.focus
|
||||
-- @client[opt] sel The client.
|
||||
function client.swap.global_bydirection(dir, sel)
|
||||
sel = sel or capi.client.focus
|
||||
local scr = sel and sel.screen or screen.focused()
|
||||
|
||||
if sel then
|
||||
|
@ -463,7 +463,7 @@ end
|
|||
-- @client c The window to set as master.
|
||||
function client.setmaster(c)
|
||||
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)
|
||||
end
|
||||
end
|
||||
|
@ -472,7 +472,7 @@ end
|
|||
-- @client c The window to set as slave.
|
||||
function client.setslave(c)
|
||||
local cls = capi.client.get(c.screen)
|
||||
for k, v in pairs(cls) do
|
||||
for _, v in pairs(cls) do
|
||||
c:swap(v)
|
||||
end
|
||||
end
|
||||
|
@ -565,7 +565,7 @@ end
|
|||
function client.mark(c)
|
||||
local cl = c or capi.client.focus
|
||||
if cl then
|
||||
for k, v in pairs(client.data.marked) do
|
||||
for _, v in pairs(client.data.marked) do
|
||||
if cl == v then
|
||||
return false
|
||||
end
|
||||
|
@ -601,7 +601,7 @@ end
|
|||
function client.ismarked(c)
|
||||
local cl = c or capi.client.focus
|
||||
if cl then
|
||||
for k, v in pairs(client.data.marked) do
|
||||
for _, v in pairs(client.data.marked) do
|
||||
if cl == v then
|
||||
return true
|
||||
end
|
||||
|
@ -613,8 +613,7 @@ end
|
|||
--- Toggle a client as marked.
|
||||
-- @client c The client to toggle mark.
|
||||
function client.togglemarked(c)
|
||||
local cl = c or capi.client.focus
|
||||
|
||||
c = c or capi.client.focus
|
||||
if not client.mark(c) then
|
||||
client.unmark(c)
|
||||
end
|
||||
|
@ -623,11 +622,11 @@ end
|
|||
--- Return the marked clients and empty the marked table.
|
||||
-- @return A table with all marked clients.
|
||||
function client.getmarked()
|
||||
for k, v in pairs(client.data.marked) do
|
||||
for _, v in pairs(client.data.marked) do
|
||||
v:emit_signal("unmarked")
|
||||
end
|
||||
|
||||
t = client.data.marked
|
||||
local t = client.data.marked
|
||||
client.data.marked = {}
|
||||
return t
|
||||
end
|
||||
|
@ -637,7 +636,7 @@ end
|
|||
-- @client c A client.
|
||||
-- @param s True or false.
|
||||
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
|
||||
client.property.set(c, "floating", s)
|
||||
local scr = c.screen
|
||||
|
@ -655,12 +654,12 @@ local function store_floating_geometry(c)
|
|||
end
|
||||
|
||||
-- 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)
|
||||
client.property.set(c, "floating_geometry", c:geometry())
|
||||
c:disconnect_signal("property::border_width", store_init_geometry)
|
||||
end
|
||||
c:connect_signal("property::border_width", store_init_geometry)
|
||||
cl:connect_signal("property::border_width", store_init_geometry)
|
||||
end)
|
||||
|
||||
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.
|
||||
-- @client c The client.
|
||||
function client.isfixed(c)
|
||||
local c = c or capi.client.focus
|
||||
c = c or capi.client.focus
|
||||
if not c then return end
|
||||
local h = c.size_hints
|
||||
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
|
||||
-- normal.
|
||||
function client.floating.get(c)
|
||||
local c = c or capi.client.focus
|
||||
c = c or capi.client.focus
|
||||
if c then
|
||||
local value = client.property.get(c, "floating")
|
||||
if value ~= nil then
|
||||
|
@ -708,7 +707,7 @@ end
|
|||
--- Toggle the floating state of a client between 'auto' and 'true'.
|
||||
-- @client c A client.
|
||||
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 client.floating.get(c) then
|
||||
client.floating.set(c, false)
|
||||
|
@ -730,11 +729,10 @@ function client.restore(s)
|
|||
s = s or screen.focused()
|
||||
local cls = capi.client.get(s)
|
||||
local tags = tag.selectedlist(s)
|
||||
local mcls = {}
|
||||
for k, c in pairs(cls) do
|
||||
for _, c in pairs(cls) do
|
||||
local ctags = c:tags()
|
||||
if c.minimized then
|
||||
for k, t in ipairs(tags) do
|
||||
for _, t in ipairs(tags) do
|
||||
if util.table.hasitem(ctags, t) then
|
||||
c.minimized = false
|
||||
return c
|
||||
|
@ -749,7 +747,7 @@ end
|
|||
-- @param set the set of numbers to normalize
|
||||
-- @param num the number of numbers to normalize
|
||||
local function normalize(set, num)
|
||||
local num = num or #set
|
||||
num = num or #set
|
||||
local total = 0
|
||||
if num then
|
||||
for i = 1,num do
|
||||
|
@ -759,7 +757,7 @@ local function normalize(set, num)
|
|||
set[i] = set[i] / total
|
||||
end
|
||||
else
|
||||
for i,v in ipairs(set) do
|
||||
for _,v in ipairs(set) do
|
||||
total = total + v
|
||||
end
|
||||
|
||||
|
@ -777,7 +775,7 @@ end
|
|||
-- @return idx index of the client in the column
|
||||
-- @return num the number of visible clients in the column
|
||||
function client.idx(c)
|
||||
local c = c or capi.client.focus
|
||||
c = c or capi.client.focus
|
||||
if not c then return end
|
||||
|
||||
-- Only check the tiled clients, the others un irrelevant
|
||||
|
@ -836,7 +834,7 @@ end
|
|||
-- @client c the client
|
||||
function client.setwfact(wfact, c)
|
||||
-- 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
|
||||
|
||||
local w = client.idx(c)
|
||||
|
@ -845,9 +843,6 @@ function client.setwfact(wfact, c)
|
|||
|
||||
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
|
||||
local data = tag.getproperty(t, "windowfact") or {}
|
||||
local colfact = data[w.col]
|
||||
|
@ -890,17 +885,16 @@ end
|
|||
-- @param add amount to increase the client's window
|
||||
-- @client c the client
|
||||
function client.incwfact(add, c)
|
||||
local c = c or capi.client.focus
|
||||
c = c or capi.client.focus
|
||||
if not c then return end
|
||||
|
||||
local t = tag.selected(c.screen)
|
||||
|
||||
local w = client.idx(c)
|
||||
|
||||
local nmaster = tag.getnmaster(t)
|
||||
local data = tag.getproperty(t, "windowfact") 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
|
||||
|
||||
-- keep our ratios normalized
|
||||
|
@ -982,15 +976,15 @@ end
|
|||
--- Set a client property to be persistent across restarts (via X properties).
|
||||
--
|
||||
-- @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".
|
||||
function client.property.persist(prop, type)
|
||||
function client.property.persist(prop, kind)
|
||||
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
|
||||
|
||||
-- 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
|
||||
c:set_xproperty(xprop, client.data.properties[c][prop])
|
||||
end
|
||||
|
@ -1017,7 +1011,7 @@ end
|
|||
function client.iterate(filter, start, s)
|
||||
local clients = capi.client.get(s)
|
||||
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)
|
||||
end
|
||||
|
||||
|
@ -1041,14 +1035,14 @@ function client.run_or_raise(cmd, matcher, merge)
|
|||
local findex = util.table.hasitem(clients, capi.client.focus) or 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)
|
||||
return
|
||||
end
|
||||
|
||||
else
|
||||
-- client not found, spawn it
|
||||
spawn(cmd)
|
||||
end
|
||||
end
|
||||
|
||||
--- Get a matching transient_for client (if any).
|
||||
-- @client c The client.
|
||||
|
|
|
@ -20,11 +20,11 @@ shape.update = {}
|
|||
|
||||
--- Get one of a client's shapes and transform it to include window decorations
|
||||
-- @client c The client whose shape should be retrieved
|
||||
-- @tparam string shape Either "bounding" or "clip"
|
||||
function shape.get_transformed(c, shape)
|
||||
local border = shape == "bounding" and c.border_width or 0
|
||||
local shape = surface.load_silently(c["client_shape_" .. shape], false)
|
||||
if not shape then return end
|
||||
-- @tparam string shape_name Either "bounding" or "clip"
|
||||
function shape.get_transformed(c, shape_name)
|
||||
local border = shape_name == "bounding" and c.border_width or 0
|
||||
local shape_img = surface.load_silently(c["client_shape_" .. shape_name], false)
|
||||
if not shape_img then return end
|
||||
|
||||
-- Get information about various sizes on the client
|
||||
local geom = c:geometry()
|
||||
|
@ -44,7 +44,7 @@ function shape.get_transformed(c, shape)
|
|||
|
||||
-- Draw the client's shape in the middle
|
||||
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:fill()
|
||||
|
||||
|
|
|
@ -18,7 +18,6 @@ local math = math
|
|||
local print = print
|
||||
local pairs = pairs
|
||||
local string = string
|
||||
local util = require("awful.util")
|
||||
|
||||
local completion = {}
|
||||
|
||||
|
@ -128,7 +127,6 @@ function completion.shell(command, cur_pos, ncomp, shell)
|
|||
end
|
||||
local c, err = io.popen(shell_cmd .. " | sort -u")
|
||||
local output = {}
|
||||
i = 0
|
||||
if c then
|
||||
while true do
|
||||
local line = c:read("*line")
|
||||
|
@ -168,7 +166,7 @@ end
|
|||
-- @param ncomp The number of yet requested completion using current text.
|
||||
-- @param keywords The keywords table uised for completion.
|
||||
-- @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
|
||||
if #keywords == 0 then
|
||||
return text, #text + 1
|
||||
|
|
|
@ -70,7 +70,6 @@ local function fullscreen(window, set)
|
|||
if set then
|
||||
store_geometry(window, "fullscreen")
|
||||
data[window].fullscreen.border_width = window.border_width
|
||||
local g = screen[window.screen].geometry
|
||||
window:geometry(screen[window.screen].geometry)
|
||||
window.border_width = 0
|
||||
elseif data[window] and data[window].fullscreen then
|
||||
|
@ -163,7 +162,7 @@ end
|
|||
-- @tparam string context The context where this signal was used.
|
||||
-- @tparam[opt] table hints A table with additional hints:
|
||||
-- @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
|
||||
client.focus = c
|
||||
end
|
||||
|
|
|
@ -159,7 +159,7 @@ local function sort_hotkeys(target)
|
|||
for group, _ in pairs(group_list) do
|
||||
if target[group] then
|
||||
local sorted_table = {}
|
||||
for index, key in pairs(target[group]) do
|
||||
for _, key in pairs(target[group]) do
|
||||
table.insert(sorted_table, key)
|
||||
end
|
||||
table.sort(
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
-- TODO: This is a hack for backwards-compatibility with 3.5, remove!
|
||||
local util = require("awful.util")
|
||||
local gtimer = require("gears.timer")
|
||||
function timer(...)
|
||||
function timer(...) -- luacheck: ignore
|
||||
util.deprecate("gears.timer")
|
||||
return gtimer(...)
|
||||
end
|
||||
|
|
|
@ -54,10 +54,10 @@ function key.new(mod, _key, press, release, data)
|
|||
ret[#ret + 1] = capi.key({ modifiers = util.table.join(mod, set),
|
||||
key = _key })
|
||||
if press then
|
||||
ret[#ret]:connect_signal("press", function(kobj, ...) press(...) end)
|
||||
ret[#ret]:connect_signal("press", function(_, ...) press(...) end)
|
||||
end
|
||||
if release then
|
||||
ret[#ret]:connect_signal("release", function(kobj, ...) release(...) end)
|
||||
ret[#ret]:connect_signal("release", function(_, ...) release(...) end)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ local keygrabbing = false
|
|||
|
||||
|
||||
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
|
||||
if keygrabber_function(mod, key, event) ~= false then
|
||||
break
|
||||
|
|
|
@ -75,7 +75,7 @@ function layout.inc(i, s, layouts)
|
|||
layouts, i, s = i, s, layouts
|
||||
end
|
||||
local t = tag.selected(s)
|
||||
local layouts = layouts or layout.layouts
|
||||
layouts = layouts or layout.layouts
|
||||
if t then
|
||||
local curlayout = layout.get(s)
|
||||
local curindex
|
||||
|
@ -192,7 +192,7 @@ end
|
|||
-- @param _layout The layout.
|
||||
-- @return The layout name.
|
||||
function layout.getname(_layout)
|
||||
local _layout = _layout or layout.get()
|
||||
_layout = _layout or layout.get()
|
||||
return _layout.name
|
||||
end
|
||||
|
||||
|
|
|
@ -109,7 +109,7 @@ local function do_corner(p, orientation)
|
|||
end
|
||||
|
||||
for i, c in ipairs(cls) do
|
||||
local g = nil
|
||||
local g
|
||||
-- Handle master window
|
||||
if i == 1 then
|
||||
g = {
|
||||
|
|
|
@ -24,7 +24,7 @@ local function do_fair(p, orientation)
|
|||
end
|
||||
|
||||
if #cls > 0 then
|
||||
local rows, cols = 0, 0
|
||||
local rows, cols
|
||||
if #cls == 2 then
|
||||
rows, cols = 1, 2
|
||||
else
|
||||
|
@ -36,11 +36,11 @@ local function do_fair(p, orientation)
|
|||
k = k - 1
|
||||
local g = {}
|
||||
|
||||
local row, col = 0, 0
|
||||
local row, col
|
||||
row = k % rows
|
||||
col = math.floor(k / rows)
|
||||
|
||||
local lrows, lcols = 0, 0
|
||||
local lrows, lcols
|
||||
if k >= rows * cols - rows then
|
||||
lrows = #cls - (rows * cols - rows)
|
||||
lcols = cols
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local math = math
|
||||
local ipairs = ipairs
|
||||
local capi =
|
||||
{
|
||||
|
@ -44,7 +43,7 @@ function floating.mouse_resize_handler(c, corner, x, y)
|
|||
capi.mousegrabber.run(function (_mouse)
|
||||
_mouse.x = _mouse.x + coordinates_delta.x
|
||||
_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
|
||||
local ng
|
||||
prev_coords = { x =_mouse.x, y = _mouse.y }
|
||||
|
|
|
@ -32,7 +32,7 @@ function magnifier.mouse_resize_handler(c, corner, x, y)
|
|||
|
||||
local prev_coords = {}
|
||||
capi.mousegrabber.run(function (_mouse)
|
||||
for k, v in ipairs(_mouse.buttons) do
|
||||
for _, v in ipairs(_mouse.buttons) do
|
||||
if v then
|
||||
prev_coords = { x =_mouse.x, y = _mouse.y }
|
||||
local dx = center_x - _mouse.x
|
||||
|
@ -126,13 +126,12 @@ function magnifier.arrange(p)
|
|||
-- Then move clients that are after focused client.
|
||||
-- So the next focused window will be the one at the top of the screen.
|
||||
for k = 1, fidx - 1 do
|
||||
local g = {
|
||||
p.geometries[cls[k]] = {
|
||||
x = geometry.x,
|
||||
y = geometry.y,
|
||||
width = geometry.width,
|
||||
height = geometry.height
|
||||
}
|
||||
p.geometries[cls[k]] = g
|
||||
geometry.y = geometry.y + geometry.height
|
||||
end
|
||||
end
|
||||
|
|
|
@ -9,7 +9,6 @@
|
|||
|
||||
-- Grab environment we need
|
||||
local pairs = pairs
|
||||
local client = require("awful.client")
|
||||
|
||||
local max = {}
|
||||
|
||||
|
@ -22,7 +21,7 @@ local function fmax(p, fs)
|
|||
area = p.workarea
|
||||
end
|
||||
|
||||
for k, c in pairs(p.clients) do
|
||||
for _, c in pairs(p.clients) do
|
||||
local g = {
|
||||
x = area.x,
|
||||
y = area.y,
|
||||
|
|
|
@ -26,8 +26,8 @@ local tile = {}
|
|||
--- Jump mouse cursor to the client's corner when resizing it.
|
||||
tile.resize_jump_to_corner = true
|
||||
|
||||
local function mouse_resize_handler(c, corner, x, y, orientation)
|
||||
local orientation = orientation or "tile"
|
||||
local function mouse_resize_handler(c, _, _, _, orientation)
|
||||
orientation = orientation or "tile"
|
||||
local wa = capi.screen[c.screen].workarea
|
||||
local mwfact = tag.getmwfact()
|
||||
local cursor
|
||||
|
@ -87,47 +87,46 @@ local function mouse_resize_handler(c, corner, x, y, orientation)
|
|||
capi.mousegrabber.run(function (_mouse)
|
||||
_mouse.x = _mouse.x + coordinates_delta.x
|
||||
_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
|
||||
prev_coords = { x =_mouse.x, y = _mouse.y }
|
||||
local fact_x = (_mouse.x - wa.x) / wa.width
|
||||
local fact_y = (_mouse.y - wa.y) / wa.height
|
||||
local mwfact
|
||||
|
||||
local g = c:geometry()
|
||||
local new_mwfact
|
||||
|
||||
local geom = c:geometry()
|
||||
|
||||
-- we have to make sure we're not on the last visible client where we have to use different settings.
|
||||
local wfact
|
||||
local wfact_x, wfact_y
|
||||
if (g.y+g.height+15) > (wa.y+wa.height) then
|
||||
wfact_y = (g.y + g.height - _mouse.y) / wa.height
|
||||
if (geom.y+geom.height+15) > (wa.y+wa.height) then
|
||||
wfact_y = (geom.y + geom.height - _mouse.y) / wa.height
|
||||
else
|
||||
wfact_y = (_mouse.y - g.y) / wa.height
|
||||
wfact_y = (_mouse.y - geom.y) / wa.height
|
||||
end
|
||||
|
||||
if (g.x+g.width+15) > (wa.x+wa.width) then
|
||||
wfact_x = (g.x + g.width - _mouse.x) / wa.width
|
||||
if (geom.x+geom.width+15) > (wa.x+wa.width) then
|
||||
wfact_x = (geom.x + geom.width - _mouse.x) / wa.width
|
||||
else
|
||||
wfact_x = (_mouse.x - g.x) / wa.width
|
||||
wfact_x = (_mouse.x - geom.x) / wa.width
|
||||
end
|
||||
|
||||
|
||||
if orientation == "tile" then
|
||||
mwfact = fact_x
|
||||
new_mwfact = fact_x
|
||||
wfact = wfact_y
|
||||
elseif orientation == "left" then
|
||||
mwfact = 1 - fact_x
|
||||
new_mwfact = 1 - fact_x
|
||||
wfact = wfact_y
|
||||
elseif orientation == "bottom" then
|
||||
mwfact = fact_y
|
||||
new_mwfact = fact_y
|
||||
wfact = wfact_x
|
||||
else
|
||||
mwfact = 1 - fact_y
|
||||
new_mwfact = 1 - fact_y
|
||||
wfact = wfact_x
|
||||
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)
|
||||
return true
|
||||
end
|
||||
|
@ -200,15 +199,11 @@ local function do_tile(param, orientation)
|
|||
orientation = orientation or "right"
|
||||
|
||||
-- This handles all different orientations.
|
||||
local height = "height"
|
||||
local width = "width"
|
||||
local x = "x"
|
||||
local y = "y"
|
||||
if orientation == "top" or orientation == "bottom" then
|
||||
height = "width"
|
||||
width = "height"
|
||||
x = "y"
|
||||
y = "x"
|
||||
end
|
||||
|
||||
local gs = param.geometries
|
||||
|
@ -236,7 +231,7 @@ local function do_tile(param, orientation)
|
|||
|
||||
local grow_master = tag.getmfpol(t) == "expand"
|
||||
-- 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
|
||||
local size = wa[width]
|
||||
if nother > 0 or not grow_master then
|
||||
|
|
|
@ -99,7 +99,7 @@ end
|
|||
|
||||
|
||||
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"
|
||||
if dir == "x" then a, b = b, a end
|
||||
|
||||
|
@ -191,7 +191,7 @@ local function check_access_key(_menu, key)
|
|||
end
|
||||
|
||||
|
||||
local function grabber(_menu, mod, key, event)
|
||||
local function grabber(_menu, _, key, event)
|
||||
if event ~= "press" then return end
|
||||
|
||||
local sel = _menu.sel or 0
|
||||
|
@ -499,10 +499,10 @@ end
|
|||
--------------------------------------------------------------------------------
|
||||
|
||||
--- 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
|
||||
-- @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.text = args[1] or args.text or ""
|
||||
args.cmd = args[2] or args.cmd
|
||||
|
@ -651,9 +651,9 @@ function menu.new(args, parent)
|
|||
end
|
||||
|
||||
-- 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
|
||||
for i, v in pairs(args.items) do _menu:add(v) end
|
||||
for _, v in pairs(args.items) do _menu:add(v) end
|
||||
end
|
||||
|
||||
_menu._keygrabber = function (...)
|
||||
|
|
|
@ -38,12 +38,9 @@
|
|||
-- @module awful.mouse.finder
|
||||
-------------------------------------------------------------------------
|
||||
|
||||
local mouse = mouse
|
||||
local screen = screen
|
||||
local timer = require("gears.timer")
|
||||
local wibox = require("wibox")
|
||||
local a_placement = require("awful.placement")
|
||||
local a_wibox = require("awful.wibox")
|
||||
local beautiful = require("beautiful")
|
||||
local setmetatable = setmetatable
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
local layout = require("awful.layout")
|
||||
local tag = require("awful.tag")
|
||||
local aclient = require("awful.client")
|
||||
local widget = require("awful.widget")
|
||||
local awibox = require("awful.wibox")
|
||||
local util = require("awful.util")
|
||||
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_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)
|
||||
local snap = snap or 8
|
||||
local c = c or mouse.client.focus
|
||||
snap = snap or 8
|
||||
c = c or mouse.client.focus
|
||||
local cur_geom = c:geometry()
|
||||
local geom = c:geometry()
|
||||
geom.width = geom.width + (2 * c.border_width)
|
||||
geom.height = geom.height + (2 * c.border_width)
|
||||
local edge = "none"
|
||||
local edge2 = "none"
|
||||
local edge
|
||||
geom.x = x or geom.x
|
||||
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.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
|
||||
geom = snap_outside(geom, snapper:geometry(), snap)
|
||||
end
|
||||
|
@ -159,7 +157,7 @@ end
|
|||
-- when moving the client has been finished. The client
|
||||
-- that has been moved will be passed to that function.
|
||||
function mouse.client.move(c, snap, finished_cb)
|
||||
local c = c or capi.client.focus
|
||||
c = c or capi.client.focus
|
||||
|
||||
if not c
|
||||
or c.fullscreen
|
||||
|
@ -178,7 +176,7 @@ function mouse.client.move(c, snap, finished_cb)
|
|||
local fixed_y = c.maximized_vertical
|
||||
|
||||
capi.mousegrabber.run(function (_mouse)
|
||||
for k, v in ipairs(_mouse.buttons) do
|
||||
for _, v in ipairs(_mouse.buttons) do
|
||||
if v then
|
||||
local lay = layout.get(c.screen)
|
||||
if lay == layout.suit.floating or aclient.floating.get(c) then
|
||||
|
@ -259,7 +257,7 @@ end
|
|||
--- Move the wibox under the cursor
|
||||
--@param w The wibox to move, or none to use that under the pointer
|
||||
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
|
||||
|
||||
local offset = {
|
||||
|
@ -286,7 +284,7 @@ function mouse.wibox.move(w)
|
|||
end
|
||||
w.screen = capi.mouse.screen
|
||||
end
|
||||
for k, v in ipairs(_mouse.buttons) do
|
||||
for _, v in ipairs(_mouse.buttons) do
|
||||
if v then button_down = true end
|
||||
end
|
||||
if not button_down then
|
||||
|
@ -302,7 +300,7 @@ end
|
|||
-- bottom_right. Default is auto, and auto find the nearest corner.
|
||||
-- @return Actual used corner and x and y coordinates.
|
||||
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
|
||||
|
||||
local g = c:geometry()
|
||||
|
@ -346,7 +344,7 @@ end
|
|||
-- @param c The client to resize, or the focused one by default.
|
||||
-- @param corner The corner to grab on resize. Auto detected by default.
|
||||
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
|
||||
|
||||
|
@ -358,12 +356,12 @@ function mouse.client.resize(c, corner)
|
|||
end
|
||||
|
||||
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
|
||||
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
|
||||
return lay.mouse_resize_handler(c, corner, x, y)
|
||||
return lay.mouse_resize_handler(c, corner2, x, y)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -119,9 +119,9 @@ end
|
|||
-- @tparam[opt=client's screen] integer screen The screen.
|
||||
-- @treturn table The new client geometry.
|
||||
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 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
|
||||
|
||||
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 curlay = layout.get()
|
||||
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
|
||||
areas = area_remove(areas, get_area(cl))
|
||||
end
|
||||
|
@ -158,7 +158,7 @@ function placement.no_overlap(c)
|
|||
-- Look for available space
|
||||
local found = false
|
||||
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
|
||||
and r.height >= geometry.height
|
||||
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:
|
||||
-- just take the biggest available one and go in
|
||||
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
|
||||
new = r
|
||||
end
|
||||
|
@ -197,7 +197,7 @@ end
|
|||
-- @param c The client.
|
||||
-- @return The new client geometry.
|
||||
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 m_coords = capi.mouse.coords()
|
||||
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 screen_geometry = capi.screen[capi.mouse.screen].workarea
|
||||
|
||||
local x, y
|
||||
|
||||
-- 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
|
||||
-- Then to the left.
|
||||
x = m_coords.x - c_width - offset
|
||||
|
@ -245,7 +247,7 @@ end
|
|||
-- @param[opt] p The parent (nil for screen centering).
|
||||
-- @return The new client geometry.
|
||||
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 screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
||||
local s_geometry
|
||||
|
@ -263,7 +265,7 @@ end
|
|||
-- @param[opt] p The parent (nil for screen centering).
|
||||
-- @return The new client geometry.
|
||||
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 screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
||||
local s_geometry
|
||||
|
@ -280,7 +282,7 @@ end
|
|||
-- @param[opt] p The parent (nil for screen centering).
|
||||
-- @return The new client geometry.
|
||||
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 screen = c.screen or a_screen.getbycoord(c_geometry.x, c_geometry.y)
|
||||
local s_geometry
|
||||
|
|
|
@ -290,9 +290,9 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
|
|||
end
|
||||
|
||||
-- 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
|
||||
local mods,key,callback = unpack(v)
|
||||
local _,key,callback = unpack(v)
|
||||
if type(callback) == "function" then
|
||||
hooks[key] = hooks[key] or {}
|
||||
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
|
||||
-- Convert index array to hash table
|
||||
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
|
||||
-- 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
|
||||
if hooks[key] then
|
||||
for k,v in ipairs(hooks[key]) do
|
||||
for _,v in ipairs(hooks[key]) do
|
||||
if #modifiers == #v[1] then
|
||||
local match = true
|
||||
for k2,v2 in ipairs(v[1]) do
|
||||
for _,v2 in ipairs(v[1]) do
|
||||
match = match and mod[v2]
|
||||
end
|
||||
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
|
||||
local wstart = 1
|
||||
local wend = 1
|
||||
local cword_start = 1
|
||||
local cword_end = 1
|
||||
local cword_start_pos = 1
|
||||
local cword_end_pos = 1
|
||||
while wend < cur_pos do
|
||||
wend = command:find("[{[(,.:;_-+=@/ ]", wstart)
|
||||
if not wend then wend = #command + 1 end
|
||||
if cur_pos >= wstart and cur_pos <= wend + 1 then
|
||||
cword_start = wstart
|
||||
cword_end = cur_pos - 1
|
||||
cword_start_pos = wstart
|
||||
cword_end_pos = cur_pos - 1
|
||||
break
|
||||
end
|
||||
wstart = wend + 1
|
||||
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
|
||||
elseif key == "Delete" then
|
||||
-- delete from history only if:
|
||||
|
@ -531,7 +531,7 @@ function prompt.run(args, textbox, exe_callback, completion_callback, history_pa
|
|||
elseif key == "d" then
|
||||
command = command:sub(1, cur_pos - 1) .. command:sub(cword_end(command, cur_pos))
|
||||
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)
|
||||
cur_pos = wstart
|
||||
end
|
||||
|
|
|
@ -9,11 +9,11 @@
|
|||
|
||||
-- Grab environment we need
|
||||
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 ipairs = ipairs
|
||||
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 type = type
|
||||
|
||||
|
|
|
@ -213,6 +213,7 @@ function rules.execute(c, props, callbacks)
|
|||
c:geometry(geo);
|
||||
elseif property == "focus" then
|
||||
-- This will be handled below
|
||||
(function() end)() -- I haven't found a nice way to silence luacheck here
|
||||
elseif type(c[property]) == "function" then
|
||||
c[property](c, value)
|
||||
else
|
||||
|
@ -222,7 +223,7 @@ function rules.execute(c, props, callbacks)
|
|||
|
||||
-- Apply all callbacks.
|
||||
if callbacks then
|
||||
for i, callback in pairs(callbacks) do
|
||||
for _, callback in pairs(callbacks) do
|
||||
callback(c)
|
||||
end
|
||||
end
|
||||
|
|
|
@ -110,7 +110,7 @@ function spawn.with_line_callback(cmd, callbacks)
|
|||
local stdout_callback, stderr_callback, done_callback, exit_callback =
|
||||
callbacks.stdout, callbacks.stderr, callbacks.output_done, callbacks.exit
|
||||
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)
|
||||
if type(pid) == "string" then
|
||||
-- Error
|
||||
|
|
|
@ -10,9 +10,7 @@
|
|||
-- Grab environment we need
|
||||
local util = require("awful.util")
|
||||
local ascreen = require("awful.screen")
|
||||
local timer = require("gears.timer")
|
||||
local beautiful = require("beautiful")
|
||||
local tostring = tostring
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
local table = table
|
||||
|
@ -46,7 +44,7 @@ tag.history.limit = 20
|
|||
-- @param target_tag The tag that should be moved. If null, the currently
|
||||
-- selected tag is used.
|
||||
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 tmp_tags = tag.gettags(scr)
|
||||
|
||||
|
@ -121,7 +119,7 @@ end
|
|||
-- @param layout The layout or layout table to set for this tags by default.
|
||||
-- @return A table with all created tags.
|
||||
function tag.new(names, screen, layout)
|
||||
local screen = screen or 1
|
||||
screen = screen or 1
|
||||
local tags = {}
|
||||
for id, name in ipairs(names) do
|
||||
table.insert(tags, id, tag.add(name, {screen = screen,
|
||||
|
@ -158,7 +156,7 @@ end
|
|||
-- history or select the first tag on the screen.
|
||||
function tag.delete(target_tag, fallback_tag)
|
||||
-- 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
|
||||
|
||||
local target_scr = tag.getscreen(target_tag)
|
||||
|
@ -167,7 +165,6 @@ function tag.delete(target_tag, fallback_tag)
|
|||
local ntags = #tags
|
||||
|
||||
-- We can't use the target tag as a fallback.
|
||||
local fallback_tag = fallback_tag
|
||||
if fallback_tag == target_tag then return end
|
||||
|
||||
-- No fallback_tag provided, try and get one.
|
||||
|
@ -292,7 +289,7 @@ end
|
|||
-- @return A table with all available tags
|
||||
function tag.gettags(s)
|
||||
local tags = {}
|
||||
for i, t in ipairs(root.tags()) do
|
||||
for _, t in ipairs(root.tags()) do
|
||||
if tag.getscreen(t) == s then
|
||||
table.insert(tags, t)
|
||||
end
|
||||
|
@ -315,7 +312,7 @@ function tag.setscreen(s, t)
|
|||
s, t = t, s
|
||||
end
|
||||
|
||||
local s = s or ascreen.focused()
|
||||
s = s or ascreen.focused()
|
||||
local sel = tag.selected
|
||||
local old_screen = tag.getproperty(t, "screen")
|
||||
if s == old_screen then return end
|
||||
|
@ -327,15 +324,15 @@ function tag.setscreen(s, t)
|
|||
tag.setproperty(t, "screen", s, true)
|
||||
|
||||
-- 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:tags({t})
|
||||
end
|
||||
|
||||
-- Update all indexes
|
||||
for _,screen in ipairs {old_screen, s} do
|
||||
for i,t in ipairs(tag.gettags(screen)) do
|
||||
tag.setproperty(t, "index", i, true)
|
||||
for i,t2 in ipairs(tag.gettags(screen)) do
|
||||
tag.setproperty(t2, "index", i, true)
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -349,7 +346,7 @@ end
|
|||
-- @param[opt] t tag object
|
||||
-- @return Screen number
|
||||
function tag.getscreen(t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
return tag.getproperty(t, "screen")
|
||||
end
|
||||
|
||||
|
@ -360,7 +357,7 @@ function tag.selectedlist(s)
|
|||
local screen = s or ascreen.focused()
|
||||
local tags = tag.gettags(screen)
|
||||
local vtags = {}
|
||||
for i, t in pairs(tags) do
|
||||
for _, t in pairs(tags) do
|
||||
if t.selected then
|
||||
vtags[#vtags + 1] = t
|
||||
end
|
||||
|
@ -378,7 +375,7 @@ end
|
|||
-- @param mwfact Master width factor.
|
||||
-- @param t The tag to modify, if null tag.selected() is used.
|
||||
function tag.setmwfact(mwfact, t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
if mwfact >= 0 and mwfact <= 1 then
|
||||
tag.setproperty(t, "mwfact", mwfact, true)
|
||||
end
|
||||
|
@ -394,7 +391,7 @@ end
|
|||
--- Get master width factor.
|
||||
-- @param[opt] t The tag.
|
||||
function tag.getmwfact(t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
return tag.getproperty(t, "mwfact") or 0.5
|
||||
end
|
||||
|
||||
|
@ -438,7 +435,7 @@ end
|
|||
-- @param useless_gap The spacing between clients
|
||||
-- @param t The tag to modify, if null tag.selected() is used.
|
||||
function tag.setgap(useless_gap, t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
if useless_gap >= 0 then
|
||||
tag.setproperty(t, "useless_gap", useless_gap, true)
|
||||
end
|
||||
|
@ -457,7 +454,7 @@ end
|
|||
-- return 0 for a single client. You can override this function to change
|
||||
-- this behavior.
|
||||
function tag.getgap(t, numclients)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
if numclients == 1 then
|
||||
return 0
|
||||
end
|
||||
|
@ -470,7 +467,7 @@ end
|
|||
-- "mwfact" (fill only an area inside the master width factor)
|
||||
-- @tparam[opt=tag.selected()] tag t The tag to modify
|
||||
function tag.setmfpol(policy, t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
tag.setproperty(t, "master_fill_policy", policy, true)
|
||||
end
|
||||
|
||||
|
@ -491,7 +488,7 @@ end
|
|||
-- "expand" (fill all the available workarea, default one) or
|
||||
-- "mwfact" (fill only an area inside the master width factor)
|
||||
function tag.getmfpol(t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
return tag.getproperty(t, "master_fill_policy") or "expand"
|
||||
end
|
||||
|
||||
|
@ -499,7 +496,7 @@ end
|
|||
-- @param nmaster The number of master windows.
|
||||
-- @param[opt] t The tag.
|
||||
function tag.setnmaster(nmaster, t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
if nmaster >= 0 then
|
||||
tag.setproperty(t, "nmaster", nmaster, true)
|
||||
end
|
||||
|
@ -508,7 +505,7 @@ end
|
|||
--- Get the number of master windows.
|
||||
-- @param[opt] t The tag.
|
||||
function tag.getnmaster(t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
return tag.getproperty(t, "nmaster") or 1
|
||||
end
|
||||
|
||||
|
@ -542,14 +539,14 @@ end
|
|||
-- @param icon the icon to set, either path or image object
|
||||
-- @param _tag the tag
|
||||
function tag.seticon(icon, _tag)
|
||||
local _tag = _tag or tag.selected()
|
||||
_tag = _tag or tag.selected()
|
||||
tag.setproperty(_tag, "icon", icon, true)
|
||||
end
|
||||
|
||||
--- Get the tag icon
|
||||
-- @param _tag the tag
|
||||
function tag.geticon(_tag)
|
||||
local _tag = _tag or tag.selected()
|
||||
_tag = _tag or tag.selected()
|
||||
return tag.getproperty(_tag, "icon")
|
||||
end
|
||||
|
||||
|
@ -557,7 +554,7 @@ end
|
|||
-- @param ncol The number of column.
|
||||
-- @param t The tag to modify, if null tag.selected() is used.
|
||||
function tag.setncol(ncol, t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
if ncol >= 1 then
|
||||
tag.setproperty(t, "ncol", ncol, true)
|
||||
end
|
||||
|
@ -566,7 +563,7 @@ end
|
|||
--- Get number of column windows.
|
||||
-- @param[opt] t The tag.
|
||||
function tag.getncol(t)
|
||||
local t = t or tag.selected()
|
||||
t = t or tag.selected()
|
||||
return tag.getproperty(t, "ncol") or 1
|
||||
end
|
||||
|
||||
|
@ -601,7 +598,7 @@ end
|
|||
-- @tparam[opt] int screen The screen number.
|
||||
function tag.viewnone(screen)
|
||||
local tags = tag.gettags(screen or ascreen.focused())
|
||||
for i, t in pairs(tags) do
|
||||
for _, t in pairs(tags) do
|
||||
t.selected = false
|
||||
end
|
||||
end
|
||||
|
@ -610,10 +607,10 @@ end
|
|||
-- @param i The relative index to see.
|
||||
-- @param[opt] screen The screen number.
|
||||
function tag.viewidx(i, screen)
|
||||
local screen = screen or ascreen.focused()
|
||||
screen = screen or ascreen.focused()
|
||||
local tags = tag.gettags(screen)
|
||||
local showntags = {}
|
||||
for k, t in ipairs(tags) do
|
||||
for _, t in ipairs(tags) do
|
||||
if not tag.getproperty(t, "hide") then
|
||||
table.insert(showntags, t)
|
||||
end
|
||||
|
@ -632,7 +629,7 @@ end
|
|||
-- @param query_tag The tag object to find. [selected()]
|
||||
-- @return The index of the tag, nil if the tag is not found.
|
||||
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
|
||||
|
||||
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[opt] screen The screen number of the tags.
|
||||
function tag.viewmore(tags, screen)
|
||||
local screen = screen or ascreen.focused()
|
||||
screen = screen or ascreen.focused()
|
||||
local screen_tags = tag.gettags(screen)
|
||||
for _, _tag in ipairs(screen_tags) do
|
||||
if not util.table.hasitem(tags, _tag) then
|
||||
|
@ -738,7 +735,7 @@ end
|
|||
-- @param c The client to tag.
|
||||
function tag.withcurrent(c)
|
||||
local tags = {}
|
||||
for k, t in ipairs(c:tags()) do
|
||||
for _, t in ipairs(c:tags()) do
|
||||
if tag.getscreen(t) == c.screen then
|
||||
table.insert(tags, t)
|
||||
end
|
||||
|
@ -755,7 +752,7 @@ function tag.withcurrent(c)
|
|||
end
|
||||
|
||||
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
|
||||
func(_tag)
|
||||
end
|
||||
|
@ -792,7 +789,7 @@ capi.client.connect_signal("manage", function(c)
|
|||
end)
|
||||
|
||||
-- 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
|
||||
count = (count + modif) >= 0 and (count + modif) or 0
|
||||
tag.setproperty(t, "urgent" , count > 0)
|
||||
|
@ -802,21 +799,21 @@ end
|
|||
-- Update the urgent counter when a client is tagged.
|
||||
local function client_tagged(c, t)
|
||||
if c.urgent then
|
||||
update_urgent(c, t, 1)
|
||||
update_urgent(t, 1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Update the urgent counter when a client is untagged.
|
||||
local function client_untagged(c, t)
|
||||
if c.urgent then
|
||||
update_urgent(c, t, -1)
|
||||
update_urgent(t, -1)
|
||||
end
|
||||
end
|
||||
|
||||
-- Count the urgent clients.
|
||||
local function urgent_callback(c)
|
||||
for k,t in ipairs(c:tags()) do
|
||||
update_urgent(c, t, c.urgent and 1 or -1)
|
||||
for _,t in ipairs(c:tags()) do
|
||||
update_urgent(t, c.urgent and 1 or -1)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -14,9 +14,7 @@ local abutton = require("awful.button")
|
|||
local aclient = require("awful.client")
|
||||
local atooltip = require("awful.tooltip")
|
||||
local beautiful = require("beautiful")
|
||||
local object = require("gears.object")
|
||||
local drawable = require("wibox.drawable")
|
||||
local base = require("wibox.widget.base")
|
||||
local imagebox = require("wibox.widget.imagebox")
|
||||
local textbox = require("wibox.widget.textbox")
|
||||
local capi = {
|
||||
|
@ -72,7 +70,7 @@ end
|
|||
-- can be configured via e.g. "bg_normal" and "bg_focus".
|
||||
-- @name titlebar
|
||||
local function new(c, args)
|
||||
local args = args or {}
|
||||
args = args or {}
|
||||
local position = args.position or "top"
|
||||
local size = args.size or util.round(beautiful.get_font_height(args.font) * 1.5)
|
||||
local d = get_titlebar_function(c, position)(c, size)
|
||||
|
@ -92,10 +90,10 @@ local function new(c, args)
|
|||
}
|
||||
ret = drawable(d, context, "awful.titlebar")
|
||||
local function update_colors()
|
||||
local args = bars[position].args
|
||||
ret:set_bg(get_color("bg", c, args))
|
||||
ret:set_fg(get_color("fg", c, args))
|
||||
ret:set_bgimage(get_color("bgimage", c, args))
|
||||
local args_ = bars[position].args
|
||||
ret:set_bg(get_color("bg", c, args_))
|
||||
ret:set_fg(get_color("fg", c, args_))
|
||||
ret:set_bgimage(get_color("bgimage", c, args_))
|
||||
end
|
||||
|
||||
bars[position] = {
|
||||
|
@ -126,7 +124,7 @@ end
|
|||
-- @param[opt] position The position of the titlebar. Must be one of "left",
|
||||
-- "right", "top", "bottom". Default is "top".
|
||||
function titlebar.show(c, position)
|
||||
local position = position or "top"
|
||||
position = position or "top"
|
||||
local bars = all_titlebars[c]
|
||||
local data = bars and bars[position]
|
||||
local args = data and data.args
|
||||
|
@ -138,7 +136,7 @@ end
|
|||
-- @param[opt] position The position of the titlebar. Must be one of "left",
|
||||
-- "right", "top", "bottom". Default is "top".
|
||||
function titlebar.hide(c, position)
|
||||
local position = position or "top"
|
||||
position = position or "top"
|
||||
get_titlebar_function(c, position)(c, 0)
|
||||
end
|
||||
|
||||
|
@ -147,8 +145,8 @@ end
|
|||
-- @param[opt] position The position of the titlebar. Must be one of "left",
|
||||
-- "right", "top", "bottom". Default is "top".
|
||||
function titlebar.toggle(c, position)
|
||||
local position = position or "top"
|
||||
local drawable, size = get_titlebar_function(c, position)(c)
|
||||
position = position or "top"
|
||||
local _, size = get_titlebar_function(c, position)(c)
|
||||
if size == 0 then
|
||||
titlebar.show(c, position)
|
||||
else
|
||||
|
@ -265,11 +263,11 @@ end
|
|||
--- Create a new maximize button for a client.
|
||||
-- @param c The client for which the button is wanted.
|
||||
function titlebar.widget.maximizedbutton(c)
|
||||
local widget = titlebar.widget.button(c, "maximized", function(c)
|
||||
return c.maximized_horizontal or c.maximized_vertical
|
||||
end, function(c, state)
|
||||
c.maximized_horizontal = not state
|
||||
c.maximized_vertical = not state
|
||||
local widget = titlebar.widget.button(c, "maximized", function(cl)
|
||||
return cl.maximized_horizontal or cl.maximized_vertical
|
||||
end, function(cl, state)
|
||||
cl.maximized_horizontal = not state
|
||||
cl.maximized_vertical = not state
|
||||
end)
|
||||
c:connect_signal("property::maximized_vertical", widget.update)
|
||||
c:connect_signal("property::maximized_horizontal", widget.update)
|
||||
|
@ -279,7 +277,7 @@ end
|
|||
--- Create a new minimize button for a client.
|
||||
-- @param c The client for which the button is wanted.
|
||||
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)
|
||||
return widget
|
||||
end
|
||||
|
@ -287,13 +285,13 @@ end
|
|||
--- Create a new closing button for a client.
|
||||
-- @param c The client for which the button is wanted.
|
||||
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
|
||||
|
||||
--- Create a new ontop button for a client.
|
||||
-- @param c The client for which the button is wanted.
|
||||
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)
|
||||
return widget
|
||||
end
|
||||
|
@ -301,7 +299,7 @@ end
|
|||
--- Create a new sticky button for a client.
|
||||
-- @param c The client for which the button is wanted.
|
||||
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)
|
||||
return widget
|
||||
end
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
-------------------------------------------------------------------------
|
||||
|
||||
local mouse = mouse
|
||||
local screen = screen
|
||||
local timer = require("gears.timer")
|
||||
local wibox = require("wibox")
|
||||
local a_placement = require("awful.placement")
|
||||
|
|
|
@ -11,14 +11,13 @@
|
|||
local os = os
|
||||
local io = io
|
||||
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 debug = debug
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
local type = type
|
||||
local rtable = table
|
||||
local pairs = pairs
|
||||
local string = string
|
||||
local lgi = require("lgi")
|
||||
local Gio = require("lgi").Gio
|
||||
|
@ -195,8 +194,8 @@ end
|
|||
-- @tparam[opt] string size The size. If this is specified, subdirectories `x`
|
||||
-- of the dirs are searched first.
|
||||
function util.geticonpath(iconname, exts, dirs, size)
|
||||
local exts = exts or { 'png', 'gif' }
|
||||
local dirs = dirs or { '/usr/share/pixmaps/', '/usr/share/icons/hicolor/' }
|
||||
exts = exts or { 'png', 'gif' }
|
||||
dirs = dirs or { '/usr/share/pixmaps/', '/usr/share/icons/hicolor/' }
|
||||
local icontypes = { 'apps', 'actions', 'categories', 'emblems',
|
||||
'mimetypes', 'status', 'devices', 'extras', 'places', 'stock' }
|
||||
for _, d in pairs(dirs) do
|
||||
|
@ -385,7 +384,7 @@ end
|
|||
-- @return A new table containing all keys from the arguments.
|
||||
function util.table.join(...)
|
||||
local ret = {}
|
||||
for i, t in pairs({...}) do
|
||||
for _, t in pairs({...}) do
|
||||
if t then
|
||||
for k, v in pairs(t) do
|
||||
if type(k) == "number" then
|
||||
|
@ -422,7 +421,7 @@ end
|
|||
-- @treturn table A packed table with all numeric keys
|
||||
function util.table.from_sparse(t)
|
||||
local keys= {}
|
||||
for k,v in pairs(t) do
|
||||
for k in pairs(t) do
|
||||
if type(k) == "number" then
|
||||
keys[#keys+1] = k
|
||||
end
|
||||
|
@ -462,7 +461,7 @@ function util.linewrap(text, width, indent)
|
|||
|
||||
local pos = 1
|
||||
return text:gsub("(%s+)()(%S+)()",
|
||||
function(sp, st, word, fi)
|
||||
function(_, st, word, fi)
|
||||
if fi - pos > width then
|
||||
pos = st
|
||||
return "\n" .. string.rep(" ", indent) .. word
|
||||
|
@ -532,7 +531,7 @@ end
|
|||
-- @param deep Create a deep clone? (default: true)
|
||||
-- @return a clone of t
|
||||
function util.table.clone(t, deep)
|
||||
local deep = deep == nil and true or deep
|
||||
deep = deep == nil and true or deep
|
||||
local c = { }
|
||||
for k, v in pairs(t) do
|
||||
if deep and type(v) == "table" then
|
||||
|
@ -592,7 +591,7 @@ end
|
|||
-- Generate a pattern matching expression that ignores case.
|
||||
-- @param s Original pattern matching expression.
|
||||
function util.query_to_pattern(q)
|
||||
s = util.quote_pattern(q)
|
||||
local s = util.quote_pattern(q)
|
||||
-- Poor man's case-insensitive character matching.
|
||||
s = string.gsub(s, "%a",
|
||||
function (c)
|
||||
|
|
|
@ -32,11 +32,11 @@ local awfulwibox = { mt = {} }
|
|||
local wiboxes = {}
|
||||
|
||||
--- Get a wibox position if it has been set, or return top.
|
||||
-- @param wibox The wibox
|
||||
-- @param wb The wibox
|
||||
-- @return The wibox position.
|
||||
function awfulwibox.get_position(wibox)
|
||||
function awfulwibox.get_position(wb)
|
||||
for _, wprop in ipairs(wiboxes) do
|
||||
if wprop.wibox == wibox then
|
||||
if wprop.wibox == wb then
|
||||
return wprop.position
|
||||
end
|
||||
end
|
||||
|
@ -44,28 +44,28 @@ function awfulwibox.get_position(wibox)
|
|||
end
|
||||
|
||||
--- 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 screen If the wibox it not attached to a screen, specified on which
|
||||
-- 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
|
||||
|
||||
-- The "length" of a wibox is always chosen to be the optimal size
|
||||
-- (non-floating).
|
||||
-- The "width" of a wibox is kept if it exists.
|
||||
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
|
||||
wibox.x = area.x
|
||||
wb.x = area.x
|
||||
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
|
||||
wibox.y = area.y
|
||||
wb.y = area.y
|
||||
end
|
||||
|
||||
for _, wprop in ipairs(wiboxes) do
|
||||
if wprop.wibox == wibox then
|
||||
if wprop.wibox == wb then
|
||||
wprop.position = position
|
||||
break
|
||||
end
|
||||
|
@ -79,23 +79,23 @@ local function update_all_wiboxes_position()
|
|||
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()
|
||||
end
|
||||
|
||||
local function wibox_update_strut(wibox)
|
||||
local function wibox_update_strut(wb)
|
||||
for _, wprop in ipairs(wiboxes) do
|
||||
if wprop.wibox == wibox then
|
||||
if not wibox.visible then
|
||||
wibox:struts { left = 0, right = 0, bottom = 0, top = 0 }
|
||||
if wprop.wibox == wb then
|
||||
if not wb.visible then
|
||||
wb:struts { left = 0, right = 0, bottom = 0, top = 0 }
|
||||
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
|
||||
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
|
||||
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
|
||||
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
|
||||
break
|
||||
end
|
||||
|
@ -105,10 +105,10 @@ end
|
|||
--- Attach a wibox to a screen.
|
||||
-- If a wibox is attached, it will be automatically be moved when other wiboxes
|
||||
-- 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 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
|
||||
local wibox_prop_table
|
||||
-- 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 wiboxes[i].wibox == nil then
|
||||
table.remove(wiboxes, i)
|
||||
elseif wiboxes[i].wibox == wibox then
|
||||
elseif wiboxes[i].wibox == wb then
|
||||
wibox_prop_table = wiboxes[i]
|
||||
-- We could break here, but well, let's check if there is no other
|
||||
-- table with their wiboxes been garbage collected.
|
||||
|
@ -125,81 +125,81 @@ function awfulwibox.attach(wibox, position, screen)
|
|||
end
|
||||
|
||||
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
|
||||
wibox_prop_table.position = position
|
||||
end
|
||||
|
||||
wibox:connect_signal("property::width", wibox_update_strut)
|
||||
wibox:connect_signal("property::height", wibox_update_strut)
|
||||
wibox:connect_signal("property::visible", wibox_update_strut)
|
||||
wb:connect_signal("property::width", wibox_update_strut)
|
||||
wb:connect_signal("property::height", wibox_update_strut)
|
||||
wb:connect_signal("property::visible", wibox_update_strut)
|
||||
|
||||
wibox:connect_signal("property::width", call_wibox_position_hook_on_prop_update)
|
||||
wibox:connect_signal("property::height", call_wibox_position_hook_on_prop_update)
|
||||
wibox: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::width", call_wibox_position_hook_on_prop_update)
|
||||
wb:connect_signal("property::height", call_wibox_position_hook_on_prop_update)
|
||||
wb:connect_signal("property::visible", call_wibox_position_hook_on_prop_update)
|
||||
wb:connect_signal("property::border_width", call_wibox_position_hook_on_prop_update)
|
||||
end
|
||||
|
||||
--- Align a wibox.
|
||||
-- @param wibox The wibox.
|
||||
-- @param wb The wibox.
|
||||
-- @param align The alignment: left, right or center.
|
||||
-- @param screen If the wibox is not attached to any screen, you can specify the
|
||||
-- screen where to align. Otherwise 1 is assumed.
|
||||
function awfulwibox.align(wibox, align, screen)
|
||||
local position = awfulwibox.get_position(wibox)
|
||||
function awfulwibox.align(wb, align, screen)
|
||||
local position = awfulwibox.get_position(wb)
|
||||
local area = capi.screen[screen].workarea
|
||||
|
||||
if position == "right" then
|
||||
if align == "right" then
|
||||
wibox.y = area.y
|
||||
wb.y = area.y
|
||||
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
|
||||
wibox.y = area.y + round((area.height - wibox.height) / 2)
|
||||
wb.y = area.y + round((area.height - wb.height) / 2)
|
||||
end
|
||||
elseif position == "left" 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
|
||||
wibox.y = area.y
|
||||
wb.y = area.y
|
||||
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
|
||||
elseif position == "bottom" 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
|
||||
wibox.x = area.x
|
||||
wb.x = area.x
|
||||
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
|
||||
elseif position == "top" 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
|
||||
wibox.x = area.x
|
||||
wb.x = area.x
|
||||
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
|
||||
|
||||
-- Update struts regardless of changes
|
||||
wibox_update_strut(wibox)
|
||||
wibox_update_strut(wb)
|
||||
end
|
||||
|
||||
--- 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.
|
||||
function awfulwibox.stretch(wibox, screen)
|
||||
function awfulwibox.stretch(wb, screen)
|
||||
if screen then
|
||||
local position = awfulwibox.get_position(wibox)
|
||||
local position = awfulwibox.get_position(wb)
|
||||
local area = capi.screen[screen].workarea
|
||||
if position == "right" or position == "left" then
|
||||
wibox.height = area.height - (2 * wibox.border_width)
|
||||
wibox.y = area.y
|
||||
wb.height = area.height - (2 * wb.border_width)
|
||||
wb.y = area.y
|
||||
else
|
||||
wibox.width = area.width - (2 * wibox.border_width)
|
||||
wibox.x = area.x
|
||||
wb.width = area.width - (2 * wb.border_width)
|
||||
wb.x = area.x
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -213,7 +213,7 @@ end
|
|||
-- If not specified, 1 is assumed.
|
||||
-- @return The wibox created.
|
||||
function awfulwibox.new(arg)
|
||||
local arg = arg or {}
|
||||
arg = arg or {}
|
||||
local position = arg.position or "top"
|
||||
local has_to_stretch = true
|
||||
local screen = arg.screen or 1
|
||||
|
|
|
@ -6,13 +6,11 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
local setmetatable = setmetatable
|
||||
local type = type
|
||||
local abutton = require("awful.button")
|
||||
local imagebox = require("wibox.widget.imagebox")
|
||||
local widget = require("wibox.widget.base")
|
||||
local surface = require("gears.surface")
|
||||
local cairo = require("lgi").cairo
|
||||
local capi = { mouse = mouse }
|
||||
|
||||
local button = { mt = {} }
|
||||
|
||||
|
@ -31,13 +29,13 @@ function button.new(args)
|
|||
local img_release
|
||||
local img_press
|
||||
|
||||
w.set_image = function(w, image)
|
||||
function w:set_image(image)
|
||||
img_release = surface.load(image)
|
||||
img_press = img_release:create_similar(cairo.Content.COLOR_ALPHA, img_release.width, img_release.height)
|
||||
local cr = cairo.Context(img_press)
|
||||
cr:set_source_surface(img_release, 2, 2)
|
||||
cr:paint()
|
||||
orig_set_image(w, img_release)
|
||||
orig_set_image(self, img_release)
|
||||
end
|
||||
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))
|
||||
|
|
|
@ -6,17 +6,10 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment we need
|
||||
local math = math
|
||||
local type = type
|
||||
local ipairs = ipairs
|
||||
local pairs = pairs
|
||||
local pcall = pcall
|
||||
local setmetatable = setmetatable
|
||||
local capi = { button = button }
|
||||
local util = require("awful.util")
|
||||
local wibox = require("wibox")
|
||||
local imagebox = require("wibox.widget.imagebox")
|
||||
local textbox = require("wibox.widget.textbox")
|
||||
local dpi = require("beautiful").xresources.apply_dpi
|
||||
|
||||
--- Common utilities for awful widgets
|
||||
|
@ -29,7 +22,7 @@ local common = {}
|
|||
function common.create_buttons(buttons, object)
|
||||
if buttons then
|
||||
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
|
||||
-- press and release events, and will propagate them the the
|
||||
-- button object the user provided, but with the object as
|
||||
|
|
|
@ -69,7 +69,7 @@ local properties = { "width", "height", "border_color", "stack",
|
|||
"stack_colors", "color", "background_color",
|
||||
"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 values = data[_graph].values
|
||||
|
||||
|
@ -91,7 +91,7 @@ function graph.draw(_graph, context, cr, width, height)
|
|||
|
||||
if data[_graph].scale then
|
||||
for _, v in ipairs(values) do
|
||||
for __, sv in ipairs(v) do
|
||||
for _, sv in ipairs(v) do
|
||||
if sv > max_value then
|
||||
max_value = sv
|
||||
end
|
||||
|
@ -169,7 +169,7 @@ end
|
|||
local function add_value(_graph, value, group)
|
||||
if not _graph then return end
|
||||
|
||||
local value = value or 0
|
||||
value = value or 0
|
||||
local values = data[_graph].values
|
||||
local max_value = data[_graph].max_value
|
||||
value = math.max(0, value)
|
||||
|
@ -243,7 +243,7 @@ end
|
|||
-- key to set graph geometry.
|
||||
-- @return A graph widget.
|
||||
function graph.new(args)
|
||||
local args = args or {}
|
||||
args = args or {}
|
||||
|
||||
local width = args.width or 100
|
||||
local height = args.height or 20
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
|
||||
local capi = {awesome = awesome}
|
||||
local setmetatable = setmetatable
|
||||
local os = os
|
||||
local textbox = require("wibox.widget.textbox")
|
||||
local button = require("awful.button")
|
||||
local util = require("awful.util")
|
||||
|
@ -264,8 +263,7 @@ function keyboardlayout.new()
|
|||
update_layout(self);
|
||||
|
||||
self.next_layout = function()
|
||||
new_layout = (self._current + 1) % (#self._layout + 1)
|
||||
self.set_layout(new_layout)
|
||||
self.set_layout((self._current + 1) % (#self._layout + 1))
|
||||
end
|
||||
|
||||
self.set_layout = function(group_number)
|
||||
|
|
|
@ -8,8 +8,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
local setmetatable = setmetatable
|
||||
local ipairs = ipairs
|
||||
local button = require("awful.button")
|
||||
local layout = require("awful.layout")
|
||||
local tooltip = require("awful.tooltip")
|
||||
local tag = require("awful.tag")
|
||||
|
@ -21,9 +19,9 @@ local layoutbox = { mt = {} }
|
|||
local boxes = nil
|
||||
|
||||
local function update(w, screen)
|
||||
local layout = layout.getname(layout.get(screen))
|
||||
w._layoutbox_tooltip:set_text(layout or "[no name]")
|
||||
w:set_image(layout and beautiful["layout_" .. layout])
|
||||
local name = layout.getname(layout.get(screen))
|
||||
w._layoutbox_tooltip:set_text(name or "[no name]")
|
||||
w:set_image(name and beautiful["layout_" .. name])
|
||||
end
|
||||
|
||||
local function update_from_tag(t)
|
||||
|
@ -39,7 +37,7 @@ end
|
|||
-- @param screen The screen number that the layout will be represented for.
|
||||
-- @return An imagebox widget configured as a layoutbox.
|
||||
function layoutbox.new(screen)
|
||||
local screen = screen or 1
|
||||
screen = screen or 1
|
||||
|
||||
-- Do we already have the update callbacks registered?
|
||||
if boxes == nil then
|
||||
|
|
|
@ -71,7 +71,7 @@ local properties = { "width", "height", "border_color",
|
|||
"vertical", "value", "max_value",
|
||||
"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_size = data[pbar].ticks_size or 4
|
||||
|
||||
|
@ -161,7 +161,7 @@ end
|
|||
--- Set the progressbar value.
|
||||
-- @param value The progress bar value between 0 and 1.
|
||||
function progressbar:set_value(value)
|
||||
local value = value or 0
|
||||
value = value or 0
|
||||
local max_value = data[self].max_value
|
||||
data[self].value = math.min(max_value, math.max(0, value))
|
||||
self:emit_signal("widget::redraw_needed")
|
||||
|
@ -200,7 +200,7 @@ end
|
|||
-- key to set progressbar geometry.
|
||||
-- @return A progressbar widget.
|
||||
function progressbar.new(args)
|
||||
local args = args or {}
|
||||
args = args or {}
|
||||
local width = args.width or 100
|
||||
local height = args.height or 20
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ end
|
|||
-- @param args Arguments table. "prompt" is the prompt to use.
|
||||
-- @return A launcher widget.
|
||||
function widgetprompt.new(args)
|
||||
local args = args or {}
|
||||
args = args or {}
|
||||
local widget = textbox()
|
||||
local promptbox = widget_base.make_widget(widget)
|
||||
|
||||
|
|
|
@ -11,7 +11,6 @@
|
|||
local capi = { screen = screen,
|
||||
awesome = awesome,
|
||||
client = client }
|
||||
local type = type
|
||||
local setmetatable = setmetatable
|
||||
local pairs = pairs
|
||||
local ipairs = ipairs
|
||||
|
@ -53,7 +52,8 @@ function taglist.taglist_label(t, args)
|
|||
local fg_color = nil
|
||||
local bg_image
|
||||
local icon
|
||||
local bg_resize = false
|
||||
-- TODO: Re-implement bg_resize
|
||||
local bg_resize = false -- luacheck: ignore
|
||||
local is_selected = false
|
||||
local cls = t:clients()
|
||||
|
||||
|
@ -117,7 +117,7 @@ end
|
|||
|
||||
local function taglist_update(s, w, buttons, filter, data, style, update_function)
|
||||
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
|
||||
table.insert(tags, t)
|
||||
end
|
||||
|
@ -211,25 +211,21 @@ end
|
|||
|
||||
--- Filtering function to include all nonempty tags on the screen.
|
||||
-- @param t The tag.
|
||||
-- @param args unused list of extra arguments.
|
||||
-- @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
|
||||
end
|
||||
|
||||
--- Filtering function to include selected tags on the screen.
|
||||
-- @param t The tag.
|
||||
-- @param args unused list of extra arguments.
|
||||
-- @return true if t is not empty, else false
|
||||
function taglist.filter.selected(t, args)
|
||||
function taglist.filter.selected(t)
|
||||
return t.selected
|
||||
end
|
||||
|
||||
--- Filtering function to include all tags on the screen.
|
||||
-- @param t The tag.
|
||||
-- @param args unused list of extra arguments.
|
||||
-- @return true
|
||||
function taglist.filter.all(t, args)
|
||||
function taglist.filter.all()
|
||||
return true
|
||||
end
|
||||
|
||||
|
|
|
@ -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_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 bg = nil
|
||||
local text = ""
|
||||
local name = ""
|
||||
local bg_image = nil
|
||||
local bg
|
||||
local bg_image
|
||||
|
||||
-- symbol to use to indicate certain client properties
|
||||
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.
|
||||
if not focused and capi.client.focus and capi.client.focus.skip_taskbar
|
||||
and client.get_transient_for_matching(capi.client.focus,
|
||||
function(c)
|
||||
return not c.skip_taskbar
|
||||
function(cl)
|
||||
return not cl.skip_taskbar
|
||||
end) == c then
|
||||
focused = true
|
||||
end
|
||||
|
@ -120,7 +120,7 @@ end
|
|||
|
||||
local function tasklist_update(s, w, buttons, filter, data, style, update_function)
|
||||
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
|
||||
or c.type == "splash" or c.type == "dock" or c.type == "desktop")
|
||||
and filter(c, s) then
|
||||
|
@ -245,10 +245,8 @@ function tasklist.new(screen, filter, buttons, style, update_function, base_widg
|
|||
end
|
||||
|
||||
--- Filtering function to include all clients.
|
||||
-- @param c The client.
|
||||
-- @param screen The screen we are drawing on.
|
||||
-- @return true
|
||||
function tasklist.filter.allscreen(c, screen)
|
||||
function tasklist.filter.allscreen()
|
||||
return true
|
||||
end
|
||||
|
||||
|
@ -271,7 +269,7 @@ function tasklist.filter.currenttags(c, screen)
|
|||
-- Include sticky client too
|
||||
if c.sticky then return true end
|
||||
local tags = tag.gettags(screen)
|
||||
for k, t in ipairs(tags) do
|
||||
for _, t in ipairs(tags) do
|
||||
if t.selected then
|
||||
local ctags = c:tags()
|
||||
for _, v in ipairs(ctags) do
|
||||
|
@ -296,7 +294,7 @@ function tasklist.filter.minimizedcurrenttags(c, screen)
|
|||
-- Include sticky client
|
||||
if c.sticky then return true end
|
||||
local tags = tag.gettags(screen)
|
||||
for k, t in ipairs(tags) do
|
||||
for _, t in ipairs(tags) do
|
||||
-- Select only minimized clients
|
||||
if t.selected then
|
||||
local ctags = c:tags()
|
||||
|
|
|
@ -27,8 +27,8 @@ end
|
|||
-- @param timeout How often update the time. Default is 60.
|
||||
-- @return A textbox widget.
|
||||
function textclock.new(format, timeout)
|
||||
local format = format or " %a %b %d, %H:%M "
|
||||
local timeout = timeout or 60
|
||||
format = format or " %a %b %d, %H:%M "
|
||||
timeout = timeout or 60
|
||||
|
||||
local w = textbox()
|
||||
local t
|
||||
|
|
|
@ -10,22 +10,13 @@
|
|||
|
||||
-- Grab environment
|
||||
local os = os
|
||||
local print = print
|
||||
local pcall = pcall
|
||||
local pairs = pairs
|
||||
local type = type
|
||||
local dofile = dofile
|
||||
local setmetatable = setmetatable
|
||||
local util = require("awful.util")
|
||||
local lgi = require("lgi")
|
||||
local cairo = lgi.cairo
|
||||
local Pango = lgi.Pango
|
||||
local PangoCairo = lgi.PangoCairo
|
||||
local capi =
|
||||
{
|
||||
screen = screen,
|
||||
awesome = awesome
|
||||
}
|
||||
local gears_debug = require("gears.debug")
|
||||
|
||||
local xresources = require("beautiful.xresources")
|
||||
|
@ -99,7 +90,7 @@ end
|
|||
-- @treturn lgi.Pango.FontDescription
|
||||
function beautiful.get_merged_font(name, merge)
|
||||
local font = beautiful.get_font(name)
|
||||
local merge = Pango.FontDescription.from_string(merge)
|
||||
merge = Pango.FontDescription.from_string(merge)
|
||||
local merged = font:copy_static()
|
||||
merged:merge(merge, true)
|
||||
return beautiful.get_font(merged:to_string())
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
----------------------------------------------------------------------------
|
||||
|
||||
-- Grab environment
|
||||
local print = print
|
||||
local awesome = awesome
|
||||
local round = require("awful.util").round
|
||||
local gears_debug = require("gears.debug")
|
||||
|
|
|
@ -21,21 +21,6 @@ local setmetatable = setmetatable
|
|||
local string = string
|
||||
local table = table
|
||||
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 dirs = {}
|
||||
|
@ -98,8 +83,8 @@ local index_theme_cache = {}
|
|||
-- @tparam table base_directories Paths used for lookup
|
||||
-- @treturn table An instance of the class `icon_theme`
|
||||
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()
|
||||
local base_directories = base_directories or get_pragmatic_base_directories()
|
||||
icon_theme_name = icon_theme_name or beautiful.icon_theme or get_default_icon_theme_name()
|
||||
base_directories = base_directories or get_pragmatic_base_directories()
|
||||
|
||||
local self = {}
|
||||
self.icon_theme_name = icon_theme_name
|
||||
|
@ -238,10 +223,10 @@ end
|
|||
-- @tparam number icon_size Prefereable icon size
|
||||
-- @treturn string Absolute path to the icon file, or nil if not found
|
||||
function icon_theme:find_icon_path(icon_name, icon_size)
|
||||
icon_size = icon_size or 16
|
||||
if not icon_name or icon_name == "" then
|
||||
return nil
|
||||
end
|
||||
local icon_size = icon_size or 16
|
||||
|
||||
local filename = find_icon_path_helper(self, icon_name, icon_size)
|
||||
if filename then
|
||||
|
|
|
@ -189,7 +189,7 @@ local function menulist_update(query, scr)
|
|||
end
|
||||
|
||||
-- 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
|
||||
if not current_category or v.category == current_category then
|
||||
if string.match(v.name, pattern)
|
||||
|
@ -205,7 +205,7 @@ local function menulist_update(query, scr)
|
|||
end
|
||||
|
||||
-- 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)
|
||||
end
|
||||
|
||||
|
@ -315,7 +315,7 @@ function menubar.show(scr)
|
|||
local prompt_args = menubar.prompt_args or {}
|
||||
prompt_args.prompt = "Run: "
|
||||
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.util.get_cache_dir() .. "/history_menu",
|
||||
nil,
|
||||
|
|
|
@ -83,7 +83,7 @@ local function get_icon_lookup_path()
|
|||
table.insert(paths, 1, glib.get_user_data_dir())
|
||||
table.insert(paths, 1, glib.build_filenamev({glib.get_home_dir(),
|
||||
'.icons'}))
|
||||
for k,dir in ipairs(paths) do
|
||||
for _,dir in ipairs(paths) do
|
||||
local icons_dir = glib.build_filenamev({dir, 'icons'})
|
||||
if awful_util.dir_readable(icons_dir) then
|
||||
if icon_theme then
|
||||
|
@ -96,14 +96,14 @@ local function get_icon_lookup_path()
|
|||
glib.build_filenamev({icons_dir, 'hicolor'}))
|
||||
end
|
||||
end
|
||||
for i, icon_theme_directory in ipairs(icon_theme_paths) do
|
||||
for j, size in ipairs(all_icon_sizes) do
|
||||
for _, icon_theme_directory in ipairs(icon_theme_paths) do
|
||||
for _, size in ipairs(all_icon_sizes) do
|
||||
add_if_readable(icon_lookup_path,
|
||||
glib.build_filenamev({icon_theme_directory,
|
||||
size, 'apps'}))
|
||||
end
|
||||
end
|
||||
for k,dir in ipairs(paths)do
|
||||
for _,dir in ipairs(paths)do
|
||||
-- lowest priority fallbacks
|
||||
add_if_readable(icon_lookup_path,
|
||||
glib.build_filenamev({dir, 'pixmaps'}))
|
||||
|
@ -127,7 +127,7 @@ function utils.lookup_icon_uncached(icon_file)
|
|||
-- supported, do not perform a lookup.
|
||||
return awful_util.file_readable(icon_file) and icon_file or nil
|
||||
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
|
||||
awful_util.file_readable(directory .. "/" .. icon_file) then
|
||||
return directory .. "/" .. icon_file
|
||||
|
@ -170,6 +170,7 @@ function utils.parse(file)
|
|||
for line in io.lines(file) do
|
||||
if line:find("^%s*#") then
|
||||
-- Skip comments.
|
||||
(function() end)() -- I haven't found a nice way to silence luacheck here
|
||||
elseif not desktop_entry and line == "[Desktop Entry]" then
|
||||
desktop_entry = true
|
||||
else
|
||||
|
@ -260,7 +261,7 @@ end
|
|||
-- @treturn int Text width.
|
||||
function utils.compute_textbox_width(textbox, s)
|
||||
s = s or mouse.screen
|
||||
local w, h = textbox:get_preferred_size(s)
|
||||
local w, _ = textbox:get_preferred_size(s)
|
||||
return w
|
||||
end
|
||||
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
local util = require("awful.util")
|
||||
local say = require("say")
|
||||
|
||||
describe("awful.util", function()
|
||||
it("table.keys_filter", function()
|
||||
|
|
|
@ -162,7 +162,7 @@ describe("gears.color", function()
|
|||
|
||||
describe("create_opaque_pattern", function()
|
||||
-- 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) }))
|
||||
local pattern = color.create_opaque_pattern(arguments[1])
|
||||
return pattern ~= nil
|
||||
|
|
|
@ -54,7 +54,7 @@ describe("gears.object", function()
|
|||
obj:weak_connect_signal("signal", cb)
|
||||
|
||||
-- Check that the GC doesn't disconnect the signal
|
||||
for i = 1, 10 do
|
||||
for _ = 1, 10 do
|
||||
collectgarbage("collect")
|
||||
end
|
||||
|
||||
|
@ -149,7 +149,8 @@ describe("gears.object", function()
|
|||
finalized = true
|
||||
end
|
||||
if _VERSION <= "Lua 5.1" then
|
||||
local userdata = newproxy(true)
|
||||
-- luacheck: globals newproxy
|
||||
userdata = newproxy(true)
|
||||
getmetatable(userdata).__gc = gc
|
||||
getmetatable(userdata).callback = callback
|
||||
else
|
||||
|
|
|
@ -6,24 +6,24 @@
|
|||
-- Hack so that beautiful can be loaded
|
||||
_G.awesome = {
|
||||
xrdb_get_value = function() end,
|
||||
connect_signal = function(...) end,
|
||||
register_xproperty = function(...) end
|
||||
connect_signal = function() end,
|
||||
register_xproperty = function() end
|
||||
}
|
||||
-- Additional hacks to load menubar
|
||||
_G.screen = {
|
||||
add_signal = function(...) end,
|
||||
add_signal = function() end,
|
||||
count = function() return 0 end
|
||||
}
|
||||
_G.client = {
|
||||
connect_signal = function(...) end,
|
||||
add_signal = function(...) end
|
||||
connect_signal = function() end,
|
||||
add_signal = function() end
|
||||
}
|
||||
_G.tag = {
|
||||
connect_signal = function(...) end,
|
||||
add_signal = function(...) end
|
||||
connect_signal = function() end,
|
||||
add_signal = function() end
|
||||
}
|
||||
_G.root = {
|
||||
cursor = function(...) end
|
||||
cursor = function() end
|
||||
}
|
||||
|
||||
local os = os
|
||||
|
|
|
@ -7,7 +7,6 @@ local hierarchy = require("wibox.hierarchy")
|
|||
|
||||
local Region = require("lgi").cairo.Region
|
||||
local matrix = require("gears.matrix")
|
||||
local object = require("gears.object")
|
||||
local utils = require("wibox.test_utils")
|
||||
|
||||
local function make_widget(children)
|
||||
|
@ -18,8 +17,8 @@ local function make_widget(children)
|
|||
return result
|
||||
end
|
||||
|
||||
local function make_child(widget, width, height, matrix)
|
||||
return { _widget = widget, _width = width, _height = height, _matrix = matrix }
|
||||
local function make_child(widget, width, height, mat)
|
||||
return { _widget = widget, _width = width, _height = height, _matrix = mat }
|
||||
end
|
||||
|
||||
describe("wibox.hierarchy", function()
|
||||
|
@ -95,7 +94,7 @@ describe("wibox.hierarchy", function()
|
|||
end
|
||||
end
|
||||
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
|
||||
parent:emit_signal("widget::redraw_needed")
|
||||
|
@ -140,7 +139,7 @@ describe("wibox.hierarchy", function()
|
|||
assert.is.equal(#children, 1)
|
||||
hierarchy_intermediate = children[1]
|
||||
|
||||
local children = hierarchy_intermediate:get_children()
|
||||
children = hierarchy_intermediate:get_children()
|
||||
assert.is.equal(#children, 1)
|
||||
hierarchy_child = children[1]
|
||||
end)
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
---------------------------------------------------------------------------
|
||||
|
||||
local object = require("gears.object")
|
||||
local cache = require("gears.cache")
|
||||
local matrix_equals = require("gears.matrix").equals
|
||||
local base = require("wibox.widget.base")
|
||||
local say = require("say")
|
||||
|
@ -53,11 +52,11 @@ local function widget_layout(state, arguments)
|
|||
fits = false
|
||||
else
|
||||
for i = 1, #children do
|
||||
local child, expected = children[i], expected[i]
|
||||
if child._widget ~= expected._widget or
|
||||
child._width ~= expected._width or
|
||||
child._height ~= expected._height or
|
||||
not matrix_equals(child._matrix, expected._matrix) then
|
||||
local child, exp = children[i], expected[i]
|
||||
if child._widget ~= exp._widget or
|
||||
child._width ~= exp._width or
|
||||
child._height ~= exp._height or
|
||||
not matrix_equals(child._matrix, exp._matrix) then
|
||||
fits = false
|
||||
break
|
||||
end
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
-- Default awesome theme --
|
||||
---------------------------
|
||||
|
||||
theme = {}
|
||||
local theme = {}
|
||||
|
||||
theme.font = "sans 8"
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
-- If you want SVGs and extras, get them from garoth.com/awesome/sky-theme
|
||||
|
||||
-- BASICS
|
||||
theme = {}
|
||||
local theme = {}
|
||||
theme.font = "sans 8"
|
||||
|
||||
theme.bg_focus = "#e2eeea"
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
-- * http://awesome.naquadah.org/wiki/Nice_Icons
|
||||
|
||||
-- {{{ Main
|
||||
theme = {}
|
||||
local theme = {}
|
||||
theme.wallpaper = "@AWESOME_THEMES_PATH@/zenburn/zenburn-background.png"
|
||||
-- }}}
|
||||
|
||||
|
|
Loading…
Reference in New Issue