mirror of
https://github.com/tmux/tmux.git
synced 2026-06-20 17:25:57 +00:00
Fix resizing floating pane with a left scrollbar, from Michael Grant.
This commit is contained in:
@@ -181,6 +181,7 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
|
||||
struct window_pane *wp;
|
||||
struct layout_cell *lc;
|
||||
int y, ly, x, lx, sx, sy, new_sx, new_sy;
|
||||
int scrollbars, sb_pos, left, right;
|
||||
int new_xoff, new_yoff, resizes = 0;
|
||||
|
||||
wp = cmd_mouse_pane(m, NULL, &wl);
|
||||
@@ -192,6 +193,17 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
|
||||
lc = wp->layout_cell;
|
||||
sx = wp->sx;
|
||||
sy = wp->sy;
|
||||
scrollbars = options_get_number(w->options, "pane-scrollbars");
|
||||
sb_pos = options_get_number(w->options, "pane-scrollbars-position");
|
||||
left = wp->xoff - 1;
|
||||
right = wp->xoff + sx;
|
||||
if (window_pane_show_scrollbar(wp, scrollbars) &&
|
||||
sb_pos == PANE_SCROLLBARS_LEFT) {
|
||||
left -= wp->scrollbar_style.width + wp->scrollbar_style.pad;
|
||||
} else if (window_pane_show_scrollbar(wp, scrollbars) &&
|
||||
sb_pos == PANE_SCROLLBARS_RIGHT) {
|
||||
right += wp->scrollbar_style.width + wp->scrollbar_style.pad;
|
||||
}
|
||||
|
||||
y = m->y + m->oy; x = m->x + m->ox;
|
||||
if (m->statusat == 0 && y >= (int)m->statuslines)
|
||||
@@ -204,7 +216,7 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
|
||||
else if (m->statusat > 0 && ly >= m->statusat)
|
||||
ly = m->statusat - 1;
|
||||
|
||||
if ((lx == wp->xoff - 1 || lx == wp->xoff) && ly == wp->yoff - 1) {
|
||||
if ((lx == left || lx == left + 1) && ly == wp->yoff - 1) {
|
||||
/* Top left corner. */
|
||||
new_sx = lc->sx + (lx - x);
|
||||
if (new_sx < PANE_MINIMUM)
|
||||
@@ -216,7 +228,7 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
|
||||
new_yoff = y + 1;
|
||||
layout_set_size(lc, new_sx, new_sy, new_xoff, new_yoff);
|
||||
resizes++;
|
||||
} else if ((lx == wp->xoff + sx + 1 || lx == wp->xoff + sx) &&
|
||||
} else if ((lx == right + 1 || lx == right) &&
|
||||
ly == wp->yoff - 1) {
|
||||
/* Top right corner. */
|
||||
new_sx = x - lc->xoff;
|
||||
@@ -228,7 +240,7 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
|
||||
new_yoff = y + 1;
|
||||
layout_set_size(lc, new_sx, new_sy, lc->xoff, new_yoff);
|
||||
resizes++;
|
||||
} else if ((lx == wp->xoff - 1 || lx == wp->xoff) &&
|
||||
} else if ((lx == left || lx == left + 1) &&
|
||||
ly == wp->yoff + sy) {
|
||||
/* Bottom left corner. */
|
||||
new_sx = lc->sx + (lx - x);
|
||||
@@ -240,7 +252,7 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
|
||||
new_xoff = x + 1;
|
||||
layout_set_size(lc, new_sx, new_sy, new_xoff, lc->yoff);
|
||||
resizes++;
|
||||
} else if ((lx == wp->xoff + sx + 1 || lx == wp->xoff + sx) &&
|
||||
} else if ((lx == right + 1 || lx == right) &&
|
||||
ly == wp->yoff + sy) {
|
||||
/* Bottom right corner. */
|
||||
new_sx = x - lc->xoff;
|
||||
@@ -251,14 +263,14 @@ cmd_resize_pane_mouse_update_floating(struct client *c, struct mouse_event *m)
|
||||
new_sy = PANE_MINIMUM;
|
||||
layout_set_size(lc, new_sx, new_sy, lc->xoff, lc->yoff);
|
||||
resizes++;
|
||||
} else if (lx == wp->xoff + sx + 1) {
|
||||
} else if (lx == right) {
|
||||
/* Right border. */
|
||||
new_sx = x - lc->xoff;
|
||||
if (new_sx < PANE_MINIMUM)
|
||||
return;
|
||||
layout_set_size(lc, new_sx, lc->sy, lc->xoff, lc->yoff);
|
||||
resizes++;
|
||||
} else if (lx == wp->xoff - 1) {
|
||||
} else if (lx == left) {
|
||||
/* Left border. */
|
||||
new_sx = lc->sx + (lx - x);
|
||||
if (new_sx < PANE_MINIMUM)
|
||||
|
||||
@@ -627,6 +627,9 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
|
||||
pane_status_line = wp->yoff + wp->sy;
|
||||
else
|
||||
pane_status_line = -1; /* not used */
|
||||
bdr_left = wp->xoff - 1;
|
||||
if (sb_pos == PANE_SCROLLBARS_LEFT)
|
||||
bdr_left -= sb_pad + sb_w;
|
||||
|
||||
/* Check if point is within the pane or scrollbar. */
|
||||
if (((pane_status != PANE_STATUS_OFF &&
|
||||
@@ -656,7 +659,7 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
|
||||
} else /* py > sl_bottom */
|
||||
return (KEYC_MOUSE_LOCATION_SCROLLBAR_DOWN);
|
||||
} else if (window_pane_is_floating(wp) &&
|
||||
(px == wp->xoff - 1 ||
|
||||
(px == bdr_left ||
|
||||
py == wp->yoff - 1 ||
|
||||
py == wp->yoff + (int)wp->sy)) {
|
||||
/* Floating pane left, bottom or top border. */
|
||||
@@ -671,11 +674,20 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
|
||||
if ((w->flags & WINDOW_ZOOMED) &&
|
||||
(~fwp->flags & PANE_ZOOMED))
|
||||
continue;
|
||||
if (window_pane_show_scrollbar(fwp, sb)) {
|
||||
sb_w = fwp->scrollbar_style.width;
|
||||
sb_pad = fwp->scrollbar_style.pad;
|
||||
} else {
|
||||
sb_w = 0;
|
||||
sb_pad = 0;
|
||||
}
|
||||
bdr_top = fwp->yoff - 1;
|
||||
bdr_bottom = fwp->yoff + fwp->sy;
|
||||
if (sb_pos == PANE_SCROLLBARS_LEFT)
|
||||
bdr_left = fwp->xoff - 1;
|
||||
if (sb_pos == PANE_SCROLLBARS_LEFT) {
|
||||
bdr_left -= sb_pad + sb_w;
|
||||
bdr_right = fwp->xoff + fwp->sx;
|
||||
else {
|
||||
} else {
|
||||
/* PANE_SCROLLBARS_RIGHT or none. */
|
||||
bdr_right = fwp->xoff + fwp->sx + sb_pad + sb_w;
|
||||
}
|
||||
@@ -685,13 +697,11 @@ server_client_check_mouse_in_pane(struct window_pane *wp, int px, int py,
|
||||
break;
|
||||
if (window_pane_is_floating(wp)) {
|
||||
/* Floating pane, check left border. */
|
||||
bdr_left = fwp->xoff - 1;
|
||||
if (px == bdr_left)
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (px >= fwp->xoff - 1 &&
|
||||
px <= fwp->xoff + (int)fwp->sx) {
|
||||
if (px >= bdr_left && px <= fwp->xoff + (int)fwp->sx) {
|
||||
bdr_bottom = fwp->yoff + fwp->sy;
|
||||
if (py == bdr_bottom)
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user