/*
* ion/ioncore/group.c
*
- * Copyright (c) Tuomo Valkonen 1999-2007.
+ * Copyright (c) Tuomo Valkonen 1999-2009.
*
* See the included file LICENSE for details.
*/
}
-static bool group_refocus_(WGroup *ws, WStacking *st)
-{
- if(st!=ws->current_managed && st->reg!=NULL){
- if(region_may_control_focus((WRegion*)ws))
- region_set_focus(st->reg);
- else
- ws->current_managed=st;
- return TRUE;
- }
-
- return FALSE;
-}
-
-
static void group_do_set_focus(WGroup *ws, bool warp)
{
- WStacking *st=ws->current_managed;
-
- if(st==NULL || st->reg==NULL)
- st=find_to_focus(ws, NULL, TRUE);
+ WStacking *st=find_to_focus(ws, ws->current_managed, FALSE);
if(st!=NULL && st->reg!=NULL)
region_do_set_focus(st->reg, warp);
ws->managed_stdisp=NULL;
ws->bottom=NULL;
ws->managed_list=NULL;
+ ws->phs=NULL;
ws->dummywin=XCreateWindow(ioncore_g.dpy, par->win,
fp->g.x, fp->g.y, 1, 1, 0,
XDeleteContext(ioncore_g.dpy, ws->dummywin, ioncore_g.win_context);
XDestroyWindow(ioncore_g.dpy, ws->dummywin);
ws->dummywin=None;
-
+
+ while(ws->phs!=NULL)
+ grouppholder_do_unlink(ws->phs);
+
region_deinit(&ws->reg);
}
-
bool group_rescue_clientwins(WGroup *ws, WRescueInfo *info)
{
WGroupIterTmp tmp;
}
-static bool group_empty_for_bottom_stdisp(WGroup *ws)
+WPHolder *group_get_rescue_pholder_for(WGroup *ws,
+ WRegion *forwhat)
{
- WGroupIterTmp tmp;
- WStacking *st;
+ WGroupAttachParams ap=GROUPATTACHPARAMS_INIT;
+ WFramedParam fp=FRAMEDPARAM_INIT;
+ WPHolder *ph;
- FOR_ALL_NODES_IN_GROUP(ws, st, tmp){
- if(st!=ws->bottom && st!=ws->managed_stdisp)
- return FALSE;
- }
-
- return TRUE;
-}
-
+ ap.geom_set=TRUE;
+ ap.geom=REGION_GEOM(forwhat);
-static WRegion *group_managed_disposeroot(WGroup *ws, WRegion *reg)
-{
- if(group_bottom(ws)==reg){
- if(group_empty_for_bottom_stdisp(ws))
- return region_disposeroot((WRegion*)ws);
+ ap.geom_weak_set=1;
+
+ if(REGION_PARENT(forwhat)==REGION_PARENT(ws)){
+ ap.geom.x-=REGION_GEOM(ws).x;
+ ap.geom.y-=REGION_GEOM(ws).y;
+ }else{
+ ap.geom_weak=REGION_RQGEOM_WEAK_X|REGION_RQGEOM_WEAK_Y;
}
- return reg;
+ /* frame mode */
+ /*{
+ WFrame *frame=OBJ_CAST(forwhat, WFrame);
+ if(frame!=NULL)
+ fp.mode=frame->mode;
+ }*/
+
+ ph=(WPHolder*)create_grouppholder(ws, NULL, &ap);
+
+ return pholder_either((WPHolder*)create_framedpholder(ph, &fp), ph);
}
+
/*}}}*/
frame=OBJ_CAST(reg, WFrame);
if(frame!=NULL){
- WFrameMode m=frame_mode(frame);
- if(m==FRAME_MODE_TILED || m==FRAME_MODE_TILED_ALT)
+ if(framemode_unalt(frame_mode(frame))==FRAME_MODE_TILED)
frame_set_mode(frame, FRAME_MODE_FLOATING);
}
}
+static int group_must_focus(WGroup *ws, WStacking *st)
+{
+ WStacking *stacking=group_get_stacking(ws);
+
+ return (stacking!=NULL && stacking_must_focus(stacking, st));
+}
+
+
bool group_do_attach_final(WGroup *ws,
WRegion *reg,
const WGroupAttachParams *param)
? param->szplcy
: (param->bottom
? SIZEPOLICY_FULL_EXACT
- : SIZEPOLICY_UNCONSTRAINED));
-
- weak=(param->geom_weak_set
- ? param->geom_weak
- : (param->geom_set
- ? 0
- : REGION_RQGEOM_WEAK_ALL));
-
- if(param->geom_set)
- geom_group_to_parent(ws, ¶m->geom, &g);
- else
- g=REGION_GEOM(reg);
-
- /* If the requested geometry does not overlap the workspaces's geometry,
- * position request is never honoured.
- */
- if((g.x+g.w<=REGION_GEOM(ws).x) ||
- (g.x>=REGION_GEOM(ws).x+REGION_GEOM(ws).w)){
- weak|=REGION_RQGEOM_WEAK_X;
- }
-
- if((g.y+g.h<=REGION_GEOM(ws).y) ||
- (g.y>=REGION_GEOM(ws).y+REGION_GEOM(ws).h)){
- weak|=REGION_RQGEOM_WEAK_Y;
- }
+ : SIZEPOLICY_VISIBILITY_CONSTRAINED));
+
+ if(!param->whatever){
+ weak=(param->geom_weak_set
+ ? param->geom_weak
+ : (param->geom_set
+ ? 0
+ : REGION_RQGEOM_WEAK_ALL));
+
+ if(param->geom_set)
+ geom_group_to_parent(ws, ¶m->geom, &g);
+ else
+ g=REGION_GEOM(reg);
+
+ /* If the requested geometry does not overlap the workspaces's geometry,
+ * position request is never honoured.
+ */
+ if((g.x+g.w<=REGION_GEOM(ws).x) ||
+ (g.x>=REGION_GEOM(ws).x+REGION_GEOM(ws).w)){
+ weak|=REGION_RQGEOM_WEAK_X;
+ }
+
+ if((g.y+g.h<=REGION_GEOM(ws).y) ||
+ (g.y>=REGION_GEOM(ws).y+REGION_GEOM(ws).h)){
+ weak|=REGION_RQGEOM_WEAK_Y;
+ }
- if(weak&(REGION_RQGEOM_WEAK_X|REGION_RQGEOM_WEAK_Y) &&
- (szplcy==SIZEPOLICY_UNCONSTRAINED ||
- szplcy==SIZEPOLICY_FREE ||
- szplcy==SIZEPOLICY_FREE_GLUE /* without flags */)){
- /* TODO: use 'weak'? */
- group_calc_placement(ws, level, &g);
- }
+ if(weak&(REGION_RQGEOM_WEAK_X|REGION_RQGEOM_WEAK_Y) &&
+ (szplcy==SIZEPOLICY_UNCONSTRAINED ||
+ szplcy==SIZEPOLICY_VISIBILITY_CONSTRAINED ||
+ szplcy==SIZEPOLICY_FREE ||
+ szplcy==SIZEPOLICY_FREE_GLUE /* without flags */)){
+ /* TODO: use 'weak'? */
+ group_calc_placement(ws, level, &g);
+ }
- fp.g=REGION_GEOM(ws);
- fp.mode=REGION_FIT_EXACT;
+ fp.g=REGION_GEOM(ws);
+ fp.mode=REGION_FIT_EXACT;
- sizepolicy(&szplcy, reg, &g, weak, &fp);
+ sizepolicy(&szplcy, reg, &g, weak, &fp);
- if(rectangle_compare(&fp.g, ®ION_GEOM(reg))!=RECTANGLE_SAME)
- region_fitrep(reg, NULL, &fp);
+ if(rectangle_compare(&fp.g, ®ION_GEOM(reg))!=RECTANGLE_SAME)
+ region_fitrep(reg, NULL, &fp);
+ }
/* Add */
st=group_do_add_managed(ws, reg, level, szplcy);
group_do_set_bottom(ws, st);
/* Focus */
- sw=(param->switchto_set ? param->switchto : ioncore_g.switchto_new);
+ sw=((param->switchto_set ? param->switchto : ioncore_g.switchto_new)
+ ? st==find_to_focus(ws, st, FALSE)
+ : group_must_focus(ws, st));
- if(sw || st->level>=STACKING_LEVEL_MODAL1){
- WStacking *stf=find_to_focus(ws, st, FALSE);
-
- if(stf==st){
- /* Ok, the new region can be focused */
- group_refocus_(ws, stf);
- }
+ if(sw){
+ if(region_may_control_focus((WRegion*)ws))
+ region_set_focus(st->reg);
+ else
+ ws->current_managed=st;
+ }else if(region_is_fully_mapped(reg)){
+ region_pointer_focus_hack(reg);
}
-
+
return TRUE;
}
+static void group_attach_fp(WGroup *ws, const WGroupAttachParams *param,
+ WFitParams *fp)
+{
+ if(param->geom_set){
+ geom_group_to_parent(ws, ¶m->geom, &fp->g);
+ fp->mode=REGION_FIT_EXACT;
+ }else{
+ fp->g=REGION_GEOM(ws);
+ fp->mode=REGION_FIT_BOUNDS|REGION_FIT_WHATEVER;
+ }
+}
+
+
WRegion *group_do_attach(WGroup *ws,
/*const*/ WGroupAttachParams *param,
WRegionAttachData *data)
{
WFitParams fp;
- WWindow *par;
WRegion *reg;
if(ws->bottom!=NULL && param->bottom){
return NULL;
}
- par=REGION_PARENT(ws);
- assert(par!=NULL);
-
- if(param->geom_set){
- geom_group_to_parent(ws, ¶m->geom, &fp.g);
- fp.mode=REGION_FIT_EXACT;
- }else{
- fp.g=REGION_GEOM(ws);
- fp.mode=REGION_FIT_BOUNDS|REGION_FIT_WHATEVER;
- }
+ group_attach_fp(ws, param, &fp);
- return region_attach_helper((WRegion*) ws, par, &fp,
+ return region_attach_helper((WRegion*) ws, REGION_PARENT(ws), &fp,
(WRegionDoAttachFn*)group_do_attach_final,
/*(const WRegionAttachParams*)*/param, data);
/* ^^^^ doesn't seem to work. */
}
-static void get_params(WGroup *ws, ExtlTab tab, WGroupAttachParams *par)
+void group_get_attach_params(WGroup *ws, ExtlTab tab,
+ WGroupAttachParams *par)
{
int tmp;
+ bool tmpb;
char *tmps;
ExtlTab g;
if(extl_table_gets_i(tab, "level", &tmp)){
if(tmp>=0){
- par->level_set=STACKING_LEVEL_NORMAL;
+ par->level_set=1;
par->level=tmp;
}
}
par->level_set=1;
}
- if(extl_table_is_bool_set(tab, "switchto"))
- par->switchto=1;
-
+ if(extl_table_gets_b(tab, "switchto", &tmpb)){
+ par->switchto=(tmpb!=0);
+ par->switchto_set=1;
+ }
+
if(extl_table_gets_i(tab, "sizepolicy", &tmp)){
par->szplcy_set=1;
par->szplcy=tmp;
if(reg==NULL)
return NULL;
- get_params(ws, param, &par);
+ group_get_attach_params(ws, param, &par);
data.type=REGION_ATTACH_REPARENT;
data.u.reg=reg;
WGroupAttachParams par=GROUPATTACHPARAMS_INIT;
WRegionAttachData data;
- get_params(ws, param, &par);
+ group_get_attach_params(ws, param, &par);
data.type=REGION_ATTACH_LOAD;
data.u.tab=param;
static int stdisp_szplcy(const WMPlexSTDispInfo *di, WRegion *stdisp)
{
int pos=di->pos;
+ int policy=0, gravity=0;
if(di->fullsize){
if(region_orientation(stdisp)==REGION_ORIENTATION_VERTICAL){
if(pos==MPLEX_STDISP_TL || pos==MPLEX_STDISP_BL)
- return SIZEPOLICY_STRETCH_LEFT;
+ policy=SIZEPOLICY_STRETCH_LEFT;
else
- return SIZEPOLICY_STRETCH_RIGHT;
+ policy=SIZEPOLICY_STRETCH_RIGHT;
}else{
if(pos==MPLEX_STDISP_TL || pos==MPLEX_STDISP_TR)
- return SIZEPOLICY_STRETCH_TOP;
+ policy=SIZEPOLICY_STRETCH_TOP;
else
- return SIZEPOLICY_STRETCH_BOTTOM;
+ policy=SIZEPOLICY_STRETCH_BOTTOM;
}
}else{
- if(pos==MPLEX_STDISP_TL)
- return SIZEPOLICY_GRAVITY_NORTHWEST;
- else if(pos==MPLEX_STDISP_BL)
- return SIZEPOLICY_GRAVITY_SOUTHWEST;
- else if(pos==MPLEX_STDISP_TR)
- return SIZEPOLICY_GRAVITY_NORTHEAST;
- else /*if(pos=MPLEX_STDISP_BR)*/
- return SIZEPOLICY_GRAVITY_SOUTHEAST;
+ policy=SIZEPOLICY_GRAVITY;
}
+
+ if(pos==MPLEX_STDISP_TL)
+ gravity=SIZEPOLICY_VERT_TOP|SIZEPOLICY_HORIZ_LEFT;
+ else if(pos==MPLEX_STDISP_BL)
+ gravity=SIZEPOLICY_VERT_BOTTOM|SIZEPOLICY_HORIZ_LEFT;
+ else if(pos==MPLEX_STDISP_TR)
+ gravity=SIZEPOLICY_VERT_TOP|SIZEPOLICY_HORIZ_RIGHT;
+ else /*if(pos=MPLEX_STDISP_BR)*/
+ gravity=SIZEPOLICY_VERT_BOTTOM|SIZEPOLICY_HORIZ_RIGHT;
+
+ return (policy|gravity);
}
stdisp->flags|=REGION_SKIP_FOCUS;
fp.g=REGION_GEOM(ws);
+ fp.mode=0;
+
sizepolicy(&ws->managed_stdisp->szplcy, stdisp, NULL, 0, &fp);
region_fitrep(stdisp, NULL, &fp);
fp.mode=REGION_FIT_EXACT;
}else{
fp.g=REGION_GEOM(ws);
+ fp.mode=0;
sizepolicy(&st->szplcy, reg, &rq->geom, rq->flags, &fp);
}
/*EXTL_DOC
* Iterate over managed regions of \var{ws} until \var{iterfn} returns
* \code{false}.
- * The function itself returns \code{true} if it reaches the end of list
+ * The function is called in protected mode.
+ * This routine returns \code{true} if it reaches the end of list
* without this happening.
*/
EXTL_SAFE
return tab;
}
-
+
void group_do_load(WGroup *ws, ExtlTab tab)
{
ExtlTab substab, subtab;
n=extl_table_get_n(substab);
for(i=1; i<=n; i++){
if(extl_table_geti_t(substab, i, &subtab)){
- group_attach_new(ws, subtab);
+ WGroupAttachParams par=GROUPATTACHPARAMS_INIT;
+ WRegionAttachData data;
+ WFitParams fp;
+ WPHolder *ph;
+
+ group_get_attach_params(ws, subtab, &par);
+ group_attach_fp(ws, &par, &fp);
+
+ ph=(WPHolder*)create_grouppholder(ws, NULL, &par);
+
+ region_attach_load_helper((WRegion*)ws, REGION_PARENT(ws), &fp,
+ (WRegionDoAttachFn*)group_do_attach_final,
+ (void*)&par, subtab, &ph);
+
+ if(ph!=NULL)
+ destroy_obj((Obj*)ph);
+
extl_unref_table(subtab);
}
}
{(DynFun*)region_get_configuration,
(DynFun*)group_get_configuration},
- {(DynFun*)region_managed_disposeroot,
- (DynFun*)group_managed_disposeroot},
-
{(DynFun*)region_current,
(DynFun*)group_current},
{(DynFun*)region_managed_rqorder,
(DynFun*)group_managed_rqorder},
+
+ {(DynFun*)region_get_rescue_pholder_for,
+ (DynFun*)group_get_rescue_pholder_for},
END_DYNFUNTAB
};