>> i think it would be a good idea to match a winprop structure
>> against a window's name as well (in addition to class/instance/role).
>Just write a new version of get_winprop (in ioncorelib.lua) that uses
>region_name. string.find can be used for regex mathces (simpler
>Lua-specific regexes, not POSIX; refer to the Lua manual).
Ok, here it comes. Attached are two diff's for
ioncore/clientwin.c and shared/ioncorelib.lua.
They are based on ion-devel-20030627.
You now can add an item name="regexp" to a winprop structure.
The winprop is used for a client if the client's name (WM_NAME)
matches the regular expression "regex" (and class/instance/role
as usual).
An identical class/instance/role might have several name
statements. The "search order" for matching the regular
expressions is undefined (i think the winprop defined
last is the first one to be seareched).
Regards,
Felix.
clientwin.c diff
================
*** ion-devel-20030627/ioncore/clientwin.c Sat Jun 21 12:56:53 2003
--- ion-devel-20030627_p/ioncore/clientwin.c Fri Aug 1 10:13:27 2003
***************
*** 1051,1062 ****
EXTL_EXPORT
ExtlTab clientwin_get_ident(WClientWin *cwin)
{
! char **p=NULL, *wrole=NULL;
! int n=0, n2=0, tmp=0;
ExtlTab tab;
p=get_text_property(cwin->win, XA_WM_CLASS, &n);
wrole=get_string_property(cwin->win, wglobal.atom_wm_window_role, &n2);
tab=extl_create_table();
if(n>=2 && p[1]!=NULL)
--- 1051,1063 ----
EXTL_EXPORT
ExtlTab clientwin_get_ident(WClientWin *cwin)
{
! char **p=NULL, *wrole=NULL, *wname=NULL;
! int n=0, n2=0, n3=0, tmp=0;
ExtlTab tab;
p=get_text_property(cwin->win, XA_WM_CLASS, &n);
wrole=get_string_property(cwin->win, wglobal.atom_wm_window_role, &n2);
+ wname=get_string_property(cwin->win, XA_WM_NAME, &n3);
tab=extl_create_table();
if(n>=2 && p[1]!=NULL)
***************
*** 1065,1070 ****
--- 1066,1073 ----
extl_table_sets_s(tab, "instance", p[0]);
if(wrole!=NULL)
extl_table_sets_s(tab, "role", wrole);
+ if(wname!=NULL)
+ extl_table_sets_s(tab, "name", wname);
if(p!=NULL)
XFreeStringList(p);
ioncorelib.lua diff:
====================
*** ion-devel-20030627/share/ioncorelib.lua Fri Jun 27 20:40:23 2003
--- ion-devel-20030627_p/share/ioncorelib.lua Fri Aug 1 11:10:08 2003
***************
*** 253,265 ****
-- Find winprop table for \var{cwin}.
function get_winprop(cwin)
local id=clientwin_get_ident(cwin)
! local prop
!
for c, r, i in alternative_winprop_idents(id) do
! if pcall(function() prop=winprops[c][r][i] end) then
! if prop then
! return prop
! end
end
end
end
--- 253,272 ----
-- Find winprop table for \var{cwin}.
function get_winprop(cwin)
local id=clientwin_get_ident(cwin)
! local names
!
for c, r, i in alternative_winprop_idents(id) do
! if pcall(function() names=winprops[c][r][i] end) then
! if names then
! for name in names do
! match=string.find(id.name, name)
! if match then
! return winprops[c][r][i][name]
! end
! end
! -- no regexp match, use default winprop
! return winprops[c][r][i][" ! "]
! end
end
end
end
***************
*** 271,301 ****
if not winprops[class][role] then
winprops[class][role]={}
end
end
! local function do_add_winprop(class, role, instance, props)
ensure_winproptab(class, role, instance)
! winprops[class][role][instance]=props
end
--DOC
-- Define a winprop. For more information, see section \ref{sec:winprops}.
function winprop(list)
! local list2, class, role, instance = {}, "*", "*", "*"
!
! for k, v in list do
! if k == "class" then
! class = v
! elseif k == "role" then
! role = v
! elseif k == "instance" then
! instance = v
! else
! list2[k] = v
! end
end
! do_add_winprop(class, role, instance, list2)
end
-- }}}
--- 278,313 ----
if not winprops[class][role] then
winprops[class][role]={}
end
+ if not winprops[class][role][instance] then
+ winprops[class][role][instance]={}
+ end
end
! function do_add_winprop(class, role, instance, name, props)
ensure_winproptab(class, role, instance)
! winprops[class][role][instance][name]=props
end
--DOC
-- Define a winprop. For more information, see section \ref{sec:winprops}.
function winprop(list)
! local list2, class, role, instance, name = {}, "*", "*", "*", " ! "
!
! for k, v in list do
! if k == "class" then
! class = v
! elseif k == "role" then
! role = v
! elseif k == "instance" then
! instance = v
! elseif k == "name" then
! name = v
! else
! list2[k] = v
! end
end
! do_add_winprop(class, role, instance, name, list2)
end
-- }}}