/*
* ion/ioncore/mplex.c
*
- * Copyright (c) Tuomo Valkonen 1999-2008.
+ * Copyright (c) Tuomo Valkonen 1999-2009.
*
* See the included file LICENSE for details.
*/
}
-static WStacking *mplex_do_to_focus(WMPlex *mplex, WStacking *to_try,
- PtrList **hidelist)
-{
- return mplex_find_to_focus(mplex, to_try, NULL, hidelist);
-}
-
-
static WStacking *mplex_do_to_focus_on(WMPlex *mplex, WStacking *node,
WStacking *to_try,
PtrList **hidelist, bool *within)
}
}
- st=mplex_do_to_focus(mplex, node, hidelist);
+ st=mplex_find_to_focus(mplex, node, NULL, hidelist);
+
+ /* If 'node' points to a group, it isn't actually on the stacking list.
+ * Give it the focus, if there's nothing "proper" that could be focussed.
+ */
+ if(st==NULL && grp!=NULL && REGION_IS_MAPPED(grp))
+ st=node;
if(st==node && within!=NULL)
*within=TRUE;
}
+/* 1. Try keep focus in REGION_ACTIVE_SUB.
+ * 2. Choose something else, attempting previous in focus history.
+ */
static WStacking *mplex_to_focus(WMPlex *mplex)
{
- WStacking *to_try=NULL;
+ WStacking *foc=NULL, *fallback=NULL;
WRegion *reg=NULL;
- WStacking *st;
- to_try=maybe_focusable(REGION_ACTIVE_SUB(mplex));
+ foc=maybe_focusable(REGION_ACTIVE_SUB(mplex));
- if(to_try==NULL){
- /* Search focus history */
+ if(foc==NULL){
+ /* Search focus history if no specific attempt set.*/
for(reg=ioncore_g.focus_current; reg!=NULL; reg=reg->active_next){
- to_try=has_stacking_within(mplex, reg);
- if(to_try!=NULL)
+ foc=has_stacking_within(mplex, reg);
+ if(foc!=NULL)
break;
}
}
- st=mplex_do_to_focus(mplex, to_try, NULL);
-
- return (st!=NULL
- ? st
- : (mplex->mx_current!=NULL
- ? mplex->mx_current->st
- : NULL));
+ if(foc!=NULL){
+ /* In the history search case, 'foc' might point to a group,
+ * since we don't properly try to find a stacking within it...
+ */
+ return mplex_do_to_focus_on(mplex, foc, NULL, NULL, NULL);
+ }else{
+ return mplex_find_to_focus(mplex, NULL, NULL, NULL);
+ }
}
if(!MPLEX_MGD_UNVIEWABLE(mplex)){
WStacking *st=mplex_to_focus(mplex);
+ if(st==NULL){
+ st=(mplex->mx_current!=NULL
+ ? mplex->mx_current->st
+ : NULL);
+ }
+
if(st!=NULL){
region_do_set_focus(st->reg, warp);
return;
}
+static void mplex_refocus(WMPlex *mplex, WStacking *node, bool warp)
+{
+ bool within=FALSE;
+ WStacking *foc=NULL;
+
+ if(node!=NULL)
+ foc=mplex_do_to_focus_on(mplex, node, NULL, NULL, &within);
+
+ if(foc==NULL || !within)
+ foc=mplex_to_focus(mplex);
+
+ if(foc!=NULL)
+ region_maybewarp(foc->reg, warp);
+}
+
+
/*}}}*/
}
-static bool mplex_refocus(WMPlex *mplex, WStacking *node, bool warp)
-{
- WStacking *foc=NULL;
- bool within=FALSE;
-
- if(node!=NULL)
- foc=mplex_do_to_focus_on(mplex, node, NULL, NULL, &within);
-
- if(foc==NULL || !within)
- foc=mplex_to_focus(mplex);
-
- if(foc!=NULL)
- region_maybewarp(foc->reg, warp);
-
- return within;
-}
-
-
bool mplex_do_prepare_focus(WMPlex *mplex, WStacking *node,
WStacking *sub, int flags,
WPrepareFocusResult *res)