Merge branch 'more-luacheck-fixes' of https://github.com/psychon/awesome

This commit is contained in:
Uli Schlachter 2016-02-14 14:33:06 +01:00
commit 99ef5822b0
34 changed files with 198 additions and 258 deletions

View File

@ -7,7 +7,7 @@
local select = select
local setmetatable = setmetatable
local unpack = unpack or table.unpack
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
local cache = {}

View File

@ -8,7 +8,7 @@
local setmetatable = setmetatable
local string = string
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 tonumber = tonumber
local ipairs = ipairs
local pairs = pairs
@ -88,7 +88,6 @@ end
-- @param col The color for the pattern
-- @return A cairo pattern object
function color.create_solid_pattern(col)
local col = col
if col == nil then
col = "#000000"
elseif type(col) == "table" then
@ -102,7 +101,6 @@ end
-- @param file The filename of the file
-- @return a cairo pattern object
function color.create_png_pattern(file)
local file = file
if type(file) == "table" then
file = file.file
end
@ -138,7 +136,7 @@ local function string_pattern(creator, arg)
local args = { parse_numbers(iterator()) }
local to = { parse_numbers(iterator()) }
-- Now merge those two tables
for k, v in pairs(to) do
for _, v in pairs(to) do
table.insert(args, v)
end
-- And call our creator function with the values
@ -220,7 +218,7 @@ function color.create_pattern_uncached(col)
if cairo.Pattern:is_type_of(col) then
return col
end
local col = col or "#000000"
col = col or "#000000"
if type(col) == "string" then
local t = string.match(col, "[^:]+")
if color.types[t] then
@ -271,18 +269,17 @@ end
-- @return The pattern if it is surely opaque, else nil
function color.create_opaque_pattern(col)
local pattern = color.create_pattern(col)
local type = pattern:get_type()
local extend = pattern:get_extend()
local kind = pattern:get_type()
if type == "SOLID" then
local status, r, g, b, a = pattern:get_rgba()
if a ~= 1 then
if kind == "SOLID" then
local _, _, _, _, alpha = pattern:get_rgba()
if alpha ~= 1 then
return
end
return pattern
elseif type == "SURFACE" then
local status, surface = pattern:get_surface()
if status ~= "SUCCESS" or surface.content ~= "COLOR" then
elseif kind == "SURFACE" then
local status, surf = pattern:get_surface()
if status ~= "SUCCESS" or surf.content ~= "COLOR" then
-- The surface has an alpha channel which *might* be non-opaque
return
end
@ -294,8 +291,8 @@ function color.create_opaque_pattern(col)
end
return pattern
elseif type == "LINEAR" then
local status, stops = pattern:get_color_stop_count()
elseif kind == "LINEAR" then
local _, stops = pattern:get_color_stop_count()
-- No color stops or extend NONE -> pattern *might* contain transparency
if stops == 0 or pattern:get_extend() == "NONE" then
@ -304,8 +301,8 @@ function color.create_opaque_pattern(col)
-- Now check if any of the color stops contain transparency
for i = 0, stops - 1 do
local status, offset, r, g, b, a = pattern:get_color_stop_rgba(i)
if a ~= 1 then
local _, _, _, _, _, alpha = pattern:get_color_stop_rgba(i)
if alpha ~= 1 then
return
end
end
@ -330,7 +327,7 @@ function color.recolor_image(image, new_color)
return image
end
function color.mt:__call(...)
function color.mt.__call(_, ...)
return color.create_pattern(...)
end

View File

@ -5,9 +5,7 @@
-- @module gears.debug
---------------------------------------------------------------------------
local error = error
local tostring = tostring
local traceback = debug.traceback
local print = print
local type = type
local pairs = pairs

View File

@ -175,7 +175,7 @@ end
-- @treturn number The x coordinate of the transformed point.
-- @treturn number The x coordinate of the transformed point.
function matrix:transform_point(x, y)
local x, y = self:transform_distance(x, y)
x, y = self:transform_distance(x, y)
return self.x0 + x, self.y0 + y
end
@ -195,10 +195,10 @@ function matrix:transform_rectangle(x, y, width, height)
local x3, y3 = self:transform_point(x + width, y + height)
local x4, y4 = self:transform_point(x + width, y)
-- Find the extremal points of the result
local x = math.min(x1, x2, x3, x4)
local y = math.min(y1, y2, y3, y4)
local width = math.max(x1, x2, x3, x4) - x
local height = math.max(y1, y2, y3, y4) - y
x = math.min(x1, x2, x3, x4)
y = math.min(y1, y2, y3, y4)
width = math.max(x1, x2, x3, x4) - x
height = math.max(y1, y2, y3, y4) - y
return x, y, width, height
end

View File

@ -60,6 +60,7 @@ local function make_the_gc_obey(func)
-- Lua 5.1 only has the behaviour we want if a userdata is used as the
-- value in a weak table. Thus, do some magic so that we get a userdata.
-- luacheck: globals newproxy getfenv setfenv
local userdata = newproxy(true)
getmetatable(userdata).__gc = function() end
-- Now bind the lifetime of userdata to the lifetime of func. For this,
@ -137,7 +138,7 @@ local function new()
return ret
end
function object.mt:__call(...)
function object.mt.__call(_, ...)
return new(...)
end

View File

@ -64,9 +64,9 @@ end
-- @tparam[opt=10] number arrow_size The width and height of the arrow
-- @tparam[opt=width/2 - arrow_size/2] number arrow_position The position of the arrow
function module.infobubble(cr, width, height, corner_radius, arrow_size, arrow_position)
local corner_radius = corner_radius or 5
local arrow_size = arrow_size or 10
local arrow_position = arrow_position or width/2 - arrow_size/2
corner_radius = corner_radius or 5
arrow_size = arrow_size or 10
arrow_position = arrow_position or width/2 - arrow_size/2
cr:move_to(0 ,corner_radius)
@ -109,9 +109,9 @@ end
-- @tparam[opt=width /2] number shaft_width The width of the shaft of the arrow
-- @tparam[opt=height/2] number shaft_length The head_length of the shaft (the rest is the head)
function module.arrow(cr, width, height, head_width, shaft_width, shaft_length)
local shaft_length = shaft_length or height / 2
local shaft_width = shaft_width or width / 2
local head_width = head_width or width
shaft_length = shaft_length or height / 2
shaft_width = shaft_width or width / 2
head_width = head_width or width
local head_length = height - shaft_length
cr:move_to ( width/2 , 0 )
@ -146,7 +146,7 @@ end
-- @tparam number height The shape height
-- @tparam[opt=height/2] number arrow_depth The width of the arrow part of the shape
function module.powerline(cr, width, height, arrow_depth)
local arrow_depth = arrow_depth or height/2
arrow_depth = arrow_depth or height/2
cr:move_to(0 , 0 )
cr:line_to(width - arrow_depth , 0 )
cr:line_to(width , height/2 )

View File

@ -114,7 +114,7 @@ function surface.load(_surface)
return do_load_and_handle_errors(_surface, surface.load_silently)
end
function surface.mt:__call(...)
function surface.mt.__call(_, ...)
return surface.load(...)
end

View File

@ -14,7 +14,7 @@ local setmetatable = setmetatable
local table = table
local tonumber = tonumber
local traceback = debug.traceback
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 glib = require("lgi").GLib
local object = require("gears.object")
@ -43,7 +43,7 @@ function timer:start()
return
end
self.data.source_id = glib.timeout_add(glib.PRIORITY_DEFAULT, self.data.timeout * 1000, function()
local success, message = xpcall(function()
xpcall(function()
self:emit_signal("timeout")
end, function(err)
print(debug.traceback("Error during executing timeout handler: "..tostring(err)))
@ -160,7 +160,7 @@ end
local delayed_calls = {}
capi.awesome.connect_signal("refresh", function()
for _, callback in ipairs(delayed_calls) do
local success, message = xpcall(function()
xpcall(function()
callback[1](unpack(callback, 2))
end, function(err)
print(debug.traceback("Error during delayed call: "..tostring(err), 2))
@ -177,7 +177,7 @@ function timer.delayed_call(callback, ...)
table.insert(delayed_calls, { callback, ... })
end
function timer.mt:__call(...)
function timer.mt.__call(_, ...)
return timer.new(...)
end

View File

@ -58,9 +58,9 @@ function wallpaper.prepare_context(s)
-- Set the wallpaper (delayed)
timer.delayed_call(function()
local wp = pending_wallpaper
local paper = pending_wallpaper
pending_wallpaper = nil
wallpaper.set(wp)
wallpaper.set(paper)
end)
else
-- Draw to the already-pending wallpaper
@ -99,8 +99,8 @@ end
-- gears.color. The default is black.
function wallpaper.centered(surf, s, background)
local geom, cr = wallpaper.prepare_context(s)
local surf = surface(surf)
local background = color(background)
surf = surface(surf)
background = color(background)
-- Fill the area with the background
cr.operator = cairo.Operator.SOURCE
@ -122,7 +122,7 @@ end
-- all screens are set.
-- @param offset This can be set to a table with entries x and y.
function wallpaper.tiled(surf, s, offset)
local geom, cr = wallpaper.prepare_context(s)
local _, cr = wallpaper.prepare_context(s)
if offset then
cr:translate(offset.x, offset.y)
@ -144,7 +144,7 @@ end
-- @param offset This can be set to a table with entries x and y.
function wallpaper.maximized(surf, s, ignore_aspect, offset)
local geom, cr = wallpaper.prepare_context(s)
local surf = surface(surf)
surf = surface(surf)
local w, h = surface.get_size(surf)
local aspect_w = geom.width / w
local aspect_h = geom.height / h
@ -176,8 +176,8 @@ end
-- gears.color. The default is black.
function wallpaper.fit(surf, s, background)
local geom, cr = wallpaper.prepare_context(s)
local surf = surface(surf)
local background = color(background)
surf = surface(surf)
background = color(background)
-- Fill the area with the background
cr.operator = cairo.Operator.SOURCE

View File

@ -12,7 +12,6 @@ local pairs = pairs
local table = table
local type = type
local string = string
local tostring = tostring
local pcall = pcall
local capi = { screen = screen,
awesome = awesome }
@ -26,11 +25,6 @@ local surface = require("gears.surface")
local cairo = require("lgi").cairo
local dpi = require("beautiful").xresources.apply_dpi
local schar = string.char
local sbyte = string.byte
local tcat = table.concat
local tins = table.insert
local naughty = {}
--[[--
@ -169,7 +163,7 @@ end
--- Resume notifications
function naughty.resume()
suspended = false
for i, v in pairs(naughty.notifications.suspended) do
for _, v in pairs(naughty.notifications.suspended) do
v.box.visible = true
if v.timer then v.timer:start() end
end
@ -187,18 +181,18 @@ end
--- Evaluate desired position of the notification by index - internal
--
-- @param screen Screen to use
-- @param s Screen to use
-- @param position top_right | top_left | bottom_right | bottom_left
-- | top_middle | bottom_middle
-- @param idx Index of the notification
-- @param[opt] width Popup width.
-- @param height Popup height
-- @return Absolute position and index in { x = X, y = Y, idx = I } table
local function get_offset(screen, position, idx, width, height)
local ws = capi.screen[screen].workarea
local function get_offset(s, position, idx, width, height)
local ws = capi.screen[s].workarea
local v = {}
local idx = idx or #naughty.notifications[screen][position] + 1
local width = width or naughty.notifications[screen][position][idx].width
idx = idx or #naughty.notifications[s][position] + 1
width = width or naughty.notifications[s][position][idx].width
-- calculate x
if position:match("left") then
@ -212,7 +206,7 @@ local function get_offset(screen, position, idx, width, height)
-- calculate existing popups' height
local existing = 0
for i = 1, idx-1, 1 do
existing = existing + naughty.notifications[screen][position][i].height + naughty.config.spacing
existing = existing + naughty.notifications[s][position][i].height + naughty.config.spacing
end
-- calculate y
@ -227,20 +221,20 @@ local function get_offset(screen, position, idx, width, height)
-- e.g. critical ones.
local find_old_to_replace = function()
for i = 1, idx-1 do
local n = naughty.notifications[screen][position][i]
local n = naughty.notifications[s][position][i]
if n.timeout > 0 then
return n
end
end
-- Fallback to first one.
return naughty.notifications[screen][position][1]
return naughty.notifications[s][position][1]
end
-- if positioned outside workarea, destroy oldest popup and recalculate
if v.y + height > ws.y + ws.height or v.y < ws.y then
naughty.destroy(find_old_to_replace())
idx = idx - 1
v = get_offset(screen, position, idx, width, height)
v = get_offset(s, position, idx, width, height)
end
if not v.idx then v.idx = idx end
@ -250,10 +244,10 @@ end
--- Re-arrange notifications according to their position and index - internal
--
-- @return None
local function arrange(screen)
for p,pos in pairs(naughty.notifications[screen]) do
for i,notification in pairs(naughty.notifications[screen][p]) do
local offset = get_offset(screen, p, i, notification.width, notification.height)
local function arrange(s)
for p in pairs(naughty.notifications[s]) do
for i,notification in pairs(naughty.notifications[s][p]) do
local offset = get_offset(s, p, i, notification.width, notification.height)
notification.box:geometry({ x = offset.x, y = offset.y })
notification.idx = offset.idx
end
@ -296,8 +290,8 @@ end
function naughty.getById(id)
-- iterate the notifications to get the notfications with the correct ID
for s = 1, capi.screen.count() do
for p,pos in pairs(naughty.notifications[s]) do
for i,notification in pairs(naughty.notifications[s][p]) do
for p in pairs(naughty.notifications[s]) do
for _, notification in pairs(naughty.notifications[s][p]) do
if notification.id == id then
return notification
end
@ -437,7 +431,7 @@ function naughty.notify(args)
local icon_size = args.icon_size or preset.icon_size
local text = args.text or preset.text
local title = args.title or preset.title
local screen = args.screen or preset.screen or screen.focused()
local s = args.screen or preset.screen or screen.focused()
local ontop = args.ontop or preset.ontop
local width = args.width or preset.width
local height = args.height or preset.height
@ -455,7 +449,7 @@ function naughty.notify(args)
local fg = args.fg or preset.fg or beautiful.fg_normal or '#ffffff'
local bg = args.bg or preset.bg or beautiful.bg_normal or '#535d6c'
local border_color = args.border_color or preset.border_color or beautiful.bg_focus or '#535d6c'
local notification = { screen = screen, destroy_cb = destroy_cb, timeout = timeout }
local notification = { screen = s, destroy_cb = destroy_cb, timeout = timeout }
-- replace notification if needed
if args.replaces_id then
@ -530,8 +524,8 @@ function naughty.notify(args)
actiontextbox:set_markup(string.format('<b>%s</b>', action))
-- calculate the height and width
local w, h = actiontextbox:get_preferred_size(s)
local height = h + 2 * margin
local width = w + 2 * margin
local action_height = h + 2 * margin
local action_width = w + 2 * margin
actionmarginbox:buttons(util.table.join(
button({ }, 1, callback),
@ -539,9 +533,9 @@ function naughty.notify(args)
))
actionslayout:add(actionmarginbox)
actions_total_height = actions_total_height + height
if actions_max_width < width then
actions_max_width = width
actions_total_height = actions_total_height + action_height
if actions_max_width < action_width then
actions_max_width = action_width
end
end
end
@ -561,7 +555,7 @@ function naughty.notify(args)
end
-- is the icon file readable?
local icon = surface.load_uncached(icon)
icon = surface.load_uncached(icon)
-- if we have an icon, use it
if icon then
@ -593,7 +587,7 @@ function naughty.notify(args)
-- calculate the width
if not width then
local w, h = textbox:get_preferred_size(s)
local w, _ = textbox:get_preferred_size(s)
width = w + (iconbox and icon_w + 2 * margin or 0) + 2 * margin
end
@ -615,7 +609,7 @@ function naughty.notify(args)
height = height + actions_total_height
-- crop to workarea size if too big
local workarea = capi.screen[screen].workarea
local workarea = capi.screen[s].workarea
if width > workarea.width - 2 * (border_width or 0) - 2 * (naughty.config.padding or 0) then
width = workarea.width - 2 * (border_width or 0) - 2 * (naughty.config.padding or 0)
end
@ -628,7 +622,7 @@ function naughty.notify(args)
notification.width = width + 2 * (border_width or 0)
-- position the wibox
local offset = get_offset(screen, notification.position, nil, notification.width, notification.height)
local offset = get_offset(s, notification.position, nil, notification.width, notification.height)
notification.box.ontop = ontop
notification.box:geometry({ width = width,
height = height,
@ -657,7 +651,7 @@ function naughty.notify(args)
end)))
-- insert the notification to the table
table.insert(naughty.notifications[screen][notification.position], notification)
table.insert(naughty.notifications[s][notification.position], notification)
if suspended then
notification.box.visible = false

View File

@ -23,7 +23,7 @@ local schar = string.char
local sbyte = string.byte
local tcat = table.concat
local tins = table.insert
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 naughty = require("naughty.core")
--- Notification library, dbus bindings
@ -88,7 +88,7 @@ local function convert_icon(w, h, rowstride, channels, data)
-- Now convert each row on its own
local rows = {}
for y = 1, h do
for _ = 1, h do
local this_row = {}
for i = 1 + offset, w * channels + offset, channels do
@ -124,8 +124,8 @@ capi.dbus.connect_signal("org.freedesktop.Notifications", function (data, appnam
if appname ~= "" then
args.appname = appname
end
for i, obj in pairs(dbus.config.mapping) do
local filter, preset, s = obj[1], obj[2], 0
for _, obj in pairs(dbus.config.mapping) do
local filter, preset = obj[1], obj[2]
if (not filter.urgency or filter.urgency == hints.urgency) and
(not filter.category or filter.category == hints.category) and
(not filter.appname or filter.appname == appname) then
@ -176,8 +176,8 @@ capi.dbus.connect_signal("org.freedesktop.Notifications", function (data, appnam
-- 5 -> bits per sample
-- 6 -> channels
-- 7 -> data
local w, h, rowstride, _, _, channels, data = unpack(hints.icon_data)
args.icon = convert_icon(w, h, rowstride, channels, data)
local w, h, rowstride, _, _, channels, icon_data = unpack(hints.icon_data)
args.icon = convert_icon(w, h, rowstride, channels, icon_data)
end
if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then
args.replaces_id = replaces_id
@ -204,7 +204,7 @@ capi.dbus.connect_signal("org.freedesktop.Notifications", function (data, appnam
end
end)
capi.dbus.connect_signal("org.freedesktop.DBus.Introspectable", function (data, text)
capi.dbus.connect_signal("org.freedesktop.DBus.Introspectable", function (data)
if data.member == "Introspect" then
local xml = [=[<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object
Introspection 1.0//EN"

View File

@ -20,8 +20,7 @@ local surface = require("gears.surface")
local timer = require("gears.timer")
local matrix = require("gears.matrix")
local hierarchy = require("wibox.hierarchy")
local base = require("wibox.widget.base")
local unpack = unpack or table.unpack
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
local drawables = setmetatable({}, { __mode = 'k' })
local wallpaper = nil
@ -154,32 +153,32 @@ local function do_redraw(self)
assert(cr.status == "SUCCESS", "Cairo context entered error state: " .. cr.status)
end
local function find_widgets(drawable, result, hierarchy, x, y)
local m = hierarchy:get_matrix_from_device()
local function find_widgets(_drawable, result, _hierarchy, x, y)
local m = _hierarchy:get_matrix_from_device()
-- Is (x,y) inside of this hierarchy or any child (aka the draw extents)
local x1, y1 = m:transform_point(x, y)
local x2, y2, width, height = hierarchy:get_draw_extents()
if x1 < x2 or x1 >= x2 + width then
local x2, y2, w2, h2 = _hierarchy:get_draw_extents()
if x1 < x2 or x1 >= x2 + w2 then
return
end
if y1 < y2 or y1 >= y2 + height then
if y1 < y2 or y1 >= y2 + h2 then
return
end
-- Is (x,y) inside of this widget?
local width, height = hierarchy:get_size()
local width, height = _hierarchy:get_size()
if x1 >= 0 and y1 >= 0 and x1 <= width and y1 <= height then
-- Get the extents of this widget in the device space
local x2, y2, w2, h2 = matrix.transform_rectangle(hierarchy:get_matrix_to_device(),
local x3, y3, w3, h3 = matrix.transform_rectangle(_hierarchy:get_matrix_to_device(),
0, 0, width, height)
table.insert(result, {
x = x2, y = y2, width = w2, height = h2,
drawable = drawable, widget = hierarchy:get_widget()
x = x3, y = y3, width = w3, height = h3,
drawable = _drawable, widget = _hierarchy:get_widget()
})
end
for _, child in ipairs(hierarchy:get_children()) do
find_widgets(drawable, result, child, x, y)
for _, child in ipairs(_hierarchy:get_children()) do
find_widgets(_drawable, result, child, x, y)
end
end
@ -211,7 +210,7 @@ end
-- @param c The background to use. This must either be a cairo pattern object,
-- nil or a string that gears.color() understands.
function drawable:set_bg(c)
local c = c or "#000000"
c = c or "#000000"
local t = type(c)
if t == "string" or t == "table" then
@ -255,7 +254,7 @@ end
-- @param c The foreground to use. This must either be a cairo pattern object,
-- nil or a string that gears.color() understands.
function drawable:set_fg(c)
local c = c or "#FFFFFF"
c = c or "#FFFFFF"
if type(c) == "string" or type(c) == "table" then
c = color(c)
end
@ -265,7 +264,7 @@ end
local function emit_difference(name, list, skip)
local function in_table(table, val)
for k, v in pairs(table) do
for _, v in pairs(table) do
if v.widget == val.widget then
return true
end
@ -273,7 +272,7 @@ local function emit_difference(name, list, skip)
return false
end
for k, v in pairs(list) do
for _, v in pairs(list) do
if not in_table(skip, v) then
v.widget:emit_signal(name,v)
end
@ -371,9 +370,9 @@ function drawable.new(d, widget_context_skeleton, drawable_name)
ret._widgets_under_mouse = {}
local function button_signal(name)
d:connect_signal(name, function(d, x, y, button, modifiers)
d:connect_signal(name, function(_, x, y, button, modifiers)
local widgets = ret:find_widgets(x, y)
for k, v in pairs(widgets) do
for _, v in pairs(widgets) do
-- Calculate x/y inside of the widget
local lx = x - v.x
local ly = y - v.y
@ -388,12 +387,12 @@ function drawable.new(d, widget_context_skeleton, drawable_name)
d:connect_signal("mouse::leave", function() handle_leave(ret) end)
-- Set up our callbacks for repaints
ret._redraw_callback = function(hierarchy, arg)
ret._redraw_callback = function(hierar, arg)
if ret._widget_hierarchy_callback_arg ~= arg then
return
end
local m = hierarchy:get_matrix_to_device()
local x, y, width, height = matrix.transform_rectangle(m, hierarchy:get_draw_extents())
local m = hierar:get_matrix_to_device()
local x, y, width, height = matrix.transform_rectangle(m, hierar:get_draw_extents())
local x1, y1 = math.floor(x), math.floor(y)
local x2, y2 = math.ceil(x + width), math.ceil(y + height)
ret._dirty_area:union_rectangle(cairo.RectangleInt{
@ -401,7 +400,7 @@ function drawable.new(d, widget_context_skeleton, drawable_name)
})
ret:draw()
end
ret._layout_callback = function(hierarchy, arg)
ret._layout_callback = function(_, arg)
if ret._widget_hierarchy_callback_arg ~= arg then
return
end
@ -413,7 +412,7 @@ function drawable.new(d, widget_context_skeleton, drawable_name)
ret.drawable_name = drawable_name or object.modulename(3)
local mt = {}
local orig_string = tostring(ret)
mt.__tostring = function(o)
mt.__tostring = function()
return string.format("%s (%s)", ret.drawable_name, orig_string)
end
ret = setmetatable(ret, mt)
@ -426,7 +425,6 @@ end
-- Redraw all drawables when the wallpaper changes
capi.awesome.connect_signal("wallpaper_changed", function()
local k
wallpaper = nil
for k in pairs(drawables) do
k()

View File

@ -16,7 +16,7 @@ local no_parent = base.no_parent_I_know_what_I_am_doing
local hierarchy = {}
local function hierarchy_new(widget, redraw_callback, layout_callback, callback_arg)
local function hierarchy_new(redraw_callback, layout_callback, callback_arg)
local result = {
_matrix = matrix.identity,
_matrix_to_device = matrix.identity,
@ -107,7 +107,7 @@ function hierarchy_update(self, context, widget, width, height, region, matrix_t
for _, w in ipairs(layout_result or {}) do
local r = table.remove(old_children, 1)
if not r then
r = hierarchy_new(w._widget, self._redraw_callback, self._layout_callback, self._callback_arg)
r = hierarchy_new(self._redraw_callback, self._layout_callback, self._callback_arg)
r._parent = self
end
hierarchy_update(r, context, w._widget, w._width, w._height, region, w._matrix, matrix_to_device * w._matrix)
@ -132,12 +132,12 @@ function hierarchy_update(self, context, widget, width, height, region, matrix_t
-- Check which part needs to be redrawn
-- Are there any children which were removed? Their area needs a redraw.
for _, h in ipairs(old_children) do
local x, y, width, height = matrix.transform_rectangle(h._matrix_to_device, h:get_draw_extents())
for _, child in ipairs(old_children) do
local x, y, w, h = matrix.transform_rectangle(child._matrix_to_device, child:get_draw_extents())
region:union_rectangle(cairo.RectangleInt{
x = x, y = y, width = width, height = height
x = x, y = y, width = w, height = h
})
h._parent = nil
child._parent = nil
end
-- Did we change and need to be redrawn?
@ -167,7 +167,7 @@ end
-- @param callback_arg A second argument that is given to the above callbacks.
-- @return A new widget hierarchy
function hierarchy.new(context, widget, width, height, redraw_callback, layout_callback, callback_arg)
local result = hierarchy_new(widget, redraw_callback, layout_callback, callback_arg)
local result = hierarchy_new(redraw_callback, layout_callback, callback_arg)
result:update(context, widget, width, height)
return result
end
@ -181,7 +181,7 @@ end
-- @return A cairo region describing the changed parts (either the `region`
-- argument or a new, internally created region).
function hierarchy:update(context, widget, width, height, region)
local region = region or cairo.Region.create()
region = region or cairo.Region.create()
hierarchy_update(self, context, widget, width, height, region, self._matrix, self._matrix_to_device)
return region
end
@ -247,7 +247,7 @@ end
--- Does the given cairo context have an empty clip (aka "no drawing possible")?
local function empty_clip(cr)
local x, y, width, height = cr:clip_extents()
local _, _, width, height = cr:clip_extents()
return width == 0 or height == 0
end

View File

@ -13,13 +13,8 @@ local capi = {
local setmetatable = setmetatable
local pairs = pairs
local type = type
local table = table
local string_format = string.format
local color = require("gears.color")
local object = require("gears.object")
local beautiful = require("beautiful")
local surface = require("gears.surface")
local cairo = require("lgi").cairo
local base = require("wibox.widget.base")
--- This provides widget box windows. Every wibox can also be used as if it were
@ -82,15 +77,16 @@ for _, k in pairs{ "buttons", "struts", "geometry", "get_xproperty", "set_xprope
end
local function setup_signals(_wibox)
local w = _wibox.drawin
local obj
local function clone_signal(name)
_wibox:add_signal(name)
-- When "name" is emitted on wibox.drawin, also emit it on wibox
w:connect_signal(name, function(_, ...)
obj:connect_signal(name, function(_, ...)
_wibox:emit_signal(name, ...)
end)
end
obj = _wibox.drawin
clone_signal("property::border_color")
clone_signal("property::border_width")
clone_signal("property::buttons")
@ -104,14 +100,7 @@ local function setup_signals(_wibox)
clone_signal("property::x")
clone_signal("property::y")
local d = _wibox._drawable
local function clone_signal(name)
_wibox:add_signal(name)
-- When "name" is emitted on wibox.drawin, also emit it on wibox
d:connect_signal(name, function(_, ...)
_wibox:emit_signal(name, ...)
end)
end
obj = _wibox._drawable
clone_signal("button::press")
clone_signal("button::release")
clone_signal("mouse::enter")
@ -146,7 +135,7 @@ local function new(args)
-- Add __tostring method to metatable.
local mt = {}
local orig_string = tostring(ret)
mt.__tostring = function(o)
mt.__tostring = function()
return string.format("wibox: %s (%s)",
tostring(ret._drawable), orig_string)
end

View File

@ -5,7 +5,6 @@
-- @classmod wibox.layout.align
---------------------------------------------------------------------------
local setmetatable = setmetatable
local table = table
local pairs = pairs
local type = type
@ -125,6 +124,7 @@ function align:layout(context, width, height)
x, y = size_first, 0
end
else
local _
if self.dir == "y" then
_, h = base.fit_widget(self, context, self.second, width, size_second)
y = floor( (height - h)/2 )
@ -192,7 +192,7 @@ function align:fit(context, orig_width, orig_height)
local used_in_dir = 0
local used_in_other = 0
for k, v in pairs{self.first, self.second, self.third} do
for _, v in pairs{self.first, self.second, self.third} do
local w, h = base.fit_widget(self, context, v, orig_width, orig_height)
local max = self.dir == "y" and w or h
@ -233,7 +233,7 @@ function align:set_expand(mode)
end
function align:reset()
for k, v in pairs({ "first", "second", "third" }) do
for _, v in pairs({ "first", "second", "third" }) do
self[v] = nil
end
self:emit_signal("widget::layout_changed")

View File

@ -14,7 +14,7 @@ local math = math
local constraint = { mt = {} }
--- Layout a constraint layout
function constraint:layout(context, width, height)
function constraint:layout(_, width, height)
if self.widget then
return { base.place_widget_at(self.widget, 0, 0, width, height) }
end
@ -62,14 +62,14 @@ end
-- 'min' or 'exact'. Throws an error on invalid values.
function constraint:set_strategy(val)
local func = {
min = function(real_size, constraint)
return constraint and math.max(constraint, real_size) or real_size
min = function(real_size, limit)
return limit and math.max(limit, real_size) or real_size
end,
max = function(real_size, constraint)
return constraint and math.min(constraint, real_size) or real_size
max = function(real_size, limit)
return limit and math.min(limit, real_size) or real_size
end,
exact = function(real_size, constraint)
return constraint or real_size
exact = function(real_size, limit)
return limit or real_size
end
}

View File

@ -22,7 +22,6 @@ function fixed:layout(context, width, height)
for k, v in pairs(self.widgets) do
local x, y, w, h, _
local in_dir
if self.dir == "y" then
x, y = 0, pos
w, h = width, height - pos
@ -30,7 +29,6 @@ function fixed:layout(context, width, height)
_, h = base.fit_widget(self, context, v, w, h);
end
pos = pos + h + spacing
in_dir = h
else
x, y = pos, 0
w, h = width - pos, height
@ -38,7 +36,6 @@ function fixed:layout(context, width, height)
w, _ = base.fit_widget(self, context, v, w, h);
end
pos = pos + w + spacing
in_dir = w
end
if (self.dir == "y" and pos-spacing > height) or
@ -213,7 +210,7 @@ function fixed:fit(context, orig_width, orig_height)
local width, height = orig_width, orig_height
local used_in_dir, used_max = 0, 0
for k, v in pairs(self.widgets) do
for _, v in pairs(self.widgets) do
local w, h = base.fit_widget(self, context, v, width, height)
local in_dir, max
if self.dir == "y" then

View File

@ -107,11 +107,7 @@ local flex = {}
-- @name insert
-- @class function
--- Layout a flex layout. Each widget gets an equal share of the available space.
-- @param context The context in which we are drawn.
-- @param width The available width.
-- @param height The available height.
function flex:layout(context, width, height)
function flex:layout(_, width, height)
local result = {}
local pos,spacing = 0, self._spacing
local num = #self.widgets
@ -128,7 +124,7 @@ function flex:layout(context, width, height)
space_per_item = math.min(space_per_item, self._max_widget_size)
end
for k, v in pairs(self.widgets) do
for _, v in pairs(self.widgets) do
local x, y, w, h
if self.dir == "y" then
x, y = 0, util.round(pos)
@ -163,7 +159,7 @@ function flex:fit(context, orig_width, orig_height)
local sub_height = self.dir == "x" and orig_height or orig_height / #self.widgets
local sub_width = self.dir == "y" and orig_width or orig_width / #self.widgets
for k, v in pairs(self.widgets) do
for _, v in pairs(self.widgets) do
local w, h = base.fit_widget(self, context, v, sub_width, sub_height)
local max = self.dir == "y" and w or h

View File

@ -15,7 +15,7 @@ local cairo = require("lgi").cairo
local margin = { mt = {} }
--- Draw a margin layout
function margin:draw(context, cr, width, height)
function margin:draw(_, cr, width, height)
local x = self.left
local y = self.top
local w = self.right
@ -36,7 +36,7 @@ function margin:draw(context, cr, width, height)
end
--- Layout a margin layout
function margin:layout(context, width, height)
function margin:layout(_, width, height)
if self.widget then
local x = self.left
local y = self.top
@ -141,7 +141,7 @@ end
-- @class function
-- Create setters for each direction
for k, v in pairs({ "left", "right", "top", "bottom" }) do
for _, v in pairs({ "left", "right", "top", "bottom" }) do
margin["set_" .. v] = function(layout, val)
layout[v] = val
layout:emit_signal("widget::layout_changed")

View File

@ -10,7 +10,6 @@
local base = require("wibox.widget.base" )
local flex = require("wibox.layout.flex" )
local fixed = require("wibox.layout.fixed")
local table = table
local pairs = pairs
local floor = math.floor
@ -125,21 +124,12 @@ local function normalize(self)
assert(new_sum > 0.99 and new_sum < 1.01)
end
--- Layout a ratio layout. Each widget gets a share of the size proportional
-- to its ratio
-- @param context The context in which we are drawn.
-- @tparam number width The available width.
-- @tparam number height The available height.
function ratio:layout(context, width, height)
function ratio:layout(_, width, height)
local result = {}
local pos,spacing = 0, self._spacing
local num = #self.widgets
local total_spacing = (spacing*(num-1))
--normalize(self)
for k, v in ipairs(self.widgets) do
local space = nil
local space
local x, y, w, h
if self.dir == "y" then
@ -179,8 +169,6 @@ function ratio:inc_ratio(index, increment)
return
end
local widget = self.widgets[index]
assert(self._ratios[index])
self:set_ratio(index, self._ratios[index] + increment)
@ -214,7 +202,7 @@ function ratio:set_ratio(index, percent)
-- Remove what has to be cleared from all widget
local delta = ( (percent-old) / (#self.widgets-1) )
for k, v in pairs(self.widgets) do
for k in pairs(self.widgets) do
self._ratios[k] = self._ratios[k] - delta
end

View File

@ -25,7 +25,7 @@ local function transform(layout, width, height)
end
--- Layout this layout
function rotate:layout(context, width, height)
function rotate:layout(_, width, height)
if not self.widget or not self.widget.visible then
return
end

View File

@ -6,14 +6,11 @@
---------------------------------------------------------------------------
local cache = require("gears.cache")
local color = require("gears.color")
local matrix = require("gears.matrix")
local timer = require("gears.timer")
local hierarchy = require("wibox.hierarchy")
local base = require("wibox.widget.base")
local lgi = require("lgi")
local GLib = lgi.GLib
local cairo = lgi.cairo
local scroll = {}
local scroll_mt = { __index = scroll }
@ -34,8 +31,7 @@ end
-- Create a hierarchy (and some more stuff) for drawing the given widget. This
-- allows "some stuff" to be re-used instead of re-created all the time.
local hierarchy_cache = cache.new(function(context, widget, width, height)
local context = cleanup_context(context)
local surface = cairo.ImageSurface(cairo.Format.ARGB32, width, height)
context = cleanup_context(context)
local layouts = setmetatable({}, { __mode = "k" })
-- Create a widget hierarchy and update when needed
@ -50,10 +46,10 @@ local hierarchy_cache = cache.new(function(context, widget, width, height)
w:emit_signal(signal)
end
end
local function redraw_callback(h, arg)
local function redraw_callback()
emit("widget::redraw_needed")
end
local function layout_callback(h, arg)
local function layout_callback()
emit("widget::redraw_needed")
emit("widget::layout_changed")
end
@ -122,11 +118,11 @@ local function calculate_info(self, context, width, height)
end
result.first_x, result.first_y = x, y
-- Was the extra space already included elsewhere?
local extra = self.expand and 0 or self.extra_space
local extra_spacer = self.expand and 0 or self.extra_space
if self.dir == "h" then
x = x + surface_width + extra
x = x + surface_width + extra_spacer
else
y = y + surface_height + extra
y = y + surface_height + extra_spacer
end
result.second_x, result.second_y = x, y
else
@ -135,10 +131,10 @@ local function calculate_info(self, context, width, height)
result.surface_width, result.surface_height = surface_width, surface_height
-- Get the hierarchy and subscribe ourselves to updates
local hier, do_pending_updates, context = hierarchy_cache:get(context,
local hier, do_pending_updates, ctx = hierarchy_cache:get(context,
self.widget, surface_width, surface_height)
result.hierarchy = hier
result.context = context
result.context = ctx
do_pending_updates(self)
return result
@ -429,19 +425,19 @@ scroll.step_functions = {}
--- A step function that scrolls the widget in an increasing direction with
-- constant speed.
function scroll.step_functions.linear_increase(elapsed, size, visible_size, speed, extra_space)
function scroll.step_functions.linear_increase(elapsed, size, _, speed, extra_space)
return (elapsed * speed) % (size + extra_space)
end
--- A step function that scrolls the widget in an decreasing direction with
-- constant speed.
function scroll.step_functions.linear_decrease(elapsed, size, visible_size, speed, extra_space)
function scroll.step_functions.linear_decrease(elapsed, size, _, speed, extra_space)
return (-elapsed * speed) % (size + extra_space)
end
--- A step function that scrolls the widget to its end and back to its
-- beginning, then back to its end, etc. The speed is constant.
function scroll.step_functions.linear_back_and_forth(elapsed, size, visible_size, speed, extra_space)
function scroll.step_functions.linear_back_and_forth(elapsed, size, visible_size, speed)
local state = ((elapsed * speed) % (2 * size)) / size
state = state <= 1 and state or 2 - state
return (size - visible_size) * state
@ -450,7 +446,7 @@ end
--- A step function that scrolls the widget to its end and back to its
-- beginning, then back to its end, etc. The speed is null at the ends and
-- maximal in the middle.
function scroll.step_functions.nonlinear_back_and_forth(elapsed, size, visible_size, speed, extra_space)
function scroll.step_functions.nonlinear_back_and_forth(elapsed, size, visible_size, speed)
local state = ((elapsed * speed) % (2 * size)) / size
local negate = false
if state > 1 then
@ -478,7 +474,7 @@ end
--- A step function that scrolls the widget to its end and back to its
-- beginning, then back to its end, etc. The speed is null at the ends and
-- maximal in the middle. At both ends the widget stands still for a moment.
function scroll.step_functions.waiting_nonlinear_back_and_forth(elapsed, size, visible_size, speed, extra_space)
function scroll.step_functions.waiting_nonlinear_back_and_forth(elapsed, size, visible_size, speed)
local state = ((elapsed * speed) % (2 * size)) / size
local negate = false
if state > 1 then

View File

@ -18,7 +18,6 @@ local base = require("wibox.widget.base" )
local fixed = require("wibox.layout.fixed")
local table = table
local pairs = pairs
local floor = math.floor
local util = require("awful.util")
local stack = {mt={}}
@ -97,15 +96,11 @@ local stack = {mt={}}
-- @name set_spacing
-- @class function
--- Layout a stack layout. Each widget get drawn on top of each other
-- @param context The context in which we are drawn.
-- @param width The available width.
-- @param height The available height.
function stack:layout(context, width, height)
function stack:layout(_, width, height)
local result = {}
local spacing = self._spacing
for k, v in pairs(self.widgets) do
for _, v in pairs(self.widgets) do
table.insert(result, base.place_widget_at(v, spacing, spacing, width - 2*spacing, height - 2*spacing))
if self._top_only then break end
end
@ -113,15 +108,11 @@ function stack:layout(context, width, height)
return result
end
--- Fit the stack layout into the given space
-- @param context The context in which we are fit.
-- @param orig_width The available width.
-- @param orig_height The available height.
function stack:fit(context, orig_width, orig_height)
local max_w, max_h = 0,0
local spacing = self._spacing
for k, v in pairs(self.widgets) do
for _, v in pairs(self.widgets) do
local w, h = base.fit_widget(self, context, v, orig_width, orig_height)
max_w, max_h = math.max(max_w, w+2*spacing), math.max(max_h, h+2*spacing)
end

View File

@ -13,7 +13,7 @@ local cairo = require("lgi").cairo
local setmetatable = setmetatable
local pairs = pairs
local type = type
local unpack = unpack or table.unpack
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
local background = { mt = {} }
@ -55,7 +55,7 @@ function background:draw(context, cr, width, height)
end
-- Draw the border
function background:after_draw_children(context, cr, width, height)
function background:after_draw_children(_, cr)
-- Draw the border
if self._path and self._shape_border_width and self._shape_border_width > 0 then
cr:append_path(self._path)
@ -68,14 +68,14 @@ function background:after_draw_children(context, cr, width, height)
end
--- Prepare drawing the children of this widget
function background:before_draw_children(context, cr, width, height)
function background:before_draw_children(_, cr)
if self.foreground then
cr:set_source(self.foreground)
end
end
--- Layout this widget
function background:layout(context, width, height)
function background:layout(_, width, height)
if self.widget then
return { base.place_widget_at(self.widget, 0, 0, width, height) }
end

View File

@ -85,13 +85,13 @@ end
-- The default implementation does nothing, this must be re-implemented by
-- all layout and container widgets.
-- @tparam table children A table composed of valid widgets
function base.widget:set_children(children)
function base.widget:set_children(children) -- luacheck: no unused
-- Nothing on purpose
end
-- It could have been merged into `get_all_children`, but it's not necessary
local function digg_children(ret, tlw)
for k, w in ipairs(tlw:get_children()) do
for _, w in ipairs(tlw:get_children()) do
table.insert(ret, w)
digg_children(ret, w)
end
@ -122,9 +122,9 @@ function base.widget:index(widget, recursive, ...)
if w == widget then
return idx, self, {...}
elseif recursive then
local idx, l, path = w:index(widget, true, self, ...)
if idx and l then
return idx, l, path
local child_idx, l, path = w:index(widget, true, self, ...)
if child_idx and l then
return child_idx, l, path
end
end
end
@ -206,8 +206,8 @@ function base.fit_widget(parent, context, widget, width, height)
end
-- Sanitize the input. This also filters out e.g. NaN.
local width = math.max(0, width)
local height = math.max(0, height)
width = math.max(0, width)
height = math.max(0, height)
local w, h = 0, 0
if widget.fit then
@ -250,8 +250,8 @@ function base.layout_widget(parent, context, widget, width, height)
end
-- Sanitize the input. This also filters out e.g. NaN.
local width = math.max(0, width)
local height = math.max(0, height)
width = math.max(0, width)
height = math.max(0, height)
if widget.layout then
return get_cache(widget, "layout"):get(context, width, height)
@ -261,6 +261,7 @@ end
-- Handle a button event on a widget. This is used internally and should not be
-- called directly.
function base.handle_button(event, widget, x, y, button, modifiers, geometry)
x = x or y -- luacheck: no unused
local function is_any(mod)
return #mod == 1 and mod[1] == "Any"
end
@ -279,7 +280,7 @@ function base.handle_button(event, widget, x, y, button, modifiers, geometry)
-- Find all matching button objects
local matches = {}
for k, v in pairs(widget.widget_buttons) do
for _, v in pairs(widget.widget_buttons) do
local match = true
-- Is it the right button?
if v.button ~= 0 and v.button ~= button then match = false end
@ -291,7 +292,7 @@ function base.handle_button(event, widget, x, y, button, modifiers, geometry)
end
-- Emit the signals
for k, v in pairs(matches) do
for _, v in pairs(matches) do
v:emit_signal(event,geometry)
end
end
@ -332,7 +333,6 @@ end
-- Read the table, separate attributes from widgets
local function parse_table(t, leave_empty)
local keys= {}
local max = 0
local attributes, widgets = {}, {}
for k,v in pairs(t) do
@ -450,12 +450,12 @@ function base.make_widget_declarative(args)
local w, id = drill(ids, args)
local mt = {}
local orig_string = tostring(ret)
local orig_string = tostring(w)
rawset(w, "_by_id", ids)
rawset(w, "get_children_by_id", get_children_by_id)
mt.__tostring = function(o)
mt.__tostring = function()
return string.format("%s (%s)", id, orig_string)
end
@ -518,7 +518,7 @@ function base.make_widget(proxy, widget_name)
ret.fit = function(_, context, width, height)
return base.fit_widget(ret, context, proxy, width, height)
end
ret.layout = function(_, context, width, height)
ret.layout = function(_, _, width, height)
return { base.place_widget_at(proxy, 0, 0, width, height) }
end
proxy:connect_signal("widget::layout_changed", function()
@ -544,7 +544,7 @@ function base.make_widget(proxy, widget_name)
ret.widget_name = widget_name or object.modulename(3)
local mt = {}
local orig_string = tostring(ret)
mt.__tostring = function(o)
mt.__tostring = function()
return string.format("%s (%s)", ret.widget_name, orig_string)
end
return setmetatable(ret, mt)
@ -559,7 +559,7 @@ end
-- widget is not a valid widget.
function base.check_widget(widget)
assert(type(widget) == "table")
for k, func in pairs({ "add_signal", "connect_signal", "disconnect_signal" }) do
for _, func in pairs({ "add_signal", "connect_signal", "disconnect_signal" }) do
assert(type(widget[func]) == "function", func .. " is not a function")
end
end

View File

@ -10,14 +10,13 @@ local surface = require("gears.surface")
local setmetatable = setmetatable
local pairs = pairs
local type = type
local pcall = pcall
local print = print
local unpack = unpack or table.unpack
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
local imagebox = { mt = {} }
--- Draw an imagebox with the given cairo context in the given geometry.
function imagebox:draw(context, cr, width, height)
function imagebox:draw(_, cr, width, height)
if not self._image then return end
if width == 0 or height == 0 then return end
@ -42,7 +41,7 @@ function imagebox:draw(context, cr, width, height)
end
--- Fit the imagebox into the given geometry
function imagebox:fit(context, width, height)
function imagebox:fit(_, width, height)
if not self._image then
return 0, 0
end
@ -81,8 +80,6 @@ end
-- interpreted as the path to a png image file.
-- @return true on success, false if the image cannot be used
function imagebox:set_image(image)
local image = image
if type(image) == "string" then
image = surface.load(image)
if not image then

View File

@ -48,7 +48,7 @@ function systray:draw(context, cr, width, height)
base, is_rotated, bg, reverse, spacing)
end
function systray:fit(context, width, height)
function systray:fit(_, width, height)
local num_entries = capi.awesome.systray()
local base = base_size
local spacing = beautiful.systray_icon_spacing or 0
@ -76,7 +76,7 @@ local function new(revers)
ret.draw = systray.draw
ret.set_base_size = function(_, size) base_size = size end
ret.set_horizontal = function(_, horiz) horizontal = horiz end
ret.set_reverse = function(revers) reverse = revers end
ret.set_reverse = function(arg) reverse = arg end
if revers then
ret:set_reverse(true)

View File

@ -10,13 +10,11 @@ local base = require("wibox.widget.base")
local gdebug = require("gears.debug")
local beautiful = require("beautiful")
local lgi = require("lgi")
local cairo = lgi.cairo
local Pango = lgi.Pango
local PangoCairo = lgi.PangoCairo
local type = type
local setmetatable = setmetatable
local pairs = pairs
local error = error
local textbox = { mt = {} }
@ -40,7 +38,7 @@ end
function textbox:draw(context, cr, width, height)
setup_layout(self, width, height, context.dpi)
cr:update_layout(self._layout)
local ink, logical = self._layout:get_pixel_extents()
local _, logical = self._layout:get_pixel_extents()
local offset = 0
if self._valign == "center" then
offset = (height - logical.height) / 2
@ -52,7 +50,7 @@ function textbox:draw(context, cr, width, height)
end
local function do_fit_return(self)
local ink, logical = self._layout:get_pixel_extents()
local _, logical = self._layout:get_pixel_extents()
if logical.width == 0 or logical.height == 0 then
return 0, 0
end
@ -110,7 +108,7 @@ function textbox:get_height_for_width_at_dpi(width, dpi)
setup_dpi(self, dpi)
self._layout.width = Pango.units_from_double(width)
self._layout.height = -max_lines -- show this many lines per paragraph
local w, h = do_fit_return(self)
local _, h = do_fit_return(self)
return h
end
@ -261,7 +259,7 @@ local function new(text, ignore_markup)
return ret
end
function textbox.mt:__call(...)
function textbox.mt.__call(_, ...)
return new(...)
end

View File

@ -1,7 +1,7 @@
local timer = require("gears.timer")
local awful = require("awful")
runner = {
local runner = {
quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1',
-- quit-on-timeout defaults to false: indicates some problem with the test itself.
quit_awesome_on_timeout = os.getenv('TEST_QUIT_ON_TIMEOUT') ~= '1',

View File

@ -15,7 +15,7 @@ do
local timer_measure = GLib.Timer()
measure = function(f, iter)
timer_measure:start()
for i = 1, iter do
for _ = 1, iter do
f()
end
local elapsed = timer_measure:elapsed()
@ -47,7 +47,7 @@ local function create_and_draw_wibox()
do_pending_repaint()
end
local wb, textclock = create_wibox()
local _, textclock = create_wibox()
local function relayout_textclock()
textclock:emit_signal("widget::layout_changed")

View File

@ -1,10 +1,9 @@
--- Tests for focus signals / property.
-- Test for https://github.com/awesomeWM/awesome/issues/134.
awful = require("awful")
timer = require("gears.timer")
local awful = require("awful")
beautiful = require("beautiful")
local beautiful = require("beautiful")
beautiful.border_normal = "#0000ff"
beautiful.border_focus = "#00ff00"

View File

@ -3,17 +3,15 @@
local awful = require("awful")
local cairo = require("lgi").cairo
local create_wibox = require("_wibox_helper").create_wibox
local gears = require("gears")
local wibox = require("wibox")
local errors = {}
local prepare_for_collect = nil
local function emit_refresh()
awesome.emit_signal("refresh")
end
-- Make the layoutbox in the default config GC'able
-- luacheck: globals mywibox mylayoutbox
mywibox[1].visible = false
mywibox = nil
mylayoutbox = nil
@ -23,7 +21,7 @@ emit_refresh()
local function collectable(a, b, c, d, e, f, g, h, last)
assert(last == nil, "got more arguments than supported")
local objs = setmetatable({ a, b, c, d, e, f, g, h }, { __mode = "v" })
a, b, c, d, e, f, g, h = nil, nil, nil, nil, nil, nil, nil, nil
a, b, c, d, e, f, g, h = nil, nil, nil, nil, nil, nil, nil, nil -- luacheck: ignore
if prepare_for_collect then
prepare_for_collect()
prepare_for_collect = nil
@ -31,7 +29,7 @@ local function collectable(a, b, c, d, e, f, g, h, last)
collectgarbage("collect")
collectgarbage("collect")
-- Check if the table is now empty
for k, v in pairs(objs) do
for _, v in pairs(objs) do
print("Some object was not garbage collected!")
error(v)
end

View File

@ -16,7 +16,6 @@ local steps = {
if count == 1 then
ret, snid = spawn('urxvt', true)
elseif manage_called then
local c = client.get()[1]
assert(ret)
assert(snid)
assert(snid == c_snid)

View File

@ -1,6 +1,10 @@
--- Tests for urgent property.
awful = require("awful")
local awful = require("awful")
local runner = require("_runner")
-- This uses the global "tags" array set in the default config
-- luacheck: globals tags
-- Some basic assertion that the tag is not marked "urgent" already.
assert(awful.tag.getproperty(tags[1][2], "urgent") == nil)
@ -53,7 +57,7 @@ local steps = {
elseif awful.tag.selectedlist()[1] == tags[1][2] then
assert(#client.get() == 1)
c = client.get()[1]
local c = client.get()[1]
assert(not c.urgent, "Client is not urgent anymore.")
assert(c == client.focus, "Client is focused.")
assert(awful.tag.getproperty(tags[1][2], "urgent") == false)
@ -106,6 +110,6 @@ local steps = {
end,
}
require("_runner").run_steps(steps)
runner.run_steps(steps)
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80