/*
* 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
#include "common.h"
#include "attach.h"
#include "pholder.h"
+#include "focus.h"
bool pholder_init(WPHolder *ph)
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));
}
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
};