aboutsummaryrefslogtreecommitdiff
path: root/cmd.c
diff options
context:
space:
mode:
authornicm <nicm>2019-05-08 18:05:03 +0000
committernicm <nicm>2019-05-08 18:05:03 +0000
commita384245c5aa1b1be2a73d9b3318a4c0d5bfc5391 (patch)
treee3c600fc6eee93a34410bf28bb19abde751f1b09 /cmd.c
parent89db309e106cfdd901ab62243bc07f0b76ef41da (diff)
downloadrtmux-a384245c5aa1b1be2a73d9b3318a4c0d5bfc5391.tar.gz
rtmux-a384245c5aa1b1be2a73d9b3318a4c0d5bfc5391.tar.bz2
rtmux-a384245c5aa1b1be2a73d9b3318a4c0d5bfc5391.zip
Adjust how mouse targets are found so they always have a session, window
and pane.
Diffstat (limited to 'cmd.c')
-rw-r--r--cmd.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/cmd.c b/cmd.c
index a0ec6aa6..c81ed12d 100644
--- a/cmd.c
+++ b/cmd.c
@@ -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. */