2 * ion/mod_tiling/placement.c
4 * Copyright (c) Tuomo Valkonen 1999-2007.
6 * Ion is free software; you can redistribute it and/or modify it under
7 * the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
12 #include <ioncore/common.h>
13 #include <ioncore/global.h>
14 #include <ioncore/clientwin.h>
15 #include <ioncore/attach.h>
16 #include <ioncore/manage.h>
17 #include <libextl/extl.h>
18 #include <ioncore/framep.h>
19 #include <ioncore/names.h>
20 #include "placement.h"
24 WHook *tiling_placement_alt=NULL;
27 static WRegion *find_suitable_target(WTiling *ws)
29 WRegion *r=tiling_current(ws);
32 FOR_ALL_MANAGED_BY_TILING_UNSAFE(r, ws)
40 static bool placement_mrsh_extl(ExtlFn fn, WTilingPlacementParams *param)
45 t=extl_create_table();
47 mp=manageparams_to_table(param->mp);
49 extl_table_sets_o(t, "tiling", (Obj*)param->ws);
50 extl_table_sets_o(t, "reg", (Obj*)param->reg);
51 extl_table_sets_t(t, "mp", mp);
56 ret=extl_call(fn, "t", "b", t, &ret);
62 extl_table_gets_o(t, "res_frame", &tmp);
64 param->res_frame=OBJ_CAST(tmp, WFrame);
65 ret=(param->res_frame!=NULL);
74 WPHolder *tiling_prepare_manage(WTiling *ws, const WClientWin *cwin,
75 const WManageParams *mp, int redir)
78 WTilingPlacementParams param;
82 if(redir==MANAGE_REDIR_STRICT_NO)
86 param.reg=(WRegion*)cwin;
90 ret=hook_call_alt_p(tiling_placement_alt, ¶m,
91 (WHookMarshallExtl*)placement_mrsh_extl);
93 if(ret && param.res_frame!=NULL &&
94 REGION_MANAGER(param.res_frame)==(WRegion*)ws){
96 target=(WRegion*)param.res_frame;
98 ph=region_prepare_manage(target, cwin, mp, redir);
103 target=find_suitable_target(ws);
106 warn(TR("Ooops... could not find a region to attach client window "
107 "to on workspace %s."), region_name((WRegion*)ws));
111 return region_prepare_manage(target, cwin, mp, redir);