call("pane:refocus", focus);
}
-bool pane_has_focus(struct pane *focus)
+bool do_pane_has_focus(struct pane *focus, struct pane *root)
{
/* Would pane_focus change anything */
struct pane *p = focus;
if (!p)
return False;
- for (; p->parent->parent->parent != p->parent->parent; p = p->parent)
+ /* We check down to the declared root, or to on1 above
+ * the global root. Where the focus of the global root
+ * is never matters.
+ */
+ for (;
+ p != root
+ && p->parent->parent->parent != p->parent->parent;
+ p = p->parent)
if (p->parent->focus != p)
return False;
return True;
void pane_close(struct pane *p safe);
bool pane_resize(struct pane *p safe, int x, int y, int w, int h);
void pane_focus(struct pane *p);
-bool pane_has_focus(struct pane *p);
+bool do_pane_has_focus(struct pane *p, struct pane *root);
+#define pane_has_focus(...) VFUNC(pane_has_focus, __VA_ARGS__)
+#define pane_has_focus1(p) do_pane_has_focus(p, NULL)
+#define pane_has_focus2(p,r) do_pane_has_focus(p, r)
void pane_damaged(struct pane *p, int type);
void pane_clone_children(struct pane *from, struct pane *to);
struct pane *pane_my_child(struct pane *p, struct pane *c);
static PyObject *Pane_has_focus(Pane *self safe, PyObject *args)
{
+ Pane *other = NULL;
+ int ret;
+
if (!pane_valid(self))
return NULL;
- if (pane_has_focus(self->pane)) {
+ ret = PyArg_ParseTuple(args, "|O!", &PaneType, &other);
+ if (ret <= 0)
+ return NULL;
+
+ if (pane_has_focus(self->pane, other ? other->pane : NULL)) {
Py_INCREF(Py_True);
return Py_True;
} else {
"Clone all children onto the target"},
{"take_focus", (PyCFunction)Pane_focus, METH_NOARGS,
"Claim the focus for this pane"},
- {"has_focus", (PyCFunction)Pane_has_focus, METH_NOARGS,
+ {"has_focus", (PyCFunction)Pane_has_focus, METH_VARARGS,
"Check if pane is focus of display"},
{"call", (void*)(PyCFunctionWithKeywords)Pane_call, METH_VARARGS|METH_KEYWORDS,
"Call a command from a pane"},