Created
April 9, 2014 21:44
-
-
Save psychon/10320743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/awful/client.lua.in b/lib/awful/client.lua.in | |
index f72e9be..fa4ac1f 100644 | |
--- a/lib/awful/client.lua.in | |
+++ b/lib/awful/client.lua.in | |
@@ -18,6 +18,7 @@ local capi = | |
client = client, | |
mouse = mouse, | |
screen = screen, | |
+ awesome = awesome, | |
} | |
-- we use require("awful.screen") inside functions to prevent circular dependencies. | |
@@ -34,6 +35,8 @@ client.data.focus = {} | |
client.data.urgent = {} | |
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_loaded = setmetatable({}, { __mode = 'k' }) -- keys are clients, value always true | |
-- Functions | |
client.urgent = {} | |
@@ -868,6 +871,12 @@ end | |
-- @param prop The property name. | |
-- @return The property. | |
function client.property.get(c, prop) | |
+ if not client.data.persistent_properties_loaded[c] then | |
+ client.data.persistent_properties_loaded[c] = true | |
+ for p in pairs(client.data.persistent_properties_registered) do | |
+ client.property.set(c, p, c:get_xproperty("awful.client.property." .. prop)) | |
+ end | |
+ end | |
if client.data.properties[c] then | |
return client.data.properties[c][prop] | |
end | |
@@ -882,10 +891,26 @@ function client.property.set(c, prop, value) | |
if not client.data.properties[c] then | |
client.data.properties[c] = {} | |
end | |
+ if client.data.persistent_properties_registered[prop] then | |
+ c:set_xproperty("awful.client.property." .. prop, value) | |
+ end | |
client.data.properties[c][prop] = value | |
c:emit_signal("property::" .. prop) | |
end | |
+function client.property.persist(c, prop, type) | |
+ local prop = "awful.client.property." .. prop | |
+ capi.awesome.register_xproperty(prop, type) | |
+ client.data.persistent_properties_registered[prop] = true | |
+ | |
+ -- Make already-set properties persistent | |
+ for c, tab in pairs(client.data.properties) do | |
+ for p, val in pairs(tab) do | |
+ c:set_xproperty(prop, val) | |
+ end | |
+ end | |
+end | |
+ | |
--- | |
-- Returns an iterator to cycle through, starting from the client in focus or | |
-- the given index, all clients that match a given criteria. | |
@@ -960,6 +985,9 @@ capi.client.connect_signal("unmanage", client.urgent.delete) | |
capi.client.connect_signal("unmanage", client.floating.delete) | |
+-- Register persistent properties | |
+client.property.persist(c, "floating", "boolean") | |
+ | |
return client | |
-- vim: filetype=lua:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:textwidth=80 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment