Merge branch 'more-luacheck-fixes' of https://github.com/psychon/awesome
This commit is contained in:
commit
99ef5822b0
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
local select = select
|
local select = select
|
||||||
local setmetatable = setmetatable
|
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 = {}
|
local cache = {}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local string = string
|
local string = string
|
||||||
local table = table
|
local table = table
|
||||||
local unpack = unpack or table.unpack -- v5.1: unpack, v5.2: table.unpack
|
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local ipairs = ipairs
|
local ipairs = ipairs
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
@ -88,7 +88,6 @@ end
|
||||||
-- @param col The color for the pattern
|
-- @param col The color for the pattern
|
||||||
-- @return A cairo pattern object
|
-- @return A cairo pattern object
|
||||||
function color.create_solid_pattern(col)
|
function color.create_solid_pattern(col)
|
||||||
local col = col
|
|
||||||
if col == nil then
|
if col == nil then
|
||||||
col = "#000000"
|
col = "#000000"
|
||||||
elseif type(col) == "table" then
|
elseif type(col) == "table" then
|
||||||
|
@ -102,7 +101,6 @@ end
|
||||||
-- @param file The filename of the file
|
-- @param file The filename of the file
|
||||||
-- @return a cairo pattern object
|
-- @return a cairo pattern object
|
||||||
function color.create_png_pattern(file)
|
function color.create_png_pattern(file)
|
||||||
local file = file
|
|
||||||
if type(file) == "table" then
|
if type(file) == "table" then
|
||||||
file = file.file
|
file = file.file
|
||||||
end
|
end
|
||||||
|
@ -138,7 +136,7 @@ local function string_pattern(creator, arg)
|
||||||
local args = { parse_numbers(iterator()) }
|
local args = { parse_numbers(iterator()) }
|
||||||
local to = { parse_numbers(iterator()) }
|
local to = { parse_numbers(iterator()) }
|
||||||
-- Now merge those two tables
|
-- Now merge those two tables
|
||||||
for k, v in pairs(to) do
|
for _, v in pairs(to) do
|
||||||
table.insert(args, v)
|
table.insert(args, v)
|
||||||
end
|
end
|
||||||
-- And call our creator function with the values
|
-- 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
|
if cairo.Pattern:is_type_of(col) then
|
||||||
return col
|
return col
|
||||||
end
|
end
|
||||||
local col = col or "#000000"
|
col = col or "#000000"
|
||||||
if type(col) == "string" then
|
if type(col) == "string" then
|
||||||
local t = string.match(col, "[^:]+")
|
local t = string.match(col, "[^:]+")
|
||||||
if color.types[t] then
|
if color.types[t] then
|
||||||
|
@ -271,18 +269,17 @@ end
|
||||||
-- @return The pattern if it is surely opaque, else nil
|
-- @return The pattern if it is surely opaque, else nil
|
||||||
function color.create_opaque_pattern(col)
|
function color.create_opaque_pattern(col)
|
||||||
local pattern = color.create_pattern(col)
|
local pattern = color.create_pattern(col)
|
||||||
local type = pattern:get_type()
|
local kind = pattern:get_type()
|
||||||
local extend = pattern:get_extend()
|
|
||||||
|
|
||||||
if type == "SOLID" then
|
if kind == "SOLID" then
|
||||||
local status, r, g, b, a = pattern:get_rgba()
|
local _, _, _, _, alpha = pattern:get_rgba()
|
||||||
if a ~= 1 then
|
if alpha ~= 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
return pattern
|
return pattern
|
||||||
elseif type == "SURFACE" then
|
elseif kind == "SURFACE" then
|
||||||
local status, surface = pattern:get_surface()
|
local status, surf = pattern:get_surface()
|
||||||
if status ~= "SUCCESS" or surface.content ~= "COLOR" then
|
if status ~= "SUCCESS" or surf.content ~= "COLOR" then
|
||||||
-- The surface has an alpha channel which *might* be non-opaque
|
-- The surface has an alpha channel which *might* be non-opaque
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -294,8 +291,8 @@ function color.create_opaque_pattern(col)
|
||||||
end
|
end
|
||||||
|
|
||||||
return pattern
|
return pattern
|
||||||
elseif type == "LINEAR" then
|
elseif kind == "LINEAR" then
|
||||||
local status, stops = pattern:get_color_stop_count()
|
local _, stops = pattern:get_color_stop_count()
|
||||||
|
|
||||||
-- No color stops or extend NONE -> pattern *might* contain transparency
|
-- No color stops or extend NONE -> pattern *might* contain transparency
|
||||||
if stops == 0 or pattern:get_extend() == "NONE" then
|
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
|
-- Now check if any of the color stops contain transparency
|
||||||
for i = 0, stops - 1 do
|
for i = 0, stops - 1 do
|
||||||
local status, offset, r, g, b, a = pattern:get_color_stop_rgba(i)
|
local _, _, _, _, _, alpha = pattern:get_color_stop_rgba(i)
|
||||||
if a ~= 1 then
|
if alpha ~= 1 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -330,7 +327,7 @@ function color.recolor_image(image, new_color)
|
||||||
return image
|
return image
|
||||||
end
|
end
|
||||||
|
|
||||||
function color.mt:__call(...)
|
function color.mt.__call(_, ...)
|
||||||
return color.create_pattern(...)
|
return color.create_pattern(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,7 @@
|
||||||
-- @module gears.debug
|
-- @module gears.debug
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local error = error
|
|
||||||
local tostring = tostring
|
local tostring = tostring
|
||||||
local traceback = debug.traceback
|
|
||||||
local print = print
|
local print = print
|
||||||
local type = type
|
local type = type
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
|
|
|
@ -175,7 +175,7 @@ end
|
||||||
-- @treturn number The x coordinate of the transformed point.
|
-- @treturn number The x coordinate of the transformed point.
|
||||||
-- @treturn number The x coordinate of the transformed point.
|
-- @treturn number The x coordinate of the transformed point.
|
||||||
function matrix:transform_point(x, y)
|
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
|
return self.x0 + x, self.y0 + y
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -195,10 +195,10 @@ function matrix:transform_rectangle(x, y, width, height)
|
||||||
local x3, y3 = self:transform_point(x + width, y + height)
|
local x3, y3 = self:transform_point(x + width, y + height)
|
||||||
local x4, y4 = self:transform_point(x + width, y)
|
local x4, y4 = self:transform_point(x + width, y)
|
||||||
-- Find the extremal points of the result
|
-- Find the extremal points of the result
|
||||||
local x = math.min(x1, x2, x3, x4)
|
x = math.min(x1, x2, x3, x4)
|
||||||
local y = math.min(y1, y2, y3, y4)
|
y = math.min(y1, y2, y3, y4)
|
||||||
local width = math.max(x1, x2, x3, x4) - x
|
width = math.max(x1, x2, x3, x4) - x
|
||||||
local height = math.max(y1, y2, y3, y4) - y
|
height = math.max(y1, y2, y3, y4) - y
|
||||||
|
|
||||||
return x, y, width, height
|
return x, y, width, height
|
||||||
end
|
end
|
||||||
|
|
|
@ -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
|
-- 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.
|
-- value in a weak table. Thus, do some magic so that we get a userdata.
|
||||||
|
|
||||||
|
-- luacheck: globals newproxy getfenv setfenv
|
||||||
local userdata = newproxy(true)
|
local userdata = newproxy(true)
|
||||||
getmetatable(userdata).__gc = function() end
|
getmetatable(userdata).__gc = function() end
|
||||||
-- Now bind the lifetime of userdata to the lifetime of func. For this,
|
-- Now bind the lifetime of userdata to the lifetime of func. For this,
|
||||||
|
@ -137,7 +138,7 @@ local function new()
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function object.mt:__call(...)
|
function object.mt.__call(_, ...)
|
||||||
return new(...)
|
return new(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -64,9 +64,9 @@ end
|
||||||
-- @tparam[opt=10] number arrow_size The width and height of the arrow
|
-- @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
|
-- @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)
|
function module.infobubble(cr, width, height, corner_radius, arrow_size, arrow_position)
|
||||||
local corner_radius = corner_radius or 5
|
corner_radius = corner_radius or 5
|
||||||
local arrow_size = arrow_size or 10
|
arrow_size = arrow_size or 10
|
||||||
local arrow_position = arrow_position or width/2 - arrow_size/2
|
arrow_position = arrow_position or width/2 - arrow_size/2
|
||||||
|
|
||||||
cr:move_to(0 ,corner_radius)
|
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=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)
|
-- @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)
|
function module.arrow(cr, width, height, head_width, shaft_width, shaft_length)
|
||||||
local shaft_length = shaft_length or height / 2
|
shaft_length = shaft_length or height / 2
|
||||||
local shaft_width = shaft_width or width / 2
|
shaft_width = shaft_width or width / 2
|
||||||
local head_width = head_width or width
|
head_width = head_width or width
|
||||||
local head_length = height - shaft_length
|
local head_length = height - shaft_length
|
||||||
|
|
||||||
cr:move_to ( width/2 , 0 )
|
cr:move_to ( width/2 , 0 )
|
||||||
|
@ -146,7 +146,7 @@ end
|
||||||
-- @tparam number height The shape height
|
-- @tparam number height The shape height
|
||||||
-- @tparam[opt=height/2] number arrow_depth The width of the arrow part of the shape
|
-- @tparam[opt=height/2] number arrow_depth The width of the arrow part of the shape
|
||||||
function module.powerline(cr, width, height, arrow_depth)
|
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:move_to(0 , 0 )
|
||||||
cr:line_to(width - arrow_depth , 0 )
|
cr:line_to(width - arrow_depth , 0 )
|
||||||
cr:line_to(width , height/2 )
|
cr:line_to(width , height/2 )
|
||||||
|
|
|
@ -114,7 +114,7 @@ function surface.load(_surface)
|
||||||
return do_load_and_handle_errors(_surface, surface.load_silently)
|
return do_load_and_handle_errors(_surface, surface.load_silently)
|
||||||
end
|
end
|
||||||
|
|
||||||
function surface.mt:__call(...)
|
function surface.mt.__call(_, ...)
|
||||||
return surface.load(...)
|
return surface.load(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@ local setmetatable = setmetatable
|
||||||
local table = table
|
local table = table
|
||||||
local tonumber = tonumber
|
local tonumber = tonumber
|
||||||
local traceback = debug.traceback
|
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 glib = require("lgi").GLib
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ function timer:start()
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
self.data.source_id = glib.timeout_add(glib.PRIORITY_DEFAULT, self.data.timeout * 1000, function()
|
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")
|
self:emit_signal("timeout")
|
||||||
end, function(err)
|
end, function(err)
|
||||||
print(debug.traceback("Error during executing timeout handler: "..tostring(err)))
|
print(debug.traceback("Error during executing timeout handler: "..tostring(err)))
|
||||||
|
@ -160,7 +160,7 @@ end
|
||||||
local delayed_calls = {}
|
local delayed_calls = {}
|
||||||
capi.awesome.connect_signal("refresh", function()
|
capi.awesome.connect_signal("refresh", function()
|
||||||
for _, callback in ipairs(delayed_calls) do
|
for _, callback in ipairs(delayed_calls) do
|
||||||
local success, message = xpcall(function()
|
xpcall(function()
|
||||||
callback[1](unpack(callback, 2))
|
callback[1](unpack(callback, 2))
|
||||||
end, function(err)
|
end, function(err)
|
||||||
print(debug.traceback("Error during delayed call: "..tostring(err), 2))
|
print(debug.traceback("Error during delayed call: "..tostring(err), 2))
|
||||||
|
@ -177,7 +177,7 @@ function timer.delayed_call(callback, ...)
|
||||||
table.insert(delayed_calls, { callback, ... })
|
table.insert(delayed_calls, { callback, ... })
|
||||||
end
|
end
|
||||||
|
|
||||||
function timer.mt:__call(...)
|
function timer.mt.__call(_, ...)
|
||||||
return timer.new(...)
|
return timer.new(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -58,9 +58,9 @@ function wallpaper.prepare_context(s)
|
||||||
|
|
||||||
-- Set the wallpaper (delayed)
|
-- Set the wallpaper (delayed)
|
||||||
timer.delayed_call(function()
|
timer.delayed_call(function()
|
||||||
local wp = pending_wallpaper
|
local paper = pending_wallpaper
|
||||||
pending_wallpaper = nil
|
pending_wallpaper = nil
|
||||||
wallpaper.set(wp)
|
wallpaper.set(paper)
|
||||||
end)
|
end)
|
||||||
else
|
else
|
||||||
-- Draw to the already-pending wallpaper
|
-- Draw to the already-pending wallpaper
|
||||||
|
@ -99,8 +99,8 @@ end
|
||||||
-- gears.color. The default is black.
|
-- gears.color. The default is black.
|
||||||
function wallpaper.centered(surf, s, background)
|
function wallpaper.centered(surf, s, background)
|
||||||
local geom, cr = wallpaper.prepare_context(s)
|
local geom, cr = wallpaper.prepare_context(s)
|
||||||
local surf = surface(surf)
|
surf = surface(surf)
|
||||||
local background = color(background)
|
background = color(background)
|
||||||
|
|
||||||
-- Fill the area with the background
|
-- Fill the area with the background
|
||||||
cr.operator = cairo.Operator.SOURCE
|
cr.operator = cairo.Operator.SOURCE
|
||||||
|
@ -122,7 +122,7 @@ end
|
||||||
-- all screens are set.
|
-- all screens are set.
|
||||||
-- @param offset This can be set to a table with entries x and y.
|
-- @param offset This can be set to a table with entries x and y.
|
||||||
function wallpaper.tiled(surf, s, offset)
|
function wallpaper.tiled(surf, s, offset)
|
||||||
local geom, cr = wallpaper.prepare_context(s)
|
local _, cr = wallpaper.prepare_context(s)
|
||||||
|
|
||||||
if offset then
|
if offset then
|
||||||
cr:translate(offset.x, offset.y)
|
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.
|
-- @param offset This can be set to a table with entries x and y.
|
||||||
function wallpaper.maximized(surf, s, ignore_aspect, offset)
|
function wallpaper.maximized(surf, s, ignore_aspect, offset)
|
||||||
local geom, cr = wallpaper.prepare_context(s)
|
local geom, cr = wallpaper.prepare_context(s)
|
||||||
local surf = surface(surf)
|
surf = surface(surf)
|
||||||
local w, h = surface.get_size(surf)
|
local w, h = surface.get_size(surf)
|
||||||
local aspect_w = geom.width / w
|
local aspect_w = geom.width / w
|
||||||
local aspect_h = geom.height / h
|
local aspect_h = geom.height / h
|
||||||
|
@ -176,8 +176,8 @@ end
|
||||||
-- gears.color. The default is black.
|
-- gears.color. The default is black.
|
||||||
function wallpaper.fit(surf, s, background)
|
function wallpaper.fit(surf, s, background)
|
||||||
local geom, cr = wallpaper.prepare_context(s)
|
local geom, cr = wallpaper.prepare_context(s)
|
||||||
local surf = surface(surf)
|
surf = surface(surf)
|
||||||
local background = color(background)
|
background = color(background)
|
||||||
|
|
||||||
-- Fill the area with the background
|
-- Fill the area with the background
|
||||||
cr.operator = cairo.Operator.SOURCE
|
cr.operator = cairo.Operator.SOURCE
|
||||||
|
|
|
@ -12,7 +12,6 @@ local pairs = pairs
|
||||||
local table = table
|
local table = table
|
||||||
local type = type
|
local type = type
|
||||||
local string = string
|
local string = string
|
||||||
local tostring = tostring
|
|
||||||
local pcall = pcall
|
local pcall = pcall
|
||||||
local capi = { screen = screen,
|
local capi = { screen = screen,
|
||||||
awesome = awesome }
|
awesome = awesome }
|
||||||
|
@ -26,11 +25,6 @@ local surface = require("gears.surface")
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
local dpi = require("beautiful").xresources.apply_dpi
|
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 = {}
|
local naughty = {}
|
||||||
|
|
||||||
--[[--
|
--[[--
|
||||||
|
@ -169,7 +163,7 @@ end
|
||||||
--- Resume notifications
|
--- Resume notifications
|
||||||
function naughty.resume()
|
function naughty.resume()
|
||||||
suspended = false
|
suspended = false
|
||||||
for i, v in pairs(naughty.notifications.suspended) do
|
for _, v in pairs(naughty.notifications.suspended) do
|
||||||
v.box.visible = true
|
v.box.visible = true
|
||||||
if v.timer then v.timer:start() end
|
if v.timer then v.timer:start() end
|
||||||
end
|
end
|
||||||
|
@ -187,18 +181,18 @@ end
|
||||||
|
|
||||||
--- Evaluate desired position of the notification by index - internal
|
--- 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
|
-- @param position top_right | top_left | bottom_right | bottom_left
|
||||||
-- | top_middle | bottom_middle
|
-- | top_middle | bottom_middle
|
||||||
-- @param idx Index of the notification
|
-- @param idx Index of the notification
|
||||||
-- @param[opt] width Popup width.
|
-- @param[opt] width Popup width.
|
||||||
-- @param height Popup height
|
-- @param height Popup height
|
||||||
-- @return Absolute position and index in { x = X, y = Y, idx = I } table
|
-- @return Absolute position and index in { x = X, y = Y, idx = I } table
|
||||||
local function get_offset(screen, position, idx, width, height)
|
local function get_offset(s, position, idx, width, height)
|
||||||
local ws = capi.screen[screen].workarea
|
local ws = capi.screen[s].workarea
|
||||||
local v = {}
|
local v = {}
|
||||||
local idx = idx or #naughty.notifications[screen][position] + 1
|
idx = idx or #naughty.notifications[s][position] + 1
|
||||||
local width = width or naughty.notifications[screen][position][idx].width
|
width = width or naughty.notifications[s][position][idx].width
|
||||||
|
|
||||||
-- calculate x
|
-- calculate x
|
||||||
if position:match("left") then
|
if position:match("left") then
|
||||||
|
@ -212,7 +206,7 @@ local function get_offset(screen, position, idx, width, height)
|
||||||
-- calculate existing popups' height
|
-- calculate existing popups' height
|
||||||
local existing = 0
|
local existing = 0
|
||||||
for i = 1, idx-1, 1 do
|
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
|
end
|
||||||
|
|
||||||
-- calculate y
|
-- calculate y
|
||||||
|
@ -227,20 +221,20 @@ local function get_offset(screen, position, idx, width, height)
|
||||||
-- e.g. critical ones.
|
-- e.g. critical ones.
|
||||||
local find_old_to_replace = function()
|
local find_old_to_replace = function()
|
||||||
for i = 1, idx-1 do
|
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
|
if n.timeout > 0 then
|
||||||
return n
|
return n
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- Fallback to first one.
|
-- Fallback to first one.
|
||||||
return naughty.notifications[screen][position][1]
|
return naughty.notifications[s][position][1]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- if positioned outside workarea, destroy oldest popup and recalculate
|
-- if positioned outside workarea, destroy oldest popup and recalculate
|
||||||
if v.y + height > ws.y + ws.height or v.y < ws.y then
|
if v.y + height > ws.y + ws.height or v.y < ws.y then
|
||||||
naughty.destroy(find_old_to_replace())
|
naughty.destroy(find_old_to_replace())
|
||||||
idx = idx - 1
|
idx = idx - 1
|
||||||
v = get_offset(screen, position, idx, width, height)
|
v = get_offset(s, position, idx, width, height)
|
||||||
end
|
end
|
||||||
if not v.idx then v.idx = idx 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
|
--- Re-arrange notifications according to their position and index - internal
|
||||||
--
|
--
|
||||||
-- @return None
|
-- @return None
|
||||||
local function arrange(screen)
|
local function arrange(s)
|
||||||
for p,pos in pairs(naughty.notifications[screen]) do
|
for p in pairs(naughty.notifications[s]) do
|
||||||
for i,notification in pairs(naughty.notifications[screen][p]) do
|
for i,notification in pairs(naughty.notifications[s][p]) do
|
||||||
local offset = get_offset(screen, p, i, notification.width, notification.height)
|
local offset = get_offset(s, p, i, notification.width, notification.height)
|
||||||
notification.box:geometry({ x = offset.x, y = offset.y })
|
notification.box:geometry({ x = offset.x, y = offset.y })
|
||||||
notification.idx = offset.idx
|
notification.idx = offset.idx
|
||||||
end
|
end
|
||||||
|
@ -296,8 +290,8 @@ end
|
||||||
function naughty.getById(id)
|
function naughty.getById(id)
|
||||||
-- iterate the notifications to get the notfications with the correct ID
|
-- iterate the notifications to get the notfications with the correct ID
|
||||||
for s = 1, capi.screen.count() do
|
for s = 1, capi.screen.count() do
|
||||||
for p,pos in pairs(naughty.notifications[s]) do
|
for p in pairs(naughty.notifications[s]) do
|
||||||
for i,notification in pairs(naughty.notifications[s][p]) do
|
for _, notification in pairs(naughty.notifications[s][p]) do
|
||||||
if notification.id == id then
|
if notification.id == id then
|
||||||
return notification
|
return notification
|
||||||
end
|
end
|
||||||
|
@ -437,7 +431,7 @@ function naughty.notify(args)
|
||||||
local icon_size = args.icon_size or preset.icon_size
|
local icon_size = args.icon_size or preset.icon_size
|
||||||
local text = args.text or preset.text
|
local text = args.text or preset.text
|
||||||
local title = args.title or preset.title
|
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 ontop = args.ontop or preset.ontop
|
||||||
local width = args.width or preset.width
|
local width = args.width or preset.width
|
||||||
local height = args.height or preset.height
|
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 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 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 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
|
-- replace notification if needed
|
||||||
if args.replaces_id then
|
if args.replaces_id then
|
||||||
|
@ -530,8 +524,8 @@ function naughty.notify(args)
|
||||||
actiontextbox:set_markup(string.format('<b>%s</b>', action))
|
actiontextbox:set_markup(string.format('<b>%s</b>', action))
|
||||||
-- calculate the height and width
|
-- calculate the height and width
|
||||||
local w, h = actiontextbox:get_preferred_size(s)
|
local w, h = actiontextbox:get_preferred_size(s)
|
||||||
local height = h + 2 * margin
|
local action_height = h + 2 * margin
|
||||||
local width = w + 2 * margin
|
local action_width = w + 2 * margin
|
||||||
|
|
||||||
actionmarginbox:buttons(util.table.join(
|
actionmarginbox:buttons(util.table.join(
|
||||||
button({ }, 1, callback),
|
button({ }, 1, callback),
|
||||||
|
@ -539,9 +533,9 @@ function naughty.notify(args)
|
||||||
))
|
))
|
||||||
actionslayout:add(actionmarginbox)
|
actionslayout:add(actionmarginbox)
|
||||||
|
|
||||||
actions_total_height = actions_total_height + height
|
actions_total_height = actions_total_height + action_height
|
||||||
if actions_max_width < width then
|
if actions_max_width < action_width then
|
||||||
actions_max_width = width
|
actions_max_width = action_width
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -561,7 +555,7 @@ function naughty.notify(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- is the icon file readable?
|
-- is the icon file readable?
|
||||||
local icon = surface.load_uncached(icon)
|
icon = surface.load_uncached(icon)
|
||||||
|
|
||||||
-- if we have an icon, use it
|
-- if we have an icon, use it
|
||||||
if icon then
|
if icon then
|
||||||
|
@ -593,7 +587,7 @@ function naughty.notify(args)
|
||||||
|
|
||||||
-- calculate the width
|
-- calculate the width
|
||||||
if not width then
|
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
|
width = w + (iconbox and icon_w + 2 * margin or 0) + 2 * margin
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -615,7 +609,7 @@ function naughty.notify(args)
|
||||||
height = height + actions_total_height
|
height = height + actions_total_height
|
||||||
|
|
||||||
-- crop to workarea size if too big
|
-- 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
|
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)
|
width = workarea.width - 2 * (border_width or 0) - 2 * (naughty.config.padding or 0)
|
||||||
end
|
end
|
||||||
|
@ -628,7 +622,7 @@ function naughty.notify(args)
|
||||||
notification.width = width + 2 * (border_width or 0)
|
notification.width = width + 2 * (border_width or 0)
|
||||||
|
|
||||||
-- position the wibox
|
-- 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.ontop = ontop
|
||||||
notification.box:geometry({ width = width,
|
notification.box:geometry({ width = width,
|
||||||
height = height,
|
height = height,
|
||||||
|
@ -657,7 +651,7 @@ function naughty.notify(args)
|
||||||
end)))
|
end)))
|
||||||
|
|
||||||
-- insert the notification to the table
|
-- 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
|
if suspended then
|
||||||
notification.box.visible = false
|
notification.box.visible = false
|
||||||
|
|
|
@ -23,7 +23,7 @@ local schar = string.char
|
||||||
local sbyte = string.byte
|
local sbyte = string.byte
|
||||||
local tcat = table.concat
|
local tcat = table.concat
|
||||||
local tins = table.insert
|
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")
|
local naughty = require("naughty.core")
|
||||||
|
|
||||||
--- Notification library, dbus bindings
|
--- Notification library, dbus bindings
|
||||||
|
@ -88,7 +88,7 @@ local function convert_icon(w, h, rowstride, channels, data)
|
||||||
-- Now convert each row on its own
|
-- Now convert each row on its own
|
||||||
local rows = {}
|
local rows = {}
|
||||||
|
|
||||||
for y = 1, h do
|
for _ = 1, h do
|
||||||
local this_row = {}
|
local this_row = {}
|
||||||
|
|
||||||
for i = 1 + offset, w * channels + offset, channels do
|
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
|
if appname ~= "" then
|
||||||
args.appname = appname
|
args.appname = appname
|
||||||
end
|
end
|
||||||
for i, obj in pairs(dbus.config.mapping) do
|
for _, obj in pairs(dbus.config.mapping) do
|
||||||
local filter, preset, s = obj[1], obj[2], 0
|
local filter, preset = obj[1], obj[2]
|
||||||
if (not filter.urgency or filter.urgency == hints.urgency) and
|
if (not filter.urgency or filter.urgency == hints.urgency) and
|
||||||
(not filter.category or filter.category == hints.category) and
|
(not filter.category or filter.category == hints.category) and
|
||||||
(not filter.appname or filter.appname == appname) then
|
(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
|
-- 5 -> bits per sample
|
||||||
-- 6 -> channels
|
-- 6 -> channels
|
||||||
-- 7 -> data
|
-- 7 -> data
|
||||||
local w, h, rowstride, _, _, channels, data = unpack(hints.icon_data)
|
local w, h, rowstride, _, _, channels, icon_data = unpack(hints.icon_data)
|
||||||
args.icon = convert_icon(w, h, rowstride, channels, data)
|
args.icon = convert_icon(w, h, rowstride, channels, icon_data)
|
||||||
end
|
end
|
||||||
if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then
|
if replaces_id and replaces_id ~= "" and replaces_id ~= 0 then
|
||||||
args.replaces_id = replaces_id
|
args.replaces_id = replaces_id
|
||||||
|
@ -204,7 +204,7 @@ capi.dbus.connect_signal("org.freedesktop.Notifications", function (data, appnam
|
||||||
end
|
end
|
||||||
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
|
if data.member == "Introspect" then
|
||||||
local xml = [=[<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object
|
local xml = [=[<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object
|
||||||
Introspection 1.0//EN"
|
Introspection 1.0//EN"
|
||||||
|
|
|
@ -20,8 +20,7 @@ local surface = require("gears.surface")
|
||||||
local timer = require("gears.timer")
|
local timer = require("gears.timer")
|
||||||
local matrix = require("gears.matrix")
|
local matrix = require("gears.matrix")
|
||||||
local hierarchy = require("wibox.hierarchy")
|
local hierarchy = require("wibox.hierarchy")
|
||||||
local base = require("wibox.widget.base")
|
local unpack = unpack or table.unpack -- luacheck: globals unpack (compatibility with Lua 5.1)
|
||||||
local unpack = unpack or table.unpack
|
|
||||||
|
|
||||||
local drawables = setmetatable({}, { __mode = 'k' })
|
local drawables = setmetatable({}, { __mode = 'k' })
|
||||||
local wallpaper = nil
|
local wallpaper = nil
|
||||||
|
@ -154,32 +153,32 @@ local function do_redraw(self)
|
||||||
assert(cr.status == "SUCCESS", "Cairo context entered error state: " .. cr.status)
|
assert(cr.status == "SUCCESS", "Cairo context entered error state: " .. cr.status)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function find_widgets(drawable, result, hierarchy, x, y)
|
local function find_widgets(_drawable, result, _hierarchy, x, y)
|
||||||
local m = hierarchy:get_matrix_from_device()
|
local m = _hierarchy:get_matrix_from_device()
|
||||||
|
|
||||||
-- Is (x,y) inside of this hierarchy or any child (aka the draw extents)
|
-- Is (x,y) inside of this hierarchy or any child (aka the draw extents)
|
||||||
local x1, y1 = m:transform_point(x, y)
|
local x1, y1 = m:transform_point(x, y)
|
||||||
local x2, y2, width, height = hierarchy:get_draw_extents()
|
local x2, y2, w2, h2 = _hierarchy:get_draw_extents()
|
||||||
if x1 < x2 or x1 >= x2 + width then
|
if x1 < x2 or x1 >= x2 + w2 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
if y1 < y2 or y1 >= y2 + height then
|
if y1 < y2 or y1 >= y2 + h2 then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Is (x,y) inside of this widget?
|
-- 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
|
if x1 >= 0 and y1 >= 0 and x1 <= width and y1 <= height then
|
||||||
-- Get the extents of this widget in the device space
|
-- 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)
|
0, 0, width, height)
|
||||||
table.insert(result, {
|
table.insert(result, {
|
||||||
x = x2, y = y2, width = w2, height = h2,
|
x = x3, y = y3, width = w3, height = h3,
|
||||||
drawable = drawable, widget = hierarchy:get_widget()
|
drawable = _drawable, widget = _hierarchy:get_widget()
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
for _, child in ipairs(hierarchy:get_children()) do
|
for _, child in ipairs(_hierarchy:get_children()) do
|
||||||
find_widgets(drawable, result, child, x, y)
|
find_widgets(_drawable, result, child, x, y)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -211,7 +210,7 @@ end
|
||||||
-- @param c The background to use. This must either be a cairo pattern object,
|
-- @param c The background to use. This must either be a cairo pattern object,
|
||||||
-- nil or a string that gears.color() understands.
|
-- nil or a string that gears.color() understands.
|
||||||
function drawable:set_bg(c)
|
function drawable:set_bg(c)
|
||||||
local c = c or "#000000"
|
c = c or "#000000"
|
||||||
local t = type(c)
|
local t = type(c)
|
||||||
|
|
||||||
if t == "string" or t == "table" then
|
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,
|
-- @param c The foreground to use. This must either be a cairo pattern object,
|
||||||
-- nil or a string that gears.color() understands.
|
-- nil or a string that gears.color() understands.
|
||||||
function drawable:set_fg(c)
|
function drawable:set_fg(c)
|
||||||
local c = c or "#FFFFFF"
|
c = c or "#FFFFFF"
|
||||||
if type(c) == "string" or type(c) == "table" then
|
if type(c) == "string" or type(c) == "table" then
|
||||||
c = color(c)
|
c = color(c)
|
||||||
end
|
end
|
||||||
|
@ -265,7 +264,7 @@ end
|
||||||
|
|
||||||
local function emit_difference(name, list, skip)
|
local function emit_difference(name, list, skip)
|
||||||
local function in_table(table, val)
|
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
|
if v.widget == val.widget then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
@ -273,7 +272,7 @@ local function emit_difference(name, list, skip)
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(list) do
|
for _, v in pairs(list) do
|
||||||
if not in_table(skip, v) then
|
if not in_table(skip, v) then
|
||||||
v.widget:emit_signal(name,v)
|
v.widget:emit_signal(name,v)
|
||||||
end
|
end
|
||||||
|
@ -371,9 +370,9 @@ function drawable.new(d, widget_context_skeleton, drawable_name)
|
||||||
ret._widgets_under_mouse = {}
|
ret._widgets_under_mouse = {}
|
||||||
|
|
||||||
local function button_signal(name)
|
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)
|
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
|
-- Calculate x/y inside of the widget
|
||||||
local lx = x - v.x
|
local lx = x - v.x
|
||||||
local ly = y - v.y
|
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)
|
d:connect_signal("mouse::leave", function() handle_leave(ret) end)
|
||||||
|
|
||||||
-- Set up our callbacks for repaints
|
-- 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
|
if ret._widget_hierarchy_callback_arg ~= arg then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
local m = hierarchy:get_matrix_to_device()
|
local m = hierar:get_matrix_to_device()
|
||||||
local x, y, width, height = matrix.transform_rectangle(m, hierarchy:get_draw_extents())
|
local x, y, width, height = matrix.transform_rectangle(m, hierar:get_draw_extents())
|
||||||
local x1, y1 = math.floor(x), math.floor(y)
|
local x1, y1 = math.floor(x), math.floor(y)
|
||||||
local x2, y2 = math.ceil(x + width), math.ceil(y + height)
|
local x2, y2 = math.ceil(x + width), math.ceil(y + height)
|
||||||
ret._dirty_area:union_rectangle(cairo.RectangleInt{
|
ret._dirty_area:union_rectangle(cairo.RectangleInt{
|
||||||
|
@ -401,7 +400,7 @@ function drawable.new(d, widget_context_skeleton, drawable_name)
|
||||||
})
|
})
|
||||||
ret:draw()
|
ret:draw()
|
||||||
end
|
end
|
||||||
ret._layout_callback = function(hierarchy, arg)
|
ret._layout_callback = function(_, arg)
|
||||||
if ret._widget_hierarchy_callback_arg ~= arg then
|
if ret._widget_hierarchy_callback_arg ~= arg then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
@ -413,7 +412,7 @@ function drawable.new(d, widget_context_skeleton, drawable_name)
|
||||||
ret.drawable_name = drawable_name or object.modulename(3)
|
ret.drawable_name = drawable_name or object.modulename(3)
|
||||||
local mt = {}
|
local mt = {}
|
||||||
local orig_string = tostring(ret)
|
local orig_string = tostring(ret)
|
||||||
mt.__tostring = function(o)
|
mt.__tostring = function()
|
||||||
return string.format("%s (%s)", ret.drawable_name, orig_string)
|
return string.format("%s (%s)", ret.drawable_name, orig_string)
|
||||||
end
|
end
|
||||||
ret = setmetatable(ret, mt)
|
ret = setmetatable(ret, mt)
|
||||||
|
@ -426,7 +425,6 @@ end
|
||||||
|
|
||||||
-- Redraw all drawables when the wallpaper changes
|
-- Redraw all drawables when the wallpaper changes
|
||||||
capi.awesome.connect_signal("wallpaper_changed", function()
|
capi.awesome.connect_signal("wallpaper_changed", function()
|
||||||
local k
|
|
||||||
wallpaper = nil
|
wallpaper = nil
|
||||||
for k in pairs(drawables) do
|
for k in pairs(drawables) do
|
||||||
k()
|
k()
|
||||||
|
|
|
@ -16,7 +16,7 @@ local no_parent = base.no_parent_I_know_what_I_am_doing
|
||||||
|
|
||||||
local hierarchy = {}
|
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 = {
|
local result = {
|
||||||
_matrix = matrix.identity,
|
_matrix = matrix.identity,
|
||||||
_matrix_to_device = 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
|
for _, w in ipairs(layout_result or {}) do
|
||||||
local r = table.remove(old_children, 1)
|
local r = table.remove(old_children, 1)
|
||||||
if not r then
|
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
|
r._parent = self
|
||||||
end
|
end
|
||||||
hierarchy_update(r, context, w._widget, w._width, w._height, region, w._matrix, matrix_to_device * w._matrix)
|
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
|
-- Check which part needs to be redrawn
|
||||||
|
|
||||||
-- Are there any children which were removed? Their area needs a redraw.
|
-- Are there any children which were removed? Their area needs a redraw.
|
||||||
for _, h in ipairs(old_children) do
|
for _, child in ipairs(old_children) do
|
||||||
local x, y, width, height = matrix.transform_rectangle(h._matrix_to_device, h:get_draw_extents())
|
local x, y, w, h = matrix.transform_rectangle(child._matrix_to_device, child:get_draw_extents())
|
||||||
region:union_rectangle(cairo.RectangleInt{
|
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
|
end
|
||||||
|
|
||||||
-- Did we change and need to be redrawn?
|
-- 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.
|
-- @param callback_arg A second argument that is given to the above callbacks.
|
||||||
-- @return A new widget hierarchy
|
-- @return A new widget hierarchy
|
||||||
function hierarchy.new(context, widget, width, height, redraw_callback, layout_callback, callback_arg)
|
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)
|
result:update(context, widget, width, height)
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
@ -181,7 +181,7 @@ end
|
||||||
-- @return A cairo region describing the changed parts (either the `region`
|
-- @return A cairo region describing the changed parts (either the `region`
|
||||||
-- argument or a new, internally created region).
|
-- argument or a new, internally created region).
|
||||||
function hierarchy:update(context, widget, width, height, 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)
|
hierarchy_update(self, context, widget, width, height, region, self._matrix, self._matrix_to_device)
|
||||||
return region
|
return region
|
||||||
end
|
end
|
||||||
|
@ -247,7 +247,7 @@ end
|
||||||
|
|
||||||
--- Does the given cairo context have an empty clip (aka "no drawing possible")?
|
--- Does the given cairo context have an empty clip (aka "no drawing possible")?
|
||||||
local function empty_clip(cr)
|
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
|
return width == 0 or height == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,13 +13,8 @@ local capi = {
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local type = type
|
local type = type
|
||||||
local table = table
|
|
||||||
local string_format = string.format
|
|
||||||
local color = require("gears.color")
|
|
||||||
local object = require("gears.object")
|
local object = require("gears.object")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local surface = require("gears.surface")
|
|
||||||
local cairo = require("lgi").cairo
|
|
||||||
local base = require("wibox.widget.base")
|
local base = require("wibox.widget.base")
|
||||||
|
|
||||||
--- This provides widget box windows. Every wibox can also be used as if it were
|
--- 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
|
end
|
||||||
|
|
||||||
local function setup_signals(_wibox)
|
local function setup_signals(_wibox)
|
||||||
local w = _wibox.drawin
|
local obj
|
||||||
|
|
||||||
local function clone_signal(name)
|
local function clone_signal(name)
|
||||||
_wibox:add_signal(name)
|
_wibox:add_signal(name)
|
||||||
-- When "name" is emitted on wibox.drawin, also emit it on wibox
|
-- 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, ...)
|
_wibox:emit_signal(name, ...)
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
obj = _wibox.drawin
|
||||||
clone_signal("property::border_color")
|
clone_signal("property::border_color")
|
||||||
clone_signal("property::border_width")
|
clone_signal("property::border_width")
|
||||||
clone_signal("property::buttons")
|
clone_signal("property::buttons")
|
||||||
|
@ -104,14 +100,7 @@ local function setup_signals(_wibox)
|
||||||
clone_signal("property::x")
|
clone_signal("property::x")
|
||||||
clone_signal("property::y")
|
clone_signal("property::y")
|
||||||
|
|
||||||
local d = _wibox._drawable
|
obj = _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
|
|
||||||
clone_signal("button::press")
|
clone_signal("button::press")
|
||||||
clone_signal("button::release")
|
clone_signal("button::release")
|
||||||
clone_signal("mouse::enter")
|
clone_signal("mouse::enter")
|
||||||
|
@ -146,7 +135,7 @@ local function new(args)
|
||||||
-- Add __tostring method to metatable.
|
-- Add __tostring method to metatable.
|
||||||
local mt = {}
|
local mt = {}
|
||||||
local orig_string = tostring(ret)
|
local orig_string = tostring(ret)
|
||||||
mt.__tostring = function(o)
|
mt.__tostring = function()
|
||||||
return string.format("wibox: %s (%s)",
|
return string.format("wibox: %s (%s)",
|
||||||
tostring(ret._drawable), orig_string)
|
tostring(ret._drawable), orig_string)
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
-- @classmod wibox.layout.align
|
-- @classmod wibox.layout.align
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local setmetatable = setmetatable
|
|
||||||
local table = table
|
local table = table
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local type = type
|
local type = type
|
||||||
|
@ -125,6 +124,7 @@ function align:layout(context, width, height)
|
||||||
x, y = size_first, 0
|
x, y = size_first, 0
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
|
local _
|
||||||
if self.dir == "y" then
|
if self.dir == "y" then
|
||||||
_, h = base.fit_widget(self, context, self.second, width, size_second)
|
_, h = base.fit_widget(self, context, self.second, width, size_second)
|
||||||
y = floor( (height - h)/2 )
|
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_dir = 0
|
||||||
local used_in_other = 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 w, h = base.fit_widget(self, context, v, orig_width, orig_height)
|
||||||
|
|
||||||
local max = self.dir == "y" and w or h
|
local max = self.dir == "y" and w or h
|
||||||
|
@ -233,7 +233,7 @@ function align:set_expand(mode)
|
||||||
end
|
end
|
||||||
|
|
||||||
function align:reset()
|
function align:reset()
|
||||||
for k, v in pairs({ "first", "second", "third" }) do
|
for _, v in pairs({ "first", "second", "third" }) do
|
||||||
self[v] = nil
|
self[v] = nil
|
||||||
end
|
end
|
||||||
self:emit_signal("widget::layout_changed")
|
self:emit_signal("widget::layout_changed")
|
||||||
|
|
|
@ -14,7 +14,7 @@ local math = math
|
||||||
local constraint = { mt = {} }
|
local constraint = { mt = {} }
|
||||||
|
|
||||||
--- Layout a constraint layout
|
--- Layout a constraint layout
|
||||||
function constraint:layout(context, width, height)
|
function constraint:layout(_, width, height)
|
||||||
if self.widget then
|
if self.widget then
|
||||||
return { base.place_widget_at(self.widget, 0, 0, width, height) }
|
return { base.place_widget_at(self.widget, 0, 0, width, height) }
|
||||||
end
|
end
|
||||||
|
@ -62,14 +62,14 @@ end
|
||||||
-- 'min' or 'exact'. Throws an error on invalid values.
|
-- 'min' or 'exact'. Throws an error on invalid values.
|
||||||
function constraint:set_strategy(val)
|
function constraint:set_strategy(val)
|
||||||
local func = {
|
local func = {
|
||||||
min = function(real_size, constraint)
|
min = function(real_size, limit)
|
||||||
return constraint and math.max(constraint, real_size) or real_size
|
return limit and math.max(limit, real_size) or real_size
|
||||||
end,
|
end,
|
||||||
max = function(real_size, constraint)
|
max = function(real_size, limit)
|
||||||
return constraint and math.min(constraint, real_size) or real_size
|
return limit and math.min(limit, real_size) or real_size
|
||||||
end,
|
end,
|
||||||
exact = function(real_size, constraint)
|
exact = function(real_size, limit)
|
||||||
return constraint or real_size
|
return limit or real_size
|
||||||
end
|
end
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,6 @@ function fixed:layout(context, width, height)
|
||||||
|
|
||||||
for k, v in pairs(self.widgets) do
|
for k, v in pairs(self.widgets) do
|
||||||
local x, y, w, h, _
|
local x, y, w, h, _
|
||||||
local in_dir
|
|
||||||
if self.dir == "y" then
|
if self.dir == "y" then
|
||||||
x, y = 0, pos
|
x, y = 0, pos
|
||||||
w, h = width, height - 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);
|
_, h = base.fit_widget(self, context, v, w, h);
|
||||||
end
|
end
|
||||||
pos = pos + h + spacing
|
pos = pos + h + spacing
|
||||||
in_dir = h
|
|
||||||
else
|
else
|
||||||
x, y = pos, 0
|
x, y = pos, 0
|
||||||
w, h = width - pos, height
|
w, h = width - pos, height
|
||||||
|
@ -38,7 +36,6 @@ function fixed:layout(context, width, height)
|
||||||
w, _ = base.fit_widget(self, context, v, w, h);
|
w, _ = base.fit_widget(self, context, v, w, h);
|
||||||
end
|
end
|
||||||
pos = pos + w + spacing
|
pos = pos + w + spacing
|
||||||
in_dir = w
|
|
||||||
end
|
end
|
||||||
|
|
||||||
if (self.dir == "y" and pos-spacing > height) or
|
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 width, height = orig_width, orig_height
|
||||||
local used_in_dir, used_max = 0, 0
|
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 w, h = base.fit_widget(self, context, v, width, height)
|
||||||
local in_dir, max
|
local in_dir, max
|
||||||
if self.dir == "y" then
|
if self.dir == "y" then
|
||||||
|
|
|
@ -107,11 +107,7 @@ local flex = {}
|
||||||
-- @name insert
|
-- @name insert
|
||||||
-- @class function
|
-- @class function
|
||||||
|
|
||||||
--- Layout a flex layout. Each widget gets an equal share of the available space.
|
function flex:layout(_, width, height)
|
||||||
-- @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)
|
|
||||||
local result = {}
|
local result = {}
|
||||||
local pos,spacing = 0, self._spacing
|
local pos,spacing = 0, self._spacing
|
||||||
local num = #self.widgets
|
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)
|
space_per_item = math.min(space_per_item, self._max_widget_size)
|
||||||
end
|
end
|
||||||
|
|
||||||
for k, v in pairs(self.widgets) do
|
for _, v in pairs(self.widgets) do
|
||||||
local x, y, w, h
|
local x, y, w, h
|
||||||
if self.dir == "y" then
|
if self.dir == "y" then
|
||||||
x, y = 0, util.round(pos)
|
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_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
|
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 w, h = base.fit_widget(self, context, v, sub_width, sub_height)
|
||||||
|
|
||||||
local max = self.dir == "y" and w or h
|
local max = self.dir == "y" and w or h
|
||||||
|
|
|
@ -15,7 +15,7 @@ local cairo = require("lgi").cairo
|
||||||
local margin = { mt = {} }
|
local margin = { mt = {} }
|
||||||
|
|
||||||
--- Draw a margin layout
|
--- Draw a margin layout
|
||||||
function margin:draw(context, cr, width, height)
|
function margin:draw(_, cr, width, height)
|
||||||
local x = self.left
|
local x = self.left
|
||||||
local y = self.top
|
local y = self.top
|
||||||
local w = self.right
|
local w = self.right
|
||||||
|
@ -36,7 +36,7 @@ function margin:draw(context, cr, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Layout a margin layout
|
--- Layout a margin layout
|
||||||
function margin:layout(context, width, height)
|
function margin:layout(_, width, height)
|
||||||
if self.widget then
|
if self.widget then
|
||||||
local x = self.left
|
local x = self.left
|
||||||
local y = self.top
|
local y = self.top
|
||||||
|
@ -141,7 +141,7 @@ end
|
||||||
-- @class function
|
-- @class function
|
||||||
|
|
||||||
-- Create setters for each direction
|
-- 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)
|
margin["set_" .. v] = function(layout, val)
|
||||||
layout[v] = val
|
layout[v] = val
|
||||||
layout:emit_signal("widget::layout_changed")
|
layout:emit_signal("widget::layout_changed")
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
|
|
||||||
local base = require("wibox.widget.base" )
|
local base = require("wibox.widget.base" )
|
||||||
local flex = require("wibox.layout.flex" )
|
local flex = require("wibox.layout.flex" )
|
||||||
local fixed = require("wibox.layout.fixed")
|
|
||||||
local table = table
|
local table = table
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local floor = math.floor
|
local floor = math.floor
|
||||||
|
@ -125,21 +124,12 @@ local function normalize(self)
|
||||||
assert(new_sum > 0.99 and new_sum < 1.01)
|
assert(new_sum > 0.99 and new_sum < 1.01)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Layout a ratio layout. Each widget gets a share of the size proportional
|
function ratio:layout(_, width, height)
|
||||||
-- 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)
|
|
||||||
local result = {}
|
local result = {}
|
||||||
local pos,spacing = 0, self._spacing
|
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
|
for k, v in ipairs(self.widgets) do
|
||||||
local space = nil
|
local space
|
||||||
local x, y, w, h
|
local x, y, w, h
|
||||||
|
|
||||||
if self.dir == "y" then
|
if self.dir == "y" then
|
||||||
|
@ -179,8 +169,6 @@ function ratio:inc_ratio(index, increment)
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local widget = self.widgets[index]
|
|
||||||
|
|
||||||
assert(self._ratios[index])
|
assert(self._ratios[index])
|
||||||
|
|
||||||
self:set_ratio(index, self._ratios[index] + increment)
|
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
|
-- Remove what has to be cleared from all widget
|
||||||
local delta = ( (percent-old) / (#self.widgets-1) )
|
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
|
self._ratios[k] = self._ratios[k] - delta
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ local function transform(layout, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Layout this layout
|
--- Layout this layout
|
||||||
function rotate:layout(context, width, height)
|
function rotate:layout(_, width, height)
|
||||||
if not self.widget or not self.widget.visible then
|
if not self.widget or not self.widget.visible then
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,14 +6,11 @@
|
||||||
---------------------------------------------------------------------------
|
---------------------------------------------------------------------------
|
||||||
|
|
||||||
local cache = require("gears.cache")
|
local cache = require("gears.cache")
|
||||||
local color = require("gears.color")
|
|
||||||
local matrix = require("gears.matrix")
|
|
||||||
local timer = require("gears.timer")
|
local timer = require("gears.timer")
|
||||||
local hierarchy = require("wibox.hierarchy")
|
local hierarchy = require("wibox.hierarchy")
|
||||||
local base = require("wibox.widget.base")
|
local base = require("wibox.widget.base")
|
||||||
local lgi = require("lgi")
|
local lgi = require("lgi")
|
||||||
local GLib = lgi.GLib
|
local GLib = lgi.GLib
|
||||||
local cairo = lgi.cairo
|
|
||||||
|
|
||||||
local scroll = {}
|
local scroll = {}
|
||||||
local scroll_mt = { __index = scroll }
|
local scroll_mt = { __index = scroll }
|
||||||
|
@ -34,8 +31,7 @@ end
|
||||||
-- Create a hierarchy (and some more stuff) for drawing the given widget. This
|
-- 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.
|
-- 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 hierarchy_cache = cache.new(function(context, widget, width, height)
|
||||||
local context = cleanup_context(context)
|
context = cleanup_context(context)
|
||||||
local surface = cairo.ImageSurface(cairo.Format.ARGB32, width, height)
|
|
||||||
local layouts = setmetatable({}, { __mode = "k" })
|
local layouts = setmetatable({}, { __mode = "k" })
|
||||||
|
|
||||||
-- Create a widget hierarchy and update when needed
|
-- 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)
|
w:emit_signal(signal)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
local function redraw_callback(h, arg)
|
local function redraw_callback()
|
||||||
emit("widget::redraw_needed")
|
emit("widget::redraw_needed")
|
||||||
end
|
end
|
||||||
local function layout_callback(h, arg)
|
local function layout_callback()
|
||||||
emit("widget::redraw_needed")
|
emit("widget::redraw_needed")
|
||||||
emit("widget::layout_changed")
|
emit("widget::layout_changed")
|
||||||
end
|
end
|
||||||
|
@ -122,11 +118,11 @@ local function calculate_info(self, context, width, height)
|
||||||
end
|
end
|
||||||
result.first_x, result.first_y = x, y
|
result.first_x, result.first_y = x, y
|
||||||
-- Was the extra space already included elsewhere?
|
-- 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
|
if self.dir == "h" then
|
||||||
x = x + surface_width + extra
|
x = x + surface_width + extra_spacer
|
||||||
else
|
else
|
||||||
y = y + surface_height + extra
|
y = y + surface_height + extra_spacer
|
||||||
end
|
end
|
||||||
result.second_x, result.second_y = x, y
|
result.second_x, result.second_y = x, y
|
||||||
else
|
else
|
||||||
|
@ -135,10 +131,10 @@ local function calculate_info(self, context, width, height)
|
||||||
result.surface_width, result.surface_height = surface_width, surface_height
|
result.surface_width, result.surface_height = surface_width, surface_height
|
||||||
|
|
||||||
-- Get the hierarchy and subscribe ourselves to updates
|
-- 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)
|
self.widget, surface_width, surface_height)
|
||||||
result.hierarchy = hier
|
result.hierarchy = hier
|
||||||
result.context = context
|
result.context = ctx
|
||||||
do_pending_updates(self)
|
do_pending_updates(self)
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -429,19 +425,19 @@ scroll.step_functions = {}
|
||||||
|
|
||||||
--- A step function that scrolls the widget in an increasing direction with
|
--- A step function that scrolls the widget in an increasing direction with
|
||||||
-- constant speed.
|
-- 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)
|
return (elapsed * speed) % (size + extra_space)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- A step function that scrolls the widget in an decreasing direction with
|
--- A step function that scrolls the widget in an decreasing direction with
|
||||||
-- constant speed.
|
-- 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)
|
return (-elapsed * speed) % (size + extra_space)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- A step function that scrolls the widget to its end and back to its
|
--- 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.
|
-- 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
|
local state = ((elapsed * speed) % (2 * size)) / size
|
||||||
state = state <= 1 and state or 2 - state
|
state = state <= 1 and state or 2 - state
|
||||||
return (size - visible_size) * 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
|
--- 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
|
-- beginning, then back to its end, etc. The speed is null at the ends and
|
||||||
-- maximal in the middle.
|
-- 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 state = ((elapsed * speed) % (2 * size)) / size
|
||||||
local negate = false
|
local negate = false
|
||||||
if state > 1 then
|
if state > 1 then
|
||||||
|
@ -478,7 +474,7 @@ end
|
||||||
--- A step function that scrolls the widget to its end and back to its
|
--- 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
|
-- 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.
|
-- 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 state = ((elapsed * speed) % (2 * size)) / size
|
||||||
local negate = false
|
local negate = false
|
||||||
if state > 1 then
|
if state > 1 then
|
||||||
|
|
|
@ -18,7 +18,6 @@ local base = require("wibox.widget.base" )
|
||||||
local fixed = require("wibox.layout.fixed")
|
local fixed = require("wibox.layout.fixed")
|
||||||
local table = table
|
local table = table
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local floor = math.floor
|
|
||||||
local util = require("awful.util")
|
local util = require("awful.util")
|
||||||
|
|
||||||
local stack = {mt={}}
|
local stack = {mt={}}
|
||||||
|
@ -97,15 +96,11 @@ local stack = {mt={}}
|
||||||
-- @name set_spacing
|
-- @name set_spacing
|
||||||
-- @class function
|
-- @class function
|
||||||
|
|
||||||
--- Layout a stack layout. Each widget get drawn on top of each other
|
function stack:layout(_, width, height)
|
||||||
-- @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)
|
|
||||||
local result = {}
|
local result = {}
|
||||||
local spacing = self._spacing
|
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))
|
table.insert(result, base.place_widget_at(v, spacing, spacing, width - 2*spacing, height - 2*spacing))
|
||||||
if self._top_only then break end
|
if self._top_only then break end
|
||||||
end
|
end
|
||||||
|
@ -113,15 +108,11 @@ function stack:layout(context, width, height)
|
||||||
return result
|
return result
|
||||||
end
|
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)
|
function stack:fit(context, orig_width, orig_height)
|
||||||
local max_w, max_h = 0,0
|
local max_w, max_h = 0,0
|
||||||
local spacing = self._spacing
|
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)
|
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)
|
max_w, max_h = math.max(max_w, w+2*spacing), math.max(max_h, h+2*spacing)
|
||||||
end
|
end
|
||||||
|
|
|
@ -13,7 +13,7 @@ local cairo = require("lgi").cairo
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local type = type
|
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 = {} }
|
local background = { mt = {} }
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ function background:draw(context, cr, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Draw the border
|
-- Draw the border
|
||||||
function background:after_draw_children(context, cr, width, height)
|
function background:after_draw_children(_, cr)
|
||||||
-- Draw the border
|
-- Draw the border
|
||||||
if self._path and self._shape_border_width and self._shape_border_width > 0 then
|
if self._path and self._shape_border_width and self._shape_border_width > 0 then
|
||||||
cr:append_path(self._path)
|
cr:append_path(self._path)
|
||||||
|
@ -68,14 +68,14 @@ function background:after_draw_children(context, cr, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Prepare drawing the children of this widget
|
--- 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
|
if self.foreground then
|
||||||
cr:set_source(self.foreground)
|
cr:set_source(self.foreground)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Layout this widget
|
--- Layout this widget
|
||||||
function background:layout(context, width, height)
|
function background:layout(_, width, height)
|
||||||
if self.widget then
|
if self.widget then
|
||||||
return { base.place_widget_at(self.widget, 0, 0, width, height) }
|
return { base.place_widget_at(self.widget, 0, 0, width, height) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -85,13 +85,13 @@ end
|
||||||
-- The default implementation does nothing, this must be re-implemented by
|
-- The default implementation does nothing, this must be re-implemented by
|
||||||
-- all layout and container widgets.
|
-- all layout and container widgets.
|
||||||
-- @tparam table children A table composed of valid 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
|
-- Nothing on purpose
|
||||||
end
|
end
|
||||||
|
|
||||||
-- It could have been merged into `get_all_children`, but it's not necessary
|
-- It could have been merged into `get_all_children`, but it's not necessary
|
||||||
local function digg_children(ret, tlw)
|
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)
|
table.insert(ret, w)
|
||||||
digg_children(ret, w)
|
digg_children(ret, w)
|
||||||
end
|
end
|
||||||
|
@ -122,9 +122,9 @@ function base.widget:index(widget, recursive, ...)
|
||||||
if w == widget then
|
if w == widget then
|
||||||
return idx, self, {...}
|
return idx, self, {...}
|
||||||
elseif recursive then
|
elseif recursive then
|
||||||
local idx, l, path = w:index(widget, true, self, ...)
|
local child_idx, l, path = w:index(widget, true, self, ...)
|
||||||
if idx and l then
|
if child_idx and l then
|
||||||
return idx, l, path
|
return child_idx, l, path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -206,8 +206,8 @@ function base.fit_widget(parent, context, widget, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sanitize the input. This also filters out e.g. NaN.
|
-- Sanitize the input. This also filters out e.g. NaN.
|
||||||
local width = math.max(0, width)
|
width = math.max(0, width)
|
||||||
local height = math.max(0, height)
|
height = math.max(0, height)
|
||||||
|
|
||||||
local w, h = 0, 0
|
local w, h = 0, 0
|
||||||
if widget.fit then
|
if widget.fit then
|
||||||
|
@ -250,8 +250,8 @@ function base.layout_widget(parent, context, widget, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sanitize the input. This also filters out e.g. NaN.
|
-- Sanitize the input. This also filters out e.g. NaN.
|
||||||
local width = math.max(0, width)
|
width = math.max(0, width)
|
||||||
local height = math.max(0, height)
|
height = math.max(0, height)
|
||||||
|
|
||||||
if widget.layout then
|
if widget.layout then
|
||||||
return get_cache(widget, "layout"):get(context, width, height)
|
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
|
-- Handle a button event on a widget. This is used internally and should not be
|
||||||
-- called directly.
|
-- called directly.
|
||||||
function base.handle_button(event, widget, x, y, button, modifiers, geometry)
|
function base.handle_button(event, widget, x, y, button, modifiers, geometry)
|
||||||
|
x = x or y -- luacheck: no unused
|
||||||
local function is_any(mod)
|
local function is_any(mod)
|
||||||
return #mod == 1 and mod[1] == "Any"
|
return #mod == 1 and mod[1] == "Any"
|
||||||
end
|
end
|
||||||
|
@ -279,7 +280,7 @@ function base.handle_button(event, widget, x, y, button, modifiers, geometry)
|
||||||
|
|
||||||
-- Find all matching button objects
|
-- Find all matching button objects
|
||||||
local matches = {}
|
local matches = {}
|
||||||
for k, v in pairs(widget.widget_buttons) do
|
for _, v in pairs(widget.widget_buttons) do
|
||||||
local match = true
|
local match = true
|
||||||
-- Is it the right button?
|
-- Is it the right button?
|
||||||
if v.button ~= 0 and v.button ~= button then match = false end
|
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
|
end
|
||||||
|
|
||||||
-- Emit the signals
|
-- Emit the signals
|
||||||
for k, v in pairs(matches) do
|
for _, v in pairs(matches) do
|
||||||
v:emit_signal(event,geometry)
|
v:emit_signal(event,geometry)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -332,7 +333,6 @@ end
|
||||||
|
|
||||||
-- Read the table, separate attributes from widgets
|
-- Read the table, separate attributes from widgets
|
||||||
local function parse_table(t, leave_empty)
|
local function parse_table(t, leave_empty)
|
||||||
local keys= {}
|
|
||||||
local max = 0
|
local max = 0
|
||||||
local attributes, widgets = {}, {}
|
local attributes, widgets = {}, {}
|
||||||
for k,v in pairs(t) do
|
for k,v in pairs(t) do
|
||||||
|
@ -450,12 +450,12 @@ function base.make_widget_declarative(args)
|
||||||
local w, id = drill(ids, args)
|
local w, id = drill(ids, args)
|
||||||
|
|
||||||
local mt = {}
|
local mt = {}
|
||||||
local orig_string = tostring(ret)
|
local orig_string = tostring(w)
|
||||||
|
|
||||||
rawset(w, "_by_id", ids)
|
rawset(w, "_by_id", ids)
|
||||||
rawset(w, "get_children_by_id", get_children_by_id)
|
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)
|
return string.format("%s (%s)", id, orig_string)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -518,7 +518,7 @@ function base.make_widget(proxy, widget_name)
|
||||||
ret.fit = function(_, context, width, height)
|
ret.fit = function(_, context, width, height)
|
||||||
return base.fit_widget(ret, context, proxy, width, height)
|
return base.fit_widget(ret, context, proxy, width, height)
|
||||||
end
|
end
|
||||||
ret.layout = function(_, context, width, height)
|
ret.layout = function(_, _, width, height)
|
||||||
return { base.place_widget_at(proxy, 0, 0, width, height) }
|
return { base.place_widget_at(proxy, 0, 0, width, height) }
|
||||||
end
|
end
|
||||||
proxy:connect_signal("widget::layout_changed", function()
|
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)
|
ret.widget_name = widget_name or object.modulename(3)
|
||||||
local mt = {}
|
local mt = {}
|
||||||
local orig_string = tostring(ret)
|
local orig_string = tostring(ret)
|
||||||
mt.__tostring = function(o)
|
mt.__tostring = function()
|
||||||
return string.format("%s (%s)", ret.widget_name, orig_string)
|
return string.format("%s (%s)", ret.widget_name, orig_string)
|
||||||
end
|
end
|
||||||
return setmetatable(ret, mt)
|
return setmetatable(ret, mt)
|
||||||
|
@ -559,7 +559,7 @@ end
|
||||||
-- widget is not a valid widget.
|
-- widget is not a valid widget.
|
||||||
function base.check_widget(widget)
|
function base.check_widget(widget)
|
||||||
assert(type(widget) == "table")
|
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")
|
assert(type(widget[func]) == "function", func .. " is not a function")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,14 +10,13 @@ local surface = require("gears.surface")
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local type = type
|
local type = type
|
||||||
local pcall = pcall
|
|
||||||
local print = print
|
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 = {} }
|
local imagebox = { mt = {} }
|
||||||
|
|
||||||
--- Draw an imagebox with the given cairo context in the given geometry.
|
--- 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 not self._image then return end
|
||||||
if width == 0 or height == 0 then return end
|
if width == 0 or height == 0 then return end
|
||||||
|
|
||||||
|
@ -42,7 +41,7 @@ function imagebox:draw(context, cr, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Fit the imagebox into the given geometry
|
--- Fit the imagebox into the given geometry
|
||||||
function imagebox:fit(context, width, height)
|
function imagebox:fit(_, width, height)
|
||||||
if not self._image then
|
if not self._image then
|
||||||
return 0, 0
|
return 0, 0
|
||||||
end
|
end
|
||||||
|
@ -81,8 +80,6 @@ end
|
||||||
-- interpreted as the path to a png image file.
|
-- interpreted as the path to a png image file.
|
||||||
-- @return true on success, false if the image cannot be used
|
-- @return true on success, false if the image cannot be used
|
||||||
function imagebox:set_image(image)
|
function imagebox:set_image(image)
|
||||||
local image = image
|
|
||||||
|
|
||||||
if type(image) == "string" then
|
if type(image) == "string" then
|
||||||
image = surface.load(image)
|
image = surface.load(image)
|
||||||
if not image then
|
if not image then
|
||||||
|
|
|
@ -48,7 +48,7 @@ function systray:draw(context, cr, width, height)
|
||||||
base, is_rotated, bg, reverse, spacing)
|
base, is_rotated, bg, reverse, spacing)
|
||||||
end
|
end
|
||||||
|
|
||||||
function systray:fit(context, width, height)
|
function systray:fit(_, width, height)
|
||||||
local num_entries = capi.awesome.systray()
|
local num_entries = capi.awesome.systray()
|
||||||
local base = base_size
|
local base = base_size
|
||||||
local spacing = beautiful.systray_icon_spacing or 0
|
local spacing = beautiful.systray_icon_spacing or 0
|
||||||
|
@ -76,7 +76,7 @@ local function new(revers)
|
||||||
ret.draw = systray.draw
|
ret.draw = systray.draw
|
||||||
ret.set_base_size = function(_, size) base_size = size end
|
ret.set_base_size = function(_, size) base_size = size end
|
||||||
ret.set_horizontal = function(_, horiz) horizontal = horiz 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
|
if revers then
|
||||||
ret:set_reverse(true)
|
ret:set_reverse(true)
|
||||||
|
|
|
@ -10,13 +10,11 @@ local base = require("wibox.widget.base")
|
||||||
local gdebug = require("gears.debug")
|
local gdebug = require("gears.debug")
|
||||||
local beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
local lgi = require("lgi")
|
local lgi = require("lgi")
|
||||||
local cairo = lgi.cairo
|
|
||||||
local Pango = lgi.Pango
|
local Pango = lgi.Pango
|
||||||
local PangoCairo = lgi.PangoCairo
|
local PangoCairo = lgi.PangoCairo
|
||||||
local type = type
|
local type = type
|
||||||
local setmetatable = setmetatable
|
local setmetatable = setmetatable
|
||||||
local pairs = pairs
|
local pairs = pairs
|
||||||
local error = error
|
|
||||||
|
|
||||||
local textbox = { mt = {} }
|
local textbox = { mt = {} }
|
||||||
|
|
||||||
|
@ -40,7 +38,7 @@ end
|
||||||
function textbox:draw(context, cr, width, height)
|
function textbox:draw(context, cr, width, height)
|
||||||
setup_layout(self, width, height, context.dpi)
|
setup_layout(self, width, height, context.dpi)
|
||||||
cr:update_layout(self._layout)
|
cr:update_layout(self._layout)
|
||||||
local ink, logical = self._layout:get_pixel_extents()
|
local _, logical = self._layout:get_pixel_extents()
|
||||||
local offset = 0
|
local offset = 0
|
||||||
if self._valign == "center" then
|
if self._valign == "center" then
|
||||||
offset = (height - logical.height) / 2
|
offset = (height - logical.height) / 2
|
||||||
|
@ -52,7 +50,7 @@ function textbox:draw(context, cr, width, height)
|
||||||
end
|
end
|
||||||
|
|
||||||
local function do_fit_return(self)
|
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
|
if logical.width == 0 or logical.height == 0 then
|
||||||
return 0, 0
|
return 0, 0
|
||||||
end
|
end
|
||||||
|
@ -110,7 +108,7 @@ function textbox:get_height_for_width_at_dpi(width, dpi)
|
||||||
setup_dpi(self, dpi)
|
setup_dpi(self, dpi)
|
||||||
self._layout.width = Pango.units_from_double(width)
|
self._layout.width = Pango.units_from_double(width)
|
||||||
self._layout.height = -max_lines -- show this many lines per paragraph
|
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
|
return h
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -261,7 +259,7 @@ local function new(text, ignore_markup)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function textbox.mt:__call(...)
|
function textbox.mt.__call(_, ...)
|
||||||
return new(...)
|
return new(...)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
local timer = require("gears.timer")
|
local timer = require("gears.timer")
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
|
|
||||||
runner = {
|
local runner = {
|
||||||
quit_awesome_on_error = os.getenv('TEST_PAUSE_ON_ERRORS') ~= '1',
|
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-on-timeout defaults to false: indicates some problem with the test itself.
|
||||||
quit_awesome_on_timeout = os.getenv('TEST_QUIT_ON_TIMEOUT') ~= '1',
|
quit_awesome_on_timeout = os.getenv('TEST_QUIT_ON_TIMEOUT') ~= '1',
|
||||||
|
|
|
@ -15,7 +15,7 @@ do
|
||||||
local timer_measure = GLib.Timer()
|
local timer_measure = GLib.Timer()
|
||||||
measure = function(f, iter)
|
measure = function(f, iter)
|
||||||
timer_measure:start()
|
timer_measure:start()
|
||||||
for i = 1, iter do
|
for _ = 1, iter do
|
||||||
f()
|
f()
|
||||||
end
|
end
|
||||||
local elapsed = timer_measure:elapsed()
|
local elapsed = timer_measure:elapsed()
|
||||||
|
@ -47,7 +47,7 @@ local function create_and_draw_wibox()
|
||||||
do_pending_repaint()
|
do_pending_repaint()
|
||||||
end
|
end
|
||||||
|
|
||||||
local wb, textclock = create_wibox()
|
local _, textclock = create_wibox()
|
||||||
|
|
||||||
local function relayout_textclock()
|
local function relayout_textclock()
|
||||||
textclock:emit_signal("widget::layout_changed")
|
textclock:emit_signal("widget::layout_changed")
|
||||||
|
|
|
@ -1,10 +1,9 @@
|
||||||
--- Tests for focus signals / property.
|
--- Tests for focus signals / property.
|
||||||
-- Test for https://github.com/awesomeWM/awesome/issues/134.
|
-- Test for https://github.com/awesomeWM/awesome/issues/134.
|
||||||
|
|
||||||
awful = require("awful")
|
local awful = require("awful")
|
||||||
timer = require("gears.timer")
|
|
||||||
|
|
||||||
beautiful = require("beautiful")
|
local beautiful = require("beautiful")
|
||||||
beautiful.border_normal = "#0000ff"
|
beautiful.border_normal = "#0000ff"
|
||||||
beautiful.border_focus = "#00ff00"
|
beautiful.border_focus = "#00ff00"
|
||||||
|
|
||||||
|
|
|
@ -3,17 +3,15 @@
|
||||||
local awful = require("awful")
|
local awful = require("awful")
|
||||||
local cairo = require("lgi").cairo
|
local cairo = require("lgi").cairo
|
||||||
local create_wibox = require("_wibox_helper").create_wibox
|
local create_wibox = require("_wibox_helper").create_wibox
|
||||||
local gears = require("gears")
|
|
||||||
local wibox = require("wibox")
|
local wibox = require("wibox")
|
||||||
|
|
||||||
local errors = {}
|
|
||||||
|
|
||||||
local prepare_for_collect = nil
|
local prepare_for_collect = nil
|
||||||
local function emit_refresh()
|
local function emit_refresh()
|
||||||
awesome.emit_signal("refresh")
|
awesome.emit_signal("refresh")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Make the layoutbox in the default config GC'able
|
-- Make the layoutbox in the default config GC'able
|
||||||
|
-- luacheck: globals mywibox mylayoutbox
|
||||||
mywibox[1].visible = false
|
mywibox[1].visible = false
|
||||||
mywibox = nil
|
mywibox = nil
|
||||||
mylayoutbox = nil
|
mylayoutbox = nil
|
||||||
|
@ -23,7 +21,7 @@ emit_refresh()
|
||||||
local function collectable(a, b, c, d, e, f, g, h, last)
|
local function collectable(a, b, c, d, e, f, g, h, last)
|
||||||
assert(last == nil, "got more arguments than supported")
|
assert(last == nil, "got more arguments than supported")
|
||||||
local objs = setmetatable({ a, b, c, d, e, f, g, h }, { __mode = "v" })
|
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
|
if prepare_for_collect then
|
||||||
prepare_for_collect()
|
prepare_for_collect()
|
||||||
prepare_for_collect = nil
|
prepare_for_collect = nil
|
||||||
|
@ -31,7 +29,7 @@ local function collectable(a, b, c, d, e, f, g, h, last)
|
||||||
collectgarbage("collect")
|
collectgarbage("collect")
|
||||||
collectgarbage("collect")
|
collectgarbage("collect")
|
||||||
-- Check if the table is now empty
|
-- 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!")
|
print("Some object was not garbage collected!")
|
||||||
error(v)
|
error(v)
|
||||||
end
|
end
|
||||||
|
|
|
@ -16,7 +16,6 @@ local steps = {
|
||||||
if count == 1 then
|
if count == 1 then
|
||||||
ret, snid = spawn('urxvt', true)
|
ret, snid = spawn('urxvt', true)
|
||||||
elseif manage_called then
|
elseif manage_called then
|
||||||
local c = client.get()[1]
|
|
||||||
assert(ret)
|
assert(ret)
|
||||||
assert(snid)
|
assert(snid)
|
||||||
assert(snid == c_snid)
|
assert(snid == c_snid)
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
--- Tests for urgent property.
|
--- 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.
|
-- Some basic assertion that the tag is not marked "urgent" already.
|
||||||
assert(awful.tag.getproperty(tags[1][2], "urgent") == nil)
|
assert(awful.tag.getproperty(tags[1][2], "urgent") == nil)
|
||||||
|
@ -53,7 +57,7 @@ local steps = {
|
||||||
|
|
||||||
elseif awful.tag.selectedlist()[1] == tags[1][2] then
|
elseif awful.tag.selectedlist()[1] == tags[1][2] then
|
||||||
assert(#client.get() == 1)
|
assert(#client.get() == 1)
|
||||||
c = client.get()[1]
|
local c = client.get()[1]
|
||||||
assert(not c.urgent, "Client is not urgent anymore.")
|
assert(not c.urgent, "Client is not urgent anymore.")
|
||||||
assert(c == client.focus, "Client is focused.")
|
assert(c == client.focus, "Client is focused.")
|
||||||
assert(awful.tag.getproperty(tags[1][2], "urgent") == false)
|
assert(awful.tag.getproperty(tags[1][2], "urgent") == false)
|
||||||
|
@ -106,6 +110,6 @@ local steps = {
|
||||||
end,
|
end,
|
||||||
}
|
}
|
||||||
|
|
||||||
require("_runner").run_steps(steps)
|
runner.run_steps(steps)
|
||||||
|
|
||||||
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80
|
||||||
|
|
Loading…
Reference in New Issue