]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/ioncore_winprops.lua
Imported Upstream version 20090110
[ion3.git] / ioncore / ioncore_winprops.lua
index 333ff69a3667fd8073f6222dc9ee23f939d4e5c6..329448691c018d2078304949aec139103f49406e 100644 (file)
@@ -1,12 +1,9 @@
 --
 -- ion/share/ioncore_winprops.lua
 -- 
--- Copyright (c) Tuomo Valkonen 2004-2006.
+-- Copyright (c) Tuomo Valkonen 2004-2009.
 --
--- Ion is free software; you can redistribute it and/or modify it under
--- the terms of the GNU Lesser General Public License as published by
--- the Free Software Foundation; either version 2.1 of the License, or
--- (at your option) any later version.
+-- See the included file LICENSE for details.
 --
 
 local ioncore=_G.ioncore
@@ -14,6 +11,7 @@ local ioncore=_G.ioncore
 local winprops={}
 
 local function ifnil(...)
+    local arg={...}
     local n=#arg
     local function nxt(_, i)
         local j=i+1
@@ -56,7 +54,7 @@ function ioncore.getwinprop(cwin)
                 props={}
                 pcall(function() props=winprops[c][r][i] or {} end)
                 for idx, prop in ipairs_r(props) do
-                    if prop:match(cwin) then
+                    if prop:match(cwin, id) then
                         if prop.oneshot then
                             table.remove(props, idx)
                         end
@@ -68,7 +66,7 @@ function ioncore.getwinprop(cwin)
     end
 end
 
-ioncore.set_get_winprop_fn(ioncore.getwinprop)
+ioncore.set{_get_winprop=ioncore.getwinprop}
 
 local function ensure_winproptab(class, role, instance)
     if not winprops[class] then
@@ -82,7 +80,7 @@ local function ensure_winproptab(class, role, instance)
     end
 end    
 
-local function do_add_winprop(class, role, instance, name, prop)
+local function do_add_winprop(class, role, instance, prop)
     ensure_winproptab(class, role, instance)
     table.insert(winprops[class][role][instance], prop)
 end
@@ -90,16 +88,35 @@ end
 
 --DOC
 -- The basic name-based winprop matching criteria.
-function ioncore.match_winprop_name(prop, cwin)
-    local nm=cwin:name()
-    if not prop.name then
-        return true
-    elseif nm then
-        local st, en=string.find(nm, prop.name)
-        return (st and en)
-    else
+function ioncore.match_winprop_dflt(prop, cwin, id)
+    local function chkf(p, i)
+        if p==nil then
+            return true
+        else
+            return (p==(i and true or false)) 
+                           -- hack for nil i
+        end
+    end
+    
+    if not chkf(prop.is_transient, id.is_transient) then
+        return false
+    end
+    
+    if not chkf(prop.is_dockapp, id.is_dockapp) then
         return false
     end
+    
+    if prop.name then
+        local nm=cwin:name()
+        if nm then
+            local st, en=string.find(nm, prop.name)
+            return (st and en)
+        else
+            return false
+        end
+    end
+    
+    return true
 end
 
 
@@ -121,9 +138,9 @@ function ioncore.defwinprop(list)
     end
     
     if not list2.match then
-        list2.match=ioncore.match_winprop_name
+        list2.match=ioncore.match_winprop_dflt
     end
     
-    do_add_winprop(class, role, instance, name, list2)
+    do_add_winprop(class, role, instance, list2)
 end