Fix luacheck warnings for the rest of awful

This fixes *most* luacheck warnings in awful. However, some non-trivial ones
remain for latter.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-02-07 15:24:08 +01:00
parent 99a4184224
commit c75741c578
11 changed files with 47 additions and 60 deletions

View File

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

View File

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

View File

@ -75,7 +75,7 @@ function layout.inc(i, s, layouts)
layouts, i, s = i, s, layouts layouts, i, s = i, s, layouts
end end
local t = tag.selected(s) local t = tag.selected(s)
local layouts = layouts or layout.layouts layouts = layouts or layout.layouts
if t then if t then
local curlayout = layout.get(s) local curlayout = layout.get(s)
local curindex local curindex
@ -192,7 +192,7 @@ end
-- @param _layout The layout. -- @param _layout The layout.
-- @return The layout name. -- @return The layout name.
function layout.getname(_layout) function layout.getname(_layout)
local _layout = _layout or layout.get() _layout = _layout or layout.get()
return _layout.name return _layout.name
end end

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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