/*
* ion/ioncore/manage.c
*
- * Copyright (c) Tuomo Valkonen 1999-2007.
+ * Copyright (c) Tuomo Valkonen 1999-2008.
*
* See the included file LICENSE for details.
*/
if(r==NULL)
return NULL;
+ if(!region_same_rootwin(r, (WRegion*)cwin))
+ return NULL;
+
return region_prepare_manage(r, cwin, param, MANAGE_PRIORITY_NONE);
}
WRegion *get_rescue;
bool failed_get;
bool test;
+ int flags;
};
}
+WPHolder *rescueinfo_pholder(WRescueInfo *info)
+{
+ if(info->test)
+ return NULL;
+
+ if(info->ph==NULL){
+ info->ph=region_get_rescue_pholder(info->get_rescue);
+ if(info->ph==NULL){
+ info->failed_get=TRUE;
+ return NULL;
+ }
+ }
+
+ return info->ph;
+}
+
+
+/* Bah, unsplitissä oikestaan pitäisi tehä non-deep rescue */
+
+bool region_do_rescue_this(WRegion *tosave_, WRescueInfo *info, int ph_flags)
+{
+ WClientWin *cwin=OBJ_CAST(tosave_, WClientWin);
+ WRegion *tosave=NULL;
+
+ if(cwin!=NULL){
+ if(cwin->flags&CLIENTWIN_UNMAP_RQ)
+ return TRUE;
+ tosave=(WRegion*)cwin;
+ }else if(info->flags®ION_RESCUE_NODEEP){
+ tosave=tosave_;
+ }else{
+ /* Try to rescue whole groups. */
+ /*tosave=(WRegion*)OBJ_CAST(tosave_, WGroupCW);*/
+ }
+
+ if(tosave==NULL){
+ return region_rescue_clientwins(tosave_, info);
+ }else{
+ int phf=(info->flags®ION_RESCUE_PHFLAGS_OK ? ph_flags : 0);
+ WPHolder *ph=rescueinfo_pholder(info);
+
+ return (ph==NULL
+ ? FALSE
+ : pholder_attach(info->ph, phf, tosave));
+ }
+}
+
+
bool region_rescue_some_clientwins(WRegion *reg, WRescueInfo *info,
WRegionIterator *iter, void *st)
{
while(TRUE){
WRegion *tosave=iter(st);
- WClientWin *cwin;
if(tosave==NULL)
break;
-
- cwin=OBJ_CAST(tosave, WClientWin);
-
- if(cwin==NULL){
- if(!region_rescue_clientwins(tosave, info)){
- fails++;
- if(info->failed_get)
- break;
- }
- }else if(info->test){
+
+ if(!region_do_rescue_this(tosave, info, 0)){
fails++;
- break;
- }else if(!(cwin->flags&CLIENTWIN_UNMAP_RQ)){
- if(info->ph==NULL){
- info->ph=region_get_rescue_pholder(info->get_rescue);
- if(info->ph==NULL){
- info->failed_get=TRUE;
- break;
- }
- }
- if(!pholder_attach(info->ph, 0, (WRegion*)cwin))
- fails++;
+ if(info->failed_get)
+ break;
}
}
}
-bool region_rescue(WRegion *reg, WPHolder *ph_param)
+bool region_rescue(WRegion *reg, WPHolder *ph, int flags)
{
WRescueInfo info;
bool ret;
- info.ph=ph_param;
+ info.ph=ph;
+ info.flags=flags;
info.test=FALSE;
info.get_rescue=reg;
info.failed_get=FALSE;
ret=region_rescue_clientwins(reg, &info);
- if(info.ph!=ph_param)
+ if(info.ph!=ph)
destroy_obj((Obj*)info.ph);
return ret;
WRescueInfo info;
info.ph=NULL;
+ info.flags=0;
info.test=TRUE;
info.get_rescue=reg;
info.failed_get=FALSE;