Slightly better logging for font loading
[notion/jeffpc.git] / mod_tiling / placement.c
blob45cb5d6b64406d03e189eef637975fdaa78ed001
1 /*
2 * ion/mod_tiling/placement.c
4 * Copyright (c) Tuomo Valkonen 1999-2009.
6 * See the included file LICENSE for details.
7 */
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"
18 #include "tiling.h"
21 WHook *tiling_placement_alt=NULL;
24 static WRegion *find_suitable_target(WTiling *ws)
26 WRegion *r=tiling_current(ws);
28 if(r==NULL){
29 FOR_ALL_MANAGED_BY_TILING_UNSAFE(r, ws)
30 break;
33 return r;
37 static bool placement_mrsh_extl(ExtlFn fn, WTilingPlacementParams *param)
39 ExtlTab t, mp;
40 bool ret=FALSE;
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);
50 extl_unref_table(mp);
52 extl_protect(NULL);
53 ret=extl_call(fn, "t", "b", t, &ret);
54 extl_unprotect(NULL);
56 if(ret){
57 Obj *tmp=NULL;
59 extl_table_gets_o(t, "res_frame", &tmp);
61 param->res_frame=OBJ_CAST(tmp, WFrame);
62 ret=(param->res_frame!=NULL);
65 extl_unref_table(t);
67 return ret;
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);
75 WRegion *target=NULL;
76 WTilingPlacementParams param;
77 WPHolder *ph;
78 bool ret;
80 param.ws=ws;
81 param.reg=(WRegion*)cwin;
82 param.mp=mp;
83 param.res_frame=NULL;
85 ret=hook_call_alt_p(tiling_placement_alt, &param,
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);
94 if(ph!=NULL)
95 return ph;
98 target=find_suitable_target(ws);
100 if(target==NULL){
101 warn(TR("Ooops... could not find a region to attach client window "
102 "to on workspace %s."), region_name((WRegion*)ws));
103 return NULL;
106 return region_prepare_manage(target, cwin, mp, cpriority);