/*
* ion/ioncore/pholder.c
*
- * Copyright (c) Tuomo Valkonen 2005-2006.
+ * Copyright (c) Tuomo Valkonen 2005-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/objp.h>
#include "common.h"
#include "attach.h"
#include "pholder.h"
+#include "focus.h"
bool pholder_init(WPHolder *ph)
}
-static WRegion *add_fn_reparent(WWindow *par, const WFitParams *fp,
- WRegion *reg)
-{
- if(!region_fitrep(reg, par, fp)){
- warn(TR("Unable to reparent."));
- return NULL;
- }
- region_detach_manager(reg);
- return reg;
-}
-
-
WRegion *pholder_attach_(WPHolder *ph, int flags, WRegionAttachData *data)
{
- if(ph->redirect!=NULL)
- return pholder_attach_(ph->redirect, flags, data);
- else
- return pholder_do_attach(ph, flags, data);
+ WPHolder *root=pholder_root(ph);
+
+ /* Use the root, so that extra containers are not added from
+ * stale chains.
+ */
+
+ return (root==NULL
+ ? NULL
+ : pholder_do_attach(root, flags, data));
}
}
+bool pholder_attach_mcfgoto(WPHolder *ph, int flags, WRegion *reg)
+{
+ bool cf=region_may_control_focus(reg);
+
+ if(!pholder_attach(ph, flags, reg))
+ return FALSE;
+
+ if(cf)
+ region_goto(reg);
+
+ return TRUE;
+}
+
+
WRegion *pholder_do_target(WPHolder *ph)
{
WRegion *ret=NULL;
WRegion *pholder_target(WPHolder *ph)
{
- if(ph->redirect!=NULL)
- return pholder_target(ph->redirect);
- else
- return pholder_do_target(ph);
+ return (ph->redirect!=NULL
+ ? pholder_target(ph->redirect)
+ : pholder_do_target(ph));
}
{
WRegion *target=pholder_do_target(ph);
- if(target==NULL)
- return FALSE;
- else
- return region_attach_reparent_check(target, reg);
+ return (target==NULL
+ ? FALSE
+ : region_ancestor_check(target, reg));
}
bool pholder_goto(WPHolder *ph)
{
- if(ph->redirect!=NULL)
- return pholder_goto(ph->redirect);
- else
- return pholder_do_goto(ph);
+ return (ph->redirect!=NULL
+ ? pholder_goto(ph->redirect)
+ : pholder_do_goto(ph));
}
+WPHolder *pholder_do_root_default(WPHolder *ph)
+{
+ return ph;
+}
+
+
+WPHolder *pholder_do_root(WPHolder *ph)
+{
+ WPHolder *ret=NULL;
+ CALL_DYN_RET(ret, WPHolder*, pholder_do_root, ph, (ph));
+ return ret;
+}
+
+
+WPHolder *pholder_root(WPHolder *ph)
+{
+ return (ph->redirect!=NULL
+ ? pholder_root(ph->redirect)
+ : pholder_do_root(ph));
+}
+
+
+bool pholder_stale(WPHolder *ph)
+{
+ return (pholder_root(ph)!=ph);
+}
+
bool pholder_redirect(WPHolder *ph, WRegion *old_target)
{
static DynFunTab pholder_dynfuntab[]={
{(DynFun*)pholder_do_check_reparent,
(DynFun*)pholder_do_check_reparent_default},
+
+ {(DynFun*)pholder_do_root,
+ (DynFun*)pholder_do_root_default},
END_DYNFUNTAB
};