2 -- ion/share/ioncore_winprops.lua
4 -- Copyright (c) Tuomo Valkonen 2004-2009.
6 -- See the included file LICENSE for details.
9 local ioncore
=_G
.ioncore
13 local function ifnil(...)
16 local function nxt(_
, i
)
33 local function ipairs_r(tab
)
34 local function nxt(_
, n
)
41 return nxt
, nil, #tab
+1
45 -- Find winprop table for \var{cwin}.
46 function ioncore
.getwinprop(cwin
)
47 local id
=cwin
:get_ident()
50 for _
, c
in ifnil(id
.class
, "*") do
51 for _
, r
in ifnil(id
.role
, "*") do
52 for _
, i
in ifnil(id
.instance
, "*") do
55 pcall(function() props
=winprops
[c
][r
][i
] or {} end)
56 for idx
, prop
in ipairs_r(props
) do
57 if prop
:match(cwin
, id
) then
59 table.remove(props
, idx
)
69 ioncore
.set
{_get_winprop
=ioncore
.getwinprop
}
71 local function ensure_winproptab(class
, role
, instance
)
72 if not winprops
[class
] then
75 if not winprops
[class
][role
] then
76 winprops
[class
][role
]={}
78 if not winprops
[class
][role
][instance
] then
79 winprops
[class
][role
][instance
]={}
83 local function do_add_winprop(class
, role
, instance
, prop
)
84 ensure_winproptab(class
, role
, instance
)
85 table.insert(winprops
[class
][role
][instance
], prop
)
90 -- The basic name-based winprop matching criteria.
91 function ioncore
.match_winprop_dflt(prop
, cwin
, id
)
92 local function chkf(p
, i
)
96 return (p
==(i
and true or false))
101 if not chkf(prop
.is_transient
, id
.is_transient
) then
105 if not chkf(prop
.is_dockapp
, id
.is_dockapp
) then
112 local st
, en
=string.find(nm
, prop
.name
)
124 -- Define a winprop. For more information, see section \ref{sec:winprops}.
125 function ioncore
.defwinprop(list
)
127 local class
, role
, instance
= "*", "*", "*"
129 for k
, v
in pairs(list
) do
132 elseif k
== "role" then
134 elseif k
== "instance" then
140 if not list2
.match
then
141 list2
.match
=ioncore
.match_winprop_dflt
144 do_add_winprop(class
, role
, instance
, list2
)