awful.client: Save client properties under c.data

Instead of using a weak table with some magic to save properties of a
client, the code now uses the c.data table provided by the C code
instead.

Signed-off-by: Uli Schlachter <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2016-10-05 20:55:28 +02:00
parent 22d1375e5f
commit 3d048dca04
1 changed files with 9 additions and 10 deletions

View File

@ -46,7 +46,6 @@ local client = {object={}}
-- Private data
client.data = {}
client.data.marked = {}
client.data.properties = setmetatable({}, { __mode = 'k' })
client.data.persistent_properties_registered = {} -- keys are names of persistent properties, value always true
-- Functions
@ -994,8 +993,8 @@ function client.property.get(c, prop)
end
end
end
if client.data.properties[c] then
return client.data.properties[c][prop]
if c.data.awful_client_properties then
return c.data.awful_client_properties[prop]
end
end
@ -1009,14 +1008,14 @@ end
-- @param value The value.
-- @deprecated awful.client.property.set
function client.property.set(c, prop, value)
if not client.data.properties[c] then
client.data.properties[c] = {}
if not c.data.awful_client_properties then
c.data.awful_client_properties = {}
end
if client.data.properties[c][prop] ~= value then
if c.data.awful_client_properties[prop] ~= value then
if client.data.persistent_properties_registered[prop] then
c:set_xproperty("awful.client.property." .. prop, value)
end
client.data.properties[c][prop] = value
c.data.awful_client_properties[prop] = value
c:emit_signal("property::" .. prop)
end
end
@ -1033,9 +1032,9 @@ function client.property.persist(prop, kind)
client.data.persistent_properties_registered[prop] = true
-- Make already-set properties persistent
for c in pairs(client.data.properties) do
if client.data.properties[c] and client.data.properties[c][prop] ~= nil then
c:set_xproperty(xprop, client.data.properties[c][prop])
for c in pairs(capi.client.get()) do
if c.data.awful_client_properties and c.data.awful_client_properties[prop] ~= nil then
c:set_xproperty(xprop, c.data.awful_client_properties[prop])
end
end
end