X-Git-Url: https://git.decadent.org.uk/gitweb/?p=ion3.git;a=blobdiff_plain;f=ioncore%2Fmplex.c;h=5f0a87d3a5a8bd2cfe6786c42bd2ca32b977758c;hp=8af9148afc1084d3c287de7daea9b76bd9bac9ec;hb=HEAD;hpb=f869221ce49f0fb7cca48eee28daff8684305963 diff --git a/ioncore/mplex.c b/ioncore/mplex.c index 8af9148..5f0a87d 100644 --- a/ioncore/mplex.c +++ b/ioncore/mplex.c @@ -1,7 +1,7 @@ /* * ion/ioncore/mplex.c * - * Copyright (c) Tuomo Valkonen 1999-2007. + * Copyright (c) Tuomo Valkonen 1999-2009. * * See the included file LICENSE for details. */ @@ -646,13 +646,6 @@ WStacking *mplex_find_to_focus(WMPlex *mplex, } -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) @@ -672,7 +665,13 @@ static WStacking *mplex_do_to_focus_on(WMPlex *mplex, WStacking *node, } } - 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; @@ -699,30 +698,33 @@ static WStacking *has_stacking_within(WMPlex *mplex, WRegion *reg) } +/* 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); + } } @@ -731,6 +733,12 @@ void mplex_do_set_focus(WMPlex *mplex, bool warp) 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; @@ -741,6 +749,22 @@ void mplex_do_set_focus(WMPlex *mplex, bool warp) } +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); +} + + /*}}}*/ @@ -833,24 +857,6 @@ static void mplex_do_node_display(WMPlex *mplex, WStacking *node, } -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)