/*
* ion/ioncore/region.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
#include "extlconv.h"
#include "activity.h"
#include "region-iter.h"
+#include "return.h"
#define D2(X)
WHook *region_notify_hook=NULL;
-static void region_notify_change_(WRegion *reg, const char *how,
- Obj *detail);
+
+static void region_notify_change_(WRegion *reg, WRegionNotify how);
/*{{{ Init & deinit */
reg->rootwin=((WRegion*)par)->rootwin;
region_set_parent(reg, par);
}else{
- assert(OBJ_IS(reg, WRootWin));/* || OBJ_IS(reg, WScreen));*/
+ assert(OBJ_IS(reg, WRootWin));
}
}
void region_deinit(WRegion *reg)
{
+ region_notify_change(reg, ioncore_g.notifies.deinit);
+
destroy_children(reg);
if(ioncore_g.focus_next==reg){
}
region_detach_manager(reg);
+ region_unset_return(reg);
region_unset_parent(reg);
region_remove_bindings(reg);
/*{{{ Manager region dynfuns */
-void region_managed_activated(WRegion *mgr, WRegion *reg)
-{
- CALL_DYN(region_managed_activated, mgr, (mgr, reg));
-}
-
-
-void region_managed_inactivated(WRegion *mgr, WRegion *reg)
-{
- CALL_DYN(region_managed_inactivated, mgr, (mgr, reg));
-}
-
-
static bool region_managed_prepare_focus_default(WRegion *mgr, WRegion *reg,
int flags,
WPrepareFocusResult *res)
}
-void region_managed_notify(WRegion *mgr, WRegion *reg, const char *how)
+void region_managed_notify(WRegion *mgr, WRegion *reg, WRegionNotify how)
{
CALL_DYN(region_managed_notify, mgr, (mgr, reg, how));
}
static bool region_rqclose_default(WRegion *reg, bool relocate)
{
WPHolder *ph;
- bool refuse=TRUE;
+ bool refuse=TRUE, mcf;
if((!relocate && !region_may_destroy(reg)) ||
!region_manager_allows_destroying(reg)){
}
ph=region_get_rescue_pholder(reg);
+ mcf=region_may_control_focus(reg);
if(ph!=NULL){
refuse=!region_rescue_clientwins(reg, ph);
return FALSE;
}
- mainloop_defer_destroy((Obj*)reg);
+ region_dispose(reg, mcf);
return TRUE;
}
}
+void region_dispose(WRegion *reg, bool was_mcf)
+{
+ if(was_mcf){
+ WPHolder *ph=region_get_return(reg);
+ if(ph!=NULL)
+ pholder_goto(ph);
+ }
+
+ mainloop_defer_destroy((Obj*)reg);
+}
+
+
+void region_dispose_(WRegion *reg)
+{
+ region_dispose(reg, region_may_control_focus(reg));
+}
+
+
/*}}}*/
if(mgr==NULL)
return;
+#if 0
/* Restore activity state to non-parent manager */
if(region_may_control_focus(reg)){
WRegion *par=REGION_PARENT_REG(reg);
* be made to work.
*/
par->active_sub=mgr;
- /*if(region_xwindow(mgr)!=None){*/
- region_do_set_focus(mgr, FALSE);
- /*}*/
+ region_maybewarp_now(mgr, FALSE);
}
}
+#endif
region_set_activity(reg, SETPARAM_UNSET);
}
+void region_unset_manager_pseudoactivity(WRegion *reg)
+{
+ WRegion *mgr=reg->manager, *par=REGION_PARENT_REG(reg);
+
+ if(mgr==NULL || mgr==par || !REGION_IS_PSEUDOACTIVE(mgr))
+ return;
+
+ mgr->flags&=~REGION_PSEUDOACTIVE;
+
+ region_notify_change(mgr, ioncore_g.notifies.pseudoinactivated);
+
+ region_unset_manager_pseudoactivity(mgr);
+}
+
+
+void region_set_manager_pseudoactivity(WRegion *reg)
+{
+ WRegion *mgr=reg->manager, *par=REGION_PARENT_REG(reg);
+
+ if(!REGION_IS_ACTIVE(reg) && !REGION_IS_PSEUDOACTIVE(reg))
+ return;
+
+ if(mgr==NULL || mgr==par || REGION_IS_PSEUDOACTIVE(mgr))
+ return;
+
+ mgr->flags|=REGION_PSEUDOACTIVE;
+
+ region_notify_change(mgr, ioncore_g.notifies.pseudoactivated);
+
+ region_set_manager_pseudoactivity(mgr);
+}
+
+
/* This should only be called within region_managed_remove,
* _after_ any managed lists and other essential structures
* of mgr have been broken.
{
if(reg->manager!=mgr)
return;
+
+ region_notify_change_(reg, ioncore_g.notifies.unset_manager);
+
+ region_unset_manager_pseudoactivity(reg);
reg->manager=NULL;
if(region_is_activity_r(reg))
region_clear_mgd_activity(mgr);
-
- region_notify_change_(reg, "unset_manager", (Obj*)mgr);
+
+ region_unset_return(reg);
}
reg->manager=mgr;
+ region_set_manager_pseudoactivity(reg);
+
if(region_is_activity_r(reg))
region_mark_mgd_activity(mgr);
- region_notify_change_(reg, "set_manager", (Obj*)mgr);
+ region_notify_change_(reg, ioncore_g.notifies.set_manager);
}
}
-static bool mrsh_not(WHookDummy *fn, void *p)
+typedef struct{
+ WRegion *reg;
+ WRegionNotify how;
+} MRSHP;
+
+
+static bool mrsh_notify_change(WHookDummy *fn, void *p_)
{
- WRegion *reg=(WRegion*)((void**)p)[0];
- const char *how=(const char*)((void**)p)[1];
- Obj *detail=(Obj*)((void**)p)[2];
+ MRSHP *p=(MRSHP*)p_;
- fn(reg, how, detail);
+ fn(p->reg, p->how);
return TRUE;
}
-static bool mrshe_not(ExtlFn fn, void *p)
+static bool mrshe_notify_change(ExtlFn fn, void *p_)
{
- WRegion *reg=(WRegion*)((void**)p)[0];
- const char *how=(const char*)((void**)p)[1];
- Obj *detail=(Obj*)((void**)p)[2];
+ MRSHP *p=(MRSHP*)p_;
- extl_call(fn, "oso", NULL, reg, how, detail);
+ extl_call(fn, "os", NULL, p->reg, stringstore_get(p->how));
return TRUE;
}
-static void region_notify_change_(WRegion *reg, const char *how,
- Obj *detail)
+static void region_notify_change_(WRegion *reg, WRegionNotify how)
{
- const void *p[3];
+ MRSHP p;
+
+ p.reg=reg;
+ p.how=how;
- p[0]=reg;
- p[1]=how;
- p[2]=detail;
-
extl_protect(NULL);
- hook_call(region_notify_hook, p, mrsh_not, mrshe_not),
+ hook_call(region_notify_hook, &p, mrsh_notify_change, mrshe_notify_change),
extl_unprotect(NULL);
-
}
-void region_notify_change(WRegion *reg, const char *how)
+void region_notify_change(WRegion *reg, WRegionNotify how)
{
WRegion *mgr=REGION_MANAGER(reg);
if(mgr!=NULL)
region_managed_notify(mgr, reg, how);
- region_notify_change_(reg, how, NULL);
+ region_notify_change_(reg, how);
}