Merge pull request #1147 from psychon/remove_weak_tables
Remove some weak tables
This commit is contained in:
commit
05d962f778
|
@ -46,9 +46,7 @@ local client = {object={}}
|
||||||
-- Private data
|
-- Private data
|
||||||
client.data = {}
|
client.data = {}
|
||||||
client.data.marked = {}
|
client.data.marked = {}
|
||||||
client.data.properties = setmetatable({}, { __mode = 'k' })
|
|
||||||
client.data.persistent_properties_registered = {} -- keys are names of persistent properties, value always true
|
client.data.persistent_properties_registered = {} -- keys are names of persistent properties, value always true
|
||||||
client.data.persistent_properties_loaded = setmetatable({}, { __mode = 'k' }) -- keys are clients, value always true
|
|
||||||
|
|
||||||
-- Functions
|
-- Functions
|
||||||
client.urgent = require("awful.client.urgent")
|
client.urgent = require("awful.client.urgent")
|
||||||
|
@ -986,8 +984,8 @@ end
|
||||||
-- @return The property.
|
-- @return The property.
|
||||||
-- @deprecated awful.client.property.get
|
-- @deprecated awful.client.property.get
|
||||||
function client.property.get(c, prop)
|
function client.property.get(c, prop)
|
||||||
if not client.data.persistent_properties_loaded[c] then
|
if not c.data._persistent_properties_loaded then
|
||||||
client.data.persistent_properties_loaded[c] = true
|
c.data._persistent_properties_loaded = true
|
||||||
for p in pairs(client.data.persistent_properties_registered) do
|
for p in pairs(client.data.persistent_properties_registered) do
|
||||||
local value = c:get_xproperty("awful.client.property." .. p)
|
local value = c:get_xproperty("awful.client.property." .. p)
|
||||||
if value ~= nil then
|
if value ~= nil then
|
||||||
|
@ -995,8 +993,8 @@ function client.property.get(c, prop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
if client.data.properties[c] then
|
if c.data.awful_client_properties then
|
||||||
return client.data.properties[c][prop]
|
return c.data.awful_client_properties[prop]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1010,14 +1008,14 @@ end
|
||||||
-- @param value The value.
|
-- @param value The value.
|
||||||
-- @deprecated awful.client.property.set
|
-- @deprecated awful.client.property.set
|
||||||
function client.property.set(c, prop, value)
|
function client.property.set(c, prop, value)
|
||||||
if not client.data.properties[c] then
|
if not c.data.awful_client_properties then
|
||||||
client.data.properties[c] = {}
|
c.data.awful_client_properties = {}
|
||||||
end
|
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
|
if client.data.persistent_properties_registered[prop] then
|
||||||
c:set_xproperty("awful.client.property." .. prop, value)
|
c:set_xproperty("awful.client.property." .. prop, value)
|
||||||
end
|
end
|
||||||
client.data.properties[c][prop] = value
|
c.data.awful_client_properties[prop] = value
|
||||||
c:emit_signal("property::" .. prop)
|
c:emit_signal("property::" .. prop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1034,9 +1032,9 @@ function client.property.persist(prop, kind)
|
||||||
client.data.persistent_properties_registered[prop] = true
|
client.data.persistent_properties_registered[prop] = true
|
||||||
|
|
||||||
-- Make already-set properties persistent
|
-- Make already-set properties persistent
|
||||||
for c in pairs(client.data.properties) do
|
for c in pairs(capi.client.get()) do
|
||||||
if client.data.properties[c] and client.data.properties[c][prop] ~= nil then
|
if c.data.awful_client_properties and c.data.awful_client_properties[prop] ~= nil then
|
||||||
c:set_xproperty(xprop, client.data.properties[c][prop])
|
c:set_xproperty(xprop, c.data.awful_client_properties[prop])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -31,8 +31,6 @@ local screen = {object={}}
|
||||||
local data = {}
|
local data = {}
|
||||||
data.padding = {}
|
data.padding = {}
|
||||||
|
|
||||||
screen.mouse_per_screen = setmetatable({}, {__mode="k"})
|
|
||||||
|
|
||||||
--- Take an input geometry and substract/add a delta.
|
--- Take an input geometry and substract/add a delta.
|
||||||
-- @tparam table geo A geometry (width, height, x, y) table.
|
-- @tparam table geo A geometry (width, height, x, y) table.
|
||||||
-- @tparam table delta A delta table (top, bottom, x, y).
|
-- @tparam table delta A delta table (top, bottom, x, y).
|
||||||
|
@ -99,7 +97,7 @@ function screen.focus(_screen)
|
||||||
local s = get_screen(capi.mouse.screen)
|
local s = get_screen(capi.mouse.screen)
|
||||||
local pos
|
local pos
|
||||||
|
|
||||||
if not screen.mouse_per_screen[_screen] then
|
if not _screen.mouse_per_screen then
|
||||||
-- This is the first time we enter this screen,
|
-- This is the first time we enter this screen,
|
||||||
-- keep relative mouse position on the new screen.
|
-- keep relative mouse position on the new screen.
|
||||||
pos = capi.mouse.coords()
|
pos = capi.mouse.coords()
|
||||||
|
@ -110,11 +108,11 @@ function screen.focus(_screen)
|
||||||
pos.y = _screen.geometry.y + rely * _screen.geometry.height
|
pos.y = _screen.geometry.y + rely * _screen.geometry.height
|
||||||
else
|
else
|
||||||
-- restore mouse position
|
-- restore mouse position
|
||||||
pos = screen.mouse_per_screen[_screen]
|
pos = _screen.mouse_per_screen
|
||||||
end
|
end
|
||||||
|
|
||||||
-- save pointer position of current screen
|
-- save pointer position of current screen
|
||||||
screen.mouse_per_screen[s] = capi.mouse.coords()
|
s.mouse_per_screen = capi.mouse.coords()
|
||||||
|
|
||||||
-- move cursor without triggering signals mouse::enter and mouse::leave
|
-- move cursor without triggering signals mouse::enter and mouse::leave
|
||||||
capi.mouse.coords(pos, true)
|
capi.mouse.coords(pos, true)
|
||||||
|
|
|
@ -35,8 +35,6 @@ local tag = {object = {}, mt = {} }
|
||||||
-- Private data
|
-- Private data
|
||||||
local data = {}
|
local data = {}
|
||||||
data.history = {}
|
data.history = {}
|
||||||
data.dynamic_cache = setmetatable({}, { __mode = 'k' })
|
|
||||||
data.tags = setmetatable({}, { __mode = 'k' })
|
|
||||||
|
|
||||||
-- History functions
|
-- History functions
|
||||||
tag.history = {}
|
tag.history = {}
|
||||||
|
@ -217,7 +215,7 @@ function tag.add(name, props)
|
||||||
local newtag = capi.tag{ name = name }
|
local newtag = capi.tag{ name = name }
|
||||||
|
|
||||||
-- Start with a fresh property table to avoid collisions with unsupported data
|
-- Start with a fresh property table to avoid collisions with unsupported data
|
||||||
data.tags[newtag] = {screen=properties.screen, index=properties.index}
|
newtag.data.awful_tag_properties = {screen=properties.screen, index=properties.index}
|
||||||
|
|
||||||
newtag.activated = true
|
newtag.activated = true
|
||||||
|
|
||||||
|
@ -323,7 +321,7 @@ function tag.object.delete(self, fallback_tag, force)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- delete the tag
|
-- delete the tag
|
||||||
data.tags[self].screen = nil
|
self.data.awful_tag_properties.screen = nil
|
||||||
self.activated = false
|
self.activated = false
|
||||||
|
|
||||||
-- Update all indexes
|
-- Update all indexes
|
||||||
|
@ -710,11 +708,11 @@ function tag.object.set_layout(t, layout)
|
||||||
and getmetatable(layout)
|
and getmetatable(layout)
|
||||||
and getmetatable(layout).__call
|
and getmetatable(layout).__call
|
||||||
) then
|
) then
|
||||||
if not data.dynamic_cache[t] then
|
if not t.dynamic_layout_cache then
|
||||||
data.dynamic_cache[t] = {}
|
t.dynamic_layout_cache = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
local instance = data.dynamic_cache[t][layout] or layout(t)
|
local instance = t.dynamic_layout_cache[layout] or layout(t)
|
||||||
|
|
||||||
-- Always make sure the layout is notified it is enabled
|
-- Always make sure the layout is notified it is enabled
|
||||||
if tag.getproperty(t, "screen").selected_tag == t and instance.wake_up then
|
if tag.getproperty(t, "screen").selected_tag == t and instance.wake_up then
|
||||||
|
@ -723,7 +721,7 @@ function tag.object.set_layout(t, layout)
|
||||||
|
|
||||||
-- Avoid creating the same layout twice, use layout:reset() to reset
|
-- Avoid creating the same layout twice, use layout:reset() to reset
|
||||||
if instance.is_dynamic then
|
if instance.is_dynamic then
|
||||||
data.dynamic_cache[t][layout] = instance
|
t.dynamic_layout_cache[layout] = instance
|
||||||
end
|
end
|
||||||
|
|
||||||
layout = instance
|
layout = instance
|
||||||
|
@ -1278,7 +1276,7 @@ end
|
||||||
-- @tparam tag _tag The tag.
|
-- @tparam tag _tag The tag.
|
||||||
-- @return The data table.
|
-- @return The data table.
|
||||||
function tag.getdata(_tag)
|
function tag.getdata(_tag)
|
||||||
return data.tags[_tag]
|
return _tag.data.awful_tag_properties
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get a tag property.
|
--- Get a tag property.
|
||||||
|
@ -1290,8 +1288,9 @@ end
|
||||||
-- @tparam string prop The property name.
|
-- @tparam string prop The property name.
|
||||||
-- @return The property.
|
-- @return The property.
|
||||||
function tag.getproperty(_tag, prop)
|
function tag.getproperty(_tag, prop)
|
||||||
if data.tags[_tag] then
|
if not _tag then return end -- FIXME: Turn this into an error?
|
||||||
return data.tags[_tag][prop]
|
if _tag.data.awful_tag_properties then
|
||||||
|
return _tag.data.awful_tag_properties[prop]
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1306,12 +1305,12 @@ end
|
||||||
-- @param prop The property name.
|
-- @param prop The property name.
|
||||||
-- @param value The value.
|
-- @param value The value.
|
||||||
function tag.setproperty(_tag, prop, value)
|
function tag.setproperty(_tag, prop, value)
|
||||||
if not data.tags[_tag] then
|
if not _tag.data.awful_tag_properties then
|
||||||
data.tags[_tag] = {}
|
_tag.data.awful_tag_properties = {}
|
||||||
end
|
end
|
||||||
|
|
||||||
if data.tags[_tag][prop] ~= value then
|
if _tag.data.awful_tag_properties[prop] ~= value then
|
||||||
data.tags[_tag][prop] = value
|
_tag.data.awful_tag_properties[prop] = value
|
||||||
_tag:emit_signal("property::" .. prop)
|
_tag:emit_signal("property::" .. prop)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1463,8 +1462,8 @@ capi.screen.connect_signal("removed", function(s)
|
||||||
for _, t in pairs(s.tags) do
|
for _, t in pairs(s.tags) do
|
||||||
t.activated = false
|
t.activated = false
|
||||||
|
|
||||||
if data.tags[t] then
|
if t.data.awful_tag_properties then
|
||||||
data.tags[t].screen = nil
|
t.data.awful_tag_properties.screen = nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|
|
@ -158,11 +158,8 @@ local function new(args)
|
||||||
local ret = object()
|
local ret = object()
|
||||||
local w = capi.drawin(args)
|
local w = capi.drawin(args)
|
||||||
|
|
||||||
-- lua 5.1 and luajit have issues with self referencing loops
|
|
||||||
local avoid_leak = setmetatable({ret},{__mode="v"})
|
|
||||||
|
|
||||||
function w.get_wibox()
|
function w.get_wibox()
|
||||||
return avoid_leak[1]
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
ret.drawin = w
|
ret.drawin = w
|
||||||
|
|
Loading…
Reference in New Issue