/*
* ion/ioncore/stacking.c
*
- * Copyright (c) Tuomo Valkonen 1999-2006.
+ * 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 <libtu/rb.h>
+#include <libtu/minmax.h>
#include "common.h"
#include "region.h"
st->szplcy=SIZEPOLICY_DEFAULT;
st->hidden=FALSE;
st->lnode=NULL;
+ st->pseudomodal=FALSE;
}
return st;
WStackingFilter *include_filt,
void *filt_data)
{
+ uint min_level=STACKING_LEVEL_BOTTOM;
WStacking *st=NULL;
- uint min_level=0;
if(stacking==NULL)
return STACKING_LEVEL_BOTTOM;
}
-WStacking *stacking_find_to_focus(WStacking *stacking, WStacking *to_try,
+WStacking *stacking_find_to_focus(WStacking *stacking,
+ WStacking *to_try,
WStackingFilter *include_filt,
WStackingFilter *approve_filt,
void *filt_data)
{
- WStacking *st=NULL;
- uint min_level=0;
+ uint min_level=STACKING_LEVEL_BOTTOM;
+ WStacking *st=NULL, *found=NULL;
if(stacking==NULL)
return NULL;
- min_level=stacking_min_level(stacking, include_filt, filt_data);
-
- if(to_try!=NULL && to_try->level>=min_level)
- return to_try;
-
st=stacking;
do{
st=st->prev;
+ if(st->reg==NULL)
+ continue;
+
+ if(st!=to_try && (st->reg->flags®ION_SKIP_FOCUS ||
+ !cf(include_filt, filt_data, st))){
+ /* skip */
+ continue;
+ }
+
if(st->level<min_level)
- break;
+ break; /* no luck */
- if(st->reg!=NULL
- && !(st->reg->flags®ION_SKIP_FOCUS)
- && cf(include_filt, filt_data, st)
- && cf(approve_filt, filt_data, st)){
+ if(st==to_try)
return st;
+
+ if(found==NULL && cf(approve_filt, filt_data, st)){
+ found=st;
+ if(to_try==NULL)
+ break;
}
+
+ if(st->level>=STACKING_LEVEL_MODAL1)
+ min_level=maxof(min_level, st->level);
}while(st!=stacking);
- return NULL;
+ return found;
}