2 * ion/mod_tiling/placement.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
9 #include <ioncore/common.h>
10 #include <ioncore/global.h>
11 #include <ioncore/clientwin.h>
12 #include <ioncore/attach.h>
13 #include <ioncore/manage.h>
14 #include <libextl/extl.h>
15 #include <ioncore/framep.h>
16 #include <ioncore/names.h>
17 #include "placement.h"
21 WHook
*tiling_placement_alt
=NULL
;
24 static WRegion
*find_suitable_target(WTiling
*ws
)
26 WRegion
*r
=tiling_current(ws
);
29 FOR_ALL_MANAGED_BY_TILING_UNSAFE(r
, ws
)
37 static bool placement_mrsh_extl(ExtlFn fn
, WTilingPlacementParams
*param
)
42 t
=extl_create_table();
44 mp
=manageparams_to_table(param
->mp
);
46 extl_table_sets_o(t
, "tiling", (Obj
*)param
->ws
);
47 extl_table_sets_o(t
, "reg", (Obj
*)param
->reg
);
48 extl_table_sets_t(t
, "mp", mp
);
53 ret
=extl_call(fn
, "t", "b", t
, &ret
);
59 extl_table_gets_o(t
, "res_frame", &tmp
);
61 param
->res_frame
=OBJ_CAST(tmp
, WFrame
);
62 ret
=(param
->res_frame
!=NULL
);
71 WPHolder
*tiling_prepare_manage(WTiling
*ws
, const WClientWin
*cwin
,
72 const WManageParams
*mp
, int priority
)
74 int cpriority
=MANAGE_PRIORITY_SUBX(priority
, MANAGE_PRIORITY_NORMAL
);
76 WTilingPlacementParams param
;
81 param
.reg
=(WRegion
*)cwin
;
85 ret
=hook_call_alt_p(tiling_placement_alt
, ¶m
,
86 (WHookMarshallExtl
*)placement_mrsh_extl
);
88 if(ret
&& param
.res_frame
!=NULL
&&
89 REGION_MANAGER(param
.res_frame
)==(WRegion
*)ws
){
91 target
=(WRegion
*)param
.res_frame
;
93 ph
=region_prepare_manage(target
, cwin
, mp
, cpriority
);
98 target
=find_suitable_target(ws
);
101 warn(TR("Ooops... could not find a region to attach client window "
102 "to on workspace %s."), region_name((WRegion
*)ws
));
106 return region_prepare_manage(target
, cwin
, mp
, cpriority
);