I'm still thinking this through....
'home' must always be the pane where the command was found.
'focus' should be where the action happens.
Previously 'home' would always end up being a parent of 'focus' but
sometimes, particularly calls from popup to target, we want something else.
So allow the caller to set 'focus' to themselves and 'home' to where
to start looking for the command.
If either is home is not set, focuses it moved out to a leaf first.
This still seems a bit clumsy...
Signed-off-by: NeilBrown <neil@brown.name>
int key_handle(const struct cmd_info *ci)
{
struct cmd_info *vci = (struct cmd_info*)ci;
- struct pane *p = ci->focus;
+ struct pane *p;
int ret = 0;
if (ci->comm)
vci->hx = ci->x;
vci->hy = ci->y;
+ /* If 'home' is set, search from there, else search
+ * from focus
+ */
+ p = ci->home;
+ if (!p)
+ p = ci->focus;
+
while (ret == 0 && p) {
if (p->handle) {
vci->home = p;
static int __key_handle_focus(struct cmd_info *ci, int savepoint)
{
/* Handle this in the focus pane, so x,y are irrelevant */
- struct pane *p = ci->focus;
+ struct pane *p = ci->home;
+ if (!p)
+ p = ci->focus;
+ if (!p)
+ return -1;
ci->x = -1;
ci->y = -1;
while (p->focus) {
if (savepoint && p->pointer)
ci->mark = p->pointer;
}
- ci->focus = p;
+ if (!ci->home || !ci->focus)
+ ci->focus = p;
+ ci->home = p;
ci->comm = NULL;
return key_handle(ci);
}