shims: Fix some missing client property::* signals.
It also found a bug in an existing test.
This commit is contained in:
parent
a7932b127f
commit
495922c31c
|
@ -9,7 +9,11 @@ awful.tag({ "1", "2", "3", "4", "5", "6", "7", "8", "9" }, screen[1], awful.layo
|
||||||
local original_geo, geo
|
local original_geo, geo
|
||||||
|
|
||||||
function awful.spawn(name)
|
function awful.spawn(name)
|
||||||
client.gen_fake{class = name, name = name, x = 4, y=10, width = 60, height =50, screen=screen[1]}
|
local c = client.gen_fake{class = name, name = name, x = 4, y=10, width = 60, height =50, screen=screen[1]}
|
||||||
|
assert(c:geometry().x == 4)
|
||||||
|
assert(c:geometry().y == 10)
|
||||||
|
assert(c:geometry().width == 60)
|
||||||
|
assert(c:geometry().height == 50)
|
||||||
end
|
end
|
||||||
|
|
||||||
--DOC_NEWLINE
|
--DOC_NEWLINE
|
||||||
|
@ -21,6 +25,10 @@ module.add_event("Spawn a floating client.", function()
|
||||||
--DOC_NEWLINE
|
--DOC_NEWLINE
|
||||||
|
|
||||||
client.get()[1].floating = true
|
client.get()[1].floating = true
|
||||||
|
assert(client.get()[1]:geometry().x == 4) --DOC_HIDE
|
||||||
|
assert(client.get()[1]:geometry().y == 10) --DOC_HIDE
|
||||||
|
assert(client.get()[1]:geometry().width == 60) --DOC_HIDE
|
||||||
|
assert(client.get()[1]:geometry().height == 50) --DOC_HIDE
|
||||||
|
|
||||||
--DOC_NEWLINE
|
--DOC_NEWLINE
|
||||||
|
|
||||||
|
|
|
@ -74,48 +74,61 @@ function client.gen_fake(args)
|
||||||
awesome._forward_class(ret, client)
|
awesome._forward_class(ret, client)
|
||||||
|
|
||||||
ret._private = {}
|
ret._private = {}
|
||||||
ret.type = "normal"
|
|
||||||
|
-- Make sure the layer properties are not `nil`
|
||||||
|
local defaults = {
|
||||||
|
ontop = false,
|
||||||
|
below = false,
|
||||||
|
above = false,
|
||||||
|
sticky = false,
|
||||||
|
urgent = false,
|
||||||
|
focusable = true,
|
||||||
|
hidden = args.hidden or false,
|
||||||
|
minimized = args.minimized or false,
|
||||||
|
type = args.type or "normal",
|
||||||
|
icon_sizes = args.icon_sizes or {{16,16}},
|
||||||
|
name = args.name or "Example Client",
|
||||||
|
size_hints = args.size_hints or {},
|
||||||
|
_border_width = args.border_width or 1,
|
||||||
|
|
||||||
|
-- This is a hack because there's a `:is_transient_for(c2)` method
|
||||||
|
-- and a `transient_for` property. It will cause a stack overflow
|
||||||
|
-- since the auto-alias will kick in if the property is allowed to
|
||||||
|
-- be `nil`.
|
||||||
|
transient_for = args.transient_for or false,
|
||||||
|
}
|
||||||
|
|
||||||
ret.valid = true
|
ret.valid = true
|
||||||
ret.size_hints = {}
|
|
||||||
ret._border_width = 1
|
|
||||||
ret._tags = args and args.tags or nil
|
ret._tags = args and args.tags or nil
|
||||||
ret.icon_sizes = {{16,16}}
|
|
||||||
ret.name = "Example Client"
|
|
||||||
ret._private._struts = { top = 0, right = 0, left = 0, bottom = 0 }
|
ret._private._struts = { top = 0, right = 0, left = 0, bottom = 0 }
|
||||||
|
|
||||||
--TODO v5: remove this. This was a private API and thus doesn't need to be
|
--TODO v5: remove this. This was a private API and thus doesn't need to be
|
||||||
-- officially deprecated.
|
-- officially deprecated.
|
||||||
ret.data = ret._private
|
ret.data = ret._private
|
||||||
|
|
||||||
-- This is a hack because there's a `:is_transient_for(c2)` method
|
|
||||||
-- and a `transient_for` property. It will cause a stack overflow
|
|
||||||
-- since the auto-alias will kick in if the property is allowed to
|
|
||||||
-- be `nil`.
|
|
||||||
ret.transient_for = false
|
|
||||||
|
|
||||||
-- Apply all properties
|
-- Apply all properties
|
||||||
for k,v in pairs(args or {}) do
|
for k,v in pairs(args or {}) do
|
||||||
ret[k] = v
|
ret._private[k] = v
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Tests should always set a geometry, but just in case
|
-- Tests should always set a geometry, but just in case
|
||||||
for _, v in ipairs{"x","y","width","height"} do
|
for _, v in ipairs{"x","y","width","height"} do
|
||||||
ret[v] = ret[v] or 1
|
rawset(ret, v, math.floor(ret[v] or ret._private[v] or 1))
|
||||||
assert((not args[v]) or ret[v] == args[v])
|
assert((not args[v]) or ret[v] == args[v])
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Emulate capi.client.geometry
|
-- Emulate capi.client.geometry
|
||||||
function ret:geometry(new)
|
function ret:geometry(new)
|
||||||
local new_full = new and {
|
local new_full = new and {
|
||||||
x = new.x or ret.x,
|
x = math.floor(new.x or ret.x),
|
||||||
y = new.y or ret.y,
|
y = math.floor(new.y or ret.y),
|
||||||
width = new.width or ret.width,
|
width = math.floor(new.width or ret.width),
|
||||||
height = new.height or ret.height,
|
height = math.floor(new.height or ret.height),
|
||||||
} or nil
|
} or nil
|
||||||
|
|
||||||
if new and not grect.are_equal(ret, new_full) then
|
if new and not grect.are_equal(ret, new_full) then
|
||||||
for k,v in pairs(new) do
|
for k,v in pairs(new) do
|
||||||
ret[k] = v
|
rawset(ret, k, v)
|
||||||
ret:emit_signal("property::"..k, v)
|
ret:emit_signal("property::"..k, v)
|
||||||
end
|
end
|
||||||
ret:emit_signal("property::geometry", ret:geometry())
|
ret:emit_signal("property::geometry", ret:geometry())
|
||||||
|
@ -123,10 +136,10 @@ function client.gen_fake(args)
|
||||||
end
|
end
|
||||||
|
|
||||||
return {
|
return {
|
||||||
x = ret.x,
|
x = math.floor(ret.x),
|
||||||
y = ret.y,
|
y = math.floor(ret.y),
|
||||||
width = ret.width,
|
width = math.floor(ret.width),
|
||||||
height = ret.height,
|
height = math.floor(ret.height),
|
||||||
label = ret._label,
|
label = ret._label,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
@ -292,16 +305,6 @@ function client.gen_fake(args)
|
||||||
ret.drawin = ret
|
ret.drawin = ret
|
||||||
ret.drawable = ret
|
ret.drawable = ret
|
||||||
|
|
||||||
-- Make sure the layer properties are not `nil`
|
|
||||||
local defaults = {
|
|
||||||
ontop = false,
|
|
||||||
below = false,
|
|
||||||
above = false,
|
|
||||||
sticky = false,
|
|
||||||
urgent = false,
|
|
||||||
focusable = true,
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Declare the deprecated buttons and keys methods.
|
-- Declare the deprecated buttons and keys methods.
|
||||||
function ret:_keys(new)
|
function ret:_keys(new)
|
||||||
if new then
|
if new then
|
||||||
|
@ -330,6 +333,8 @@ function client.gen_fake(args)
|
||||||
return properties["get_"..key](self)
|
return properties["get_"..key](self)
|
||||||
elseif defaults[key] ~= nil then
|
elseif defaults[key] ~= nil then
|
||||||
return defaults[key]
|
return defaults[key]
|
||||||
|
elseif self._private[key] ~= nil then
|
||||||
|
return self._private[key]
|
||||||
end
|
end
|
||||||
|
|
||||||
return meta.__index(self, key)
|
return meta.__index(self, key)
|
||||||
|
|
|
@ -19,6 +19,7 @@ for i=1, 3 do --DOC_HIDE
|
||||||
c:tags{t_real} --DOC_HIDE
|
c:tags{t_real} --DOC_HIDE
|
||||||
c.icon = beautiful.awesome_icon --DOC_HIDE
|
c.icon = beautiful.awesome_icon --DOC_HIDE
|
||||||
c.name = " Client "..i.." " --DOC_HIDE
|
c.name = " Client "..i.." " --DOC_HIDE
|
||||||
|
assert(c.name == " Client "..i.." ") --DOC_HIDE
|
||||||
end --DOC_HIDE
|
end --DOC_HIDE
|
||||||
|
|
||||||
s.mytasklist = awful.widget.tasklist {
|
s.mytasklist = awful.widget.tasklist {
|
||||||
|
|
Loading…
Reference in New Issue