2 -- ion/share/ioncore_winprops.lua
4 -- Copyright (c) Tuomo Valkonen 2004-2007.
6 -- See the included file LICENSE for details.
9 local ioncore=_G.ioncore
13 local function ifnil(...)
15 local function nxt(_, i)
32 local function ipairs_r(tab)
33 local function nxt(_, n)
40 return nxt, nil, #tab+1
44 -- Find winprop table for \var{cwin}.
45 function ioncore.getwinprop(cwin)
46 local id=cwin:get_ident()
49 for _, c in ifnil(id.class, "*") do
50 for _, r in ifnil(id.role, "*") do
51 for _, i in ifnil(id.instance, "*") do
54 pcall(function() props=winprops[c][r][i] or {} end)
55 for idx, prop in ipairs_r(props) do
56 if prop:match(cwin, id) then
58 table.remove(props, idx)
68 ioncore.set{_get_winprop=ioncore.getwinprop}
70 local function ensure_winproptab(class, role, instance)
71 if not winprops[class] then
74 if not winprops[class][role] then
75 winprops[class][role]={}
77 if not winprops[class][role][instance] then
78 winprops[class][role][instance]={}
82 local function do_add_winprop(class, role, instance, prop)
83 ensure_winproptab(class, role, instance)
84 table.insert(winprops[class][role][instance], prop)
89 -- The basic name-based winprop matching criteria.
90 function ioncore.match_winprop_dflt(prop, cwin, id)
91 local function chkf(p, i)
95 return (p==(i and true))
100 if not chkf(prop.is_transient, id.is_transient) then
104 if not chkf(prop.is_dockapp, id.is_dockapp) then
111 local st, en=string.find(nm, prop.name)
123 -- Define a winprop. For more information, see section \ref{sec:winprops}.
124 function ioncore.defwinprop(list)
126 local class, role, instance = "*", "*", "*"
128 for k, v in pairs(list) do
131 elseif k == "role" then
133 elseif k == "instance" then
139 if not list2.match then
140 list2.match=ioncore.match_winprop_dflt
143 do_add_winprop(class, role, instance, list2)