Adjust how mouse targets are found so they always have a session, window

and pane.
This commit is contained in:
nicm
2019-05-08 18:05:03 +00:00
parent 89db309e10
commit a384245c5a
2 changed files with 17 additions and 8 deletions

17
cmd.c
View File

@ -510,17 +510,22 @@ cmd_mouse_window(struct mouse_event *m, struct session **sp)
{
struct session *s;
struct window *w;
struct winlink *wl;
if (!m->valid || m->s == -1 || m->w == -1)
if (!m->valid)
return (NULL);
if ((s = session_find_by_id(m->s)) == NULL)
if (m->s == -1 || (s = session_find_by_id(m->s)) == NULL)
return (NULL);
if ((w = window_find_by_id(m->w)) == NULL)
return (NULL);
if (m->w == -1)
wl = s->curw;
else {
if ((w = window_find_by_id(m->w)) == NULL)
return (NULL);
wl = winlink_find_by_window(&s->windows, w);
}
if (sp != NULL)
*sp = s;
return (winlink_find_by_window(&s->windows, w));
return (wl);
}
/* Get current mouse pane if any. */