]> git.decadent.org.uk Git - ion3.git/blobdiff - ioncore/ioncore_winprops.lua
Imported Upstream version 20090110
[ion3.git] / ioncore / ioncore_winprops.lua
index c241d63b378a6247c7edec07ff5b9cdf78b80e67..329448691c018d2078304949aec139103f49406e 100644 (file)
@@ -1,12 +1,9 @@
 --
 -- ion/share/ioncore_winprops.lua
 -- 
--- Copyright (c) Tuomo Valkonen 2004-2007.
+-- 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
@@ -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,10 +88,25 @@ end
 
 --DOC
 -- The basic name-based winprop matching criteria.
-function ioncore.match_winprop_name(prop, cwin)
-    if not prop.name then
-        return true
-    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)
@@ -102,6 +115,8 @@ function ioncore.match_winprop_name(prop, cwin)
             return false
         end
     end
+    
+    return true
 end
 
 
@@ -123,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