*
* Copyright (c) Tuomo Valkonen 1999-2007.
*
- * Ion is free software; you can redistribute it and/or modify it under
- * the terms of the GNU Lesser General Public License as published by
- * the Free Software Foundation; either version 2.1 of the License, or
- * (at your option) any later version.
+ * See the included file LICENSE for details.
*/
#include <string.h>
static void group_remanage_stdisp(WGroup *ws);
+static void group_do_set_bottom(WGroup *grp, WStacking *st);
+
/*{{{ Stacking list stuff */
}
-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);
st=group_find_stacking(ws, reg);
if(st!=NULL){
- next_st=stacking_unstack(REGION_PARENT(ws), st);
-
- UNLINK_ITEM(ws->managed_list, st, mgr_next, mgr_prev);
+ if(st==ws->bottom){
+ was_bottom=TRUE;
+ group_do_set_bottom(ws, NULL);
+ }
if(st==ws->managed_stdisp){
ws->managed_stdisp=NULL;
was_stdisp=TRUE;
}
-
- if(st==ws->bottom){
- ws->bottom=NULL;
- was_bottom=TRUE;
- }
if(st==ws->current_managed){
ws->current_managed=NULL;
was_current=TRUE;
}
+ next_st=stacking_unstack(REGION_PARENT(ws), st);
+ UNLINK_ITEM(ws->managed_list, st, mgr_next, mgr_prev);
stacking_unassoc(st);
stacking_free(st);
}
region_unset_manager(reg, (WRegion*)ws);
- if(!OBJ_IS_BEING_DESTROYED(ws)){
- if(was_bottom && !was_stdisp && ws->managed_stdisp==NULL){
- /* We should probably be managing any stdisp, that 'bottom'
- * was managing.
- */
- group_remanage_stdisp(ws);
- }
-
- if(was_current){
- /* This may still potentially cause problems when focus
- * change is pending. Perhaps we should use region_await_focus,
- * if it is pointing to our child (and region_may_control_focus
- * fail if it is pointing somewhere else).
- */
- WStacking *stf=find_to_focus(ws, next_st, TRUE);
- if(stf!=NULL && mcf){
- region_maybewarp_now(stf->reg, FALSE);
- }else{
- ws->current_managed=stf;
- }
+ if(!OBJ_IS_BEING_DESTROYED(ws) && was_current){
+ /* This may still potentially cause problems when focus
+ * change is pending. Perhaps we should use region_await_focus,
+ * if it is pointing to our child (and region_may_control_focus
+ * fail if it is pointing somewhere else).
+ */
+ WStacking *stf=find_to_focus(ws, next_st, TRUE);
+ if(stf!=NULL && mcf){
+ region_maybewarp_now(stf->reg, FALSE);
+ }else{
+ ws->current_managed=stf;
}
}
}
}
-static bool group_empty_for_bottom_stdisp(WGroup *ws)
-{
- WGroupIterTmp tmp;
- WStacking *st;
-
- FOR_ALL_NODES_IN_GROUP(ws, st, tmp){
- if(st!=ws->bottom && st!=ws->managed_stdisp)
- return FALSE;
- }
-
- return TRUE;
-}
-
-
-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);
- }
-
- return reg;
-}
-
-
/*}}}*/
/*{{{ Bottom */
+void group_bottom_set(WGroup *grp)
+{
+ CALL_DYN(group_bottom_set, grp, (grp));
+}
+
+
static void group_do_set_bottom(WGroup *grp, WStacking *st)
{
WStacking *was=grp->bottom;
+ WStacking *std=grp->managed_stdisp;
grp->bottom=st;
- if(st!=was){
- if(st==NULL || HAS_DYN(st->reg, region_manage_stdisp))
+ if(!OBJ_IS_BEING_DESTROYED(grp)){
+ bool noremanage=((was==st) ||
+ (was==NULL && std==NULL) ||
+ (st!=NULL && st==std) ||
+ (st==NULL && was==std));
+
+ if(!noremanage &&
+ (st==NULL || HAS_DYN(st->reg, region_manage_stdisp))){
group_remanage_stdisp(grp);
+ }
+ group_bottom_set(grp);
}
}
/*EXTL_DOC
- * Sets the 'bottom' of \var{ws}. The region \var{reg} must already
+ * Sets the `bottom' of \var{ws}. The region \var{reg} must already
* be managed by \var{ws}, unless \code{nil}.
*/
EXTL_EXPORT_MEMBER
/*EXTL_DOC
- * Returns the 'bottom' of \var{ws}.
+ * Returns the `bottom' of \var{ws}.
*/
EXTL_SAFE
EXTL_EXPORT_MEMBER
frame=OBJ_CAST(reg, WFrame);
if(frame!=NULL){
WFrameMode m=frame_mode(frame);
- if(m!=FRAME_MODE_FLOATING && m!=FRAME_MODE_TRANSIENT)
+ if(m==FRAME_MODE_TILED || m==FRAME_MODE_TILED_ALT)
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)
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;
}
return TRUE;
}
-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;
par->geom_set=0;
par->bottom=0;
- if(extl_table_gets_i(tab, "level", &tmp)){
- if(tmp>=0){
- par->level_set=STACKING_LEVEL_NORMAL;
- par->level=tmp;
- }
- }
-
if(extl_table_is_bool_set(tab, "bottom")){
par->level=STACKING_LEVEL_BOTTOM;
par->level_set=1;
par->bottom=1;
}
+ if(extl_table_gets_i(tab, "level", &tmp)){
+ if(tmp>=0){
+ par->level_set=1;
+ par->level=tmp;
+ }
+ }
+
if(!par->level_set && extl_table_is_bool_set(tab, "modal")){
par->level=STACKING_LEVEL_MODAL1;
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;
*
* \begin{tabularx}{\linewidth}{lX}
* \tabhead{Field & Description}
- * \var{type} & Class name (a string) of the object to be created. Mandatory. \\
- * \var{name} & Name of the object to be created (a string). Optional. \\
- * \var{switchto} & Should the region be switched to (boolean)? Optional. \\
- * \var{level} & Stacking level; default is 1. \\
- * \var{modal} & Make object modal; ignored if level is set. \\
- * \var{sizepolicy} & Size policy. \\
+ * \var{type} & (string) Class of the object to be created. Mandatory. \\
+ * \var{name} & (string) Name of the object to be created. \\
+ * \var{switchto} & (boolean) Should the region be switched to? \\
+ * \var{level} & (integer) Stacking level; default is 1. \\
+ * \var{modal} & (boolean) Make object modal; ignored if level is set. \\
+ * \var{sizepolicy} & (string) Size policy; see Section \ref{sec:sizepolicies}. \\
+ * \var{bottom} & (boolean) Mark the attached region as the
+ * ``bottom'' of \var{ws}. \\
* \end{tabularx}
*
* In addition parameters to the region to be created are passed in this
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);
}
STACKING_LEVEL_ON_TOP,
szplcy);
}
-
+
+ stdisp->flags|=REGION_SKIP_FOCUS;
+
fp.g=REGION_GEOM(ws);
sizepolicy(&ws->managed_stdisp->szplcy, stdisp, NULL, 0, &fp);
typedef WStacking *NxtFn(WGroup *ws, WStacking *st, bool wrap);
-static bool mapped_filt(WStacking *st, void *unused)
-{
- return (st->reg!=NULL && REGION_IS_MAPPED(st->reg));
-}
-
-
static bool focusable(WGroup *ws, WStacking *st, uint min_level)
{
return (st->reg!=NULL
stacking=group_get_stacking(ws);
if(stacking!=NULL)
- min_level=stacking_min_level(stacking, mapped_filt, NULL);
+ min_level=stacking_min_level_mapped(stacking);
st=sti;
while(1){
subtab=region_get_configuration(st->reg);
if(subtab!=extl_table_none()){
- extl_table_sets_i(subtab, "sizepolicy", st->szplcy);
+ extl_table_sets_s(subtab, "sizepolicy",
+ sizepolicy2string(st->szplcy));
extl_table_sets_i(subtab, "level", st->level);
tmpg=REGION_GEOM(st->reg);
{(DynFun*)region_get_configuration,
(DynFun*)group_get_configuration},
- {(DynFun*)region_managed_disposeroot,
- (DynFun*)group_managed_disposeroot},
-
{(DynFun*)region_current,
(DynFun*)group_current},