From 329e9d54ab727548ed4e68a51a41f57d63b95492 Mon Sep 17 00:00:00 2001 From: Michael Grant Date: Fri, 7 Nov 2025 11:43:41 +0100 Subject: [PATCH] Add support for clicking on a floating pane border to make it active. Including bugfix to click bottom border of floating panes. --- cmd-resize-pane.c | 2 ++ cmd-select-pane.c | 4 ++++ key-bindings.c | 3 +++ server-client.c | 8 +++++--- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cmd-resize-pane.c b/cmd-resize-pane.c index f34062a0..75ef9e0f 100644 --- a/cmd-resize-pane.c +++ b/cmd-resize-pane.c @@ -86,6 +86,8 @@ cmd_resize_pane_exec(struct cmd *self, struct cmdq_item *item) c->tty.mouse_drag_update = cmd_resize_pane_mouse_update_tiled; cmd_resize_pane_mouse_update_tiled(c, &event->m); } else { + window_redraw_active_switch(w, c->tty.mouse_wp); + window_set_active_pane(w, c->tty.mouse_wp, 1); c->tty.mouse_drag_update = cmd_resize_pane_mouse_update_floating; cmd_resize_pane_mouse_update_floating(c, &event->m); } diff --git a/cmd-select-pane.c b/cmd-select-pane.c index 3cabe07e..b0138893 100644 --- a/cmd-select-pane.c +++ b/cmd-select-pane.c @@ -160,6 +160,10 @@ cmd_select_pane_exec(struct cmd *self, struct cmdq_item *item) server_redraw_window_borders(markedwp->window); server_status_window(markedwp->window); } + if (wp->layout_cell == NULL) { + window_redraw_active_switch(w, wp); + window_set_active_pane(w, wp, 1); + } return (CMD_RETURN_NORMAL); } diff --git a/key-bindings.c b/key-bindings.c index fb766a02..63305f2e 100644 --- a/key-bindings.c +++ b/key-bindings.c @@ -455,6 +455,9 @@ key_bindings_init(void) /* Mouse button 1 triple click on pane. */ "bind -n TripleClick1Pane { select-pane -t=; if -F '#{||:#{pane_in_mode},#{mouse_any_flag}}' { send -M } { copy-mode -H; send -X select-line; run -d0.3; send -X copy-pipe-and-cancel } }", + /* Mouse button 1 on border. */ + "bind -n MouseDown1Border { select-pane -M }", + /* Mouse button 1 drag on border. */ "bind -n MouseDrag1Border { resize-pane -M }", diff --git a/server-client.c b/server-client.c index 60a6ddb3..7be6babd 100644 --- a/server-client.c +++ b/server-client.c @@ -606,7 +606,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, u_int px, u_int py, sb_pad = 0; } /* xxxx isn't this only for tiled panes at the top or bottom of the window? */ - if (pane_status == PANE_STATUS_TOP) + if (pane_status == PANE_STATUS_TOP && wp->layout_cell != NULL) line = wp->yoff - 1; else if (pane_status == PANE_STATUS_BOTTOM) line = wp->yoff + wp->sy; @@ -639,8 +639,10 @@ server_client_check_mouse_in_pane(struct window_pane *wp, u_int px, u_int py, } else /* py > sl_bottom */ return (SCROLLBAR_DOWN); } else if (wp->layout_cell == NULL && - ((int)px == wp->xoff - 1 || (int)py == wp->yoff -1)) { - /* Floating pane left or top border. */ + ((int)px == wp->xoff - 1 || + (int)py == wp->yoff -1 || + (int)py == wp->yoff + (int)wp->sy)) { + /* Floating pane left, bottom or top border. */ return (BORDER); } else { /* Must be inside the pane. */