Merge branch 'master' into command_parser

This commit is contained in:
Your Name
2026-07-16 21:26:42 +01:00
22 changed files with 650 additions and 139 deletions

View File

@@ -1,4 +1,4 @@
/* $OpenBSD: server-client.c,v 1.491 2026/07/14 19:07:03 nicm Exp $ */
/* $OpenBSD: server-client.c,v 1.494 2026/07/15 14:14:50 nicm Exp $ */
/*
* Copyright (c) 2009 Nicholas Marriott <nicholas.marriott@gmail.com>
@@ -871,6 +871,7 @@ server_client_check_mouse(struct client *c, struct key_event *event)
u_int x, y, sx, sy, px, py, n, sl_mpos = 0;
u_int b, bn;
int ignore = 0;
int modal_drag = 0;
key_code key;
struct timeval tv;
struct style_range *sr;
@@ -1029,46 +1030,73 @@ have_event:
* Not on status line. Adjust position and check for border, pane, or
* scrollbar.
*/
if (loc == KEYC_MOUSE_LOCATION_NOWHERE) {
if (c->tty.mouse_scrolling_flag) {
if (lwp != NULL) {
loc = KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER;
m->wp = lwp->id;
m->w = lwp->window->id;
}
} else {
px = x;
if (m->statusat == 0 && y >= m->statuslines)
py = y - m->statuslines;
else if (m->statusat > 0 && y >= (u_int)m->statusat)
py = m->statusat - 1;
else
py = y;
if (loc == KEYC_MOUSE_LOCATION_NOWHERE && c->tty.mouse_scrolling_flag) {
if (lwp != NULL) {
loc = KEYC_MOUSE_LOCATION_SCROLLBAR_SLIDER;
m->wp = lwp->id;
m->w = lwp->window->id;
}
} else if (loc == KEYC_MOUSE_LOCATION_NOWHERE) {
px = x;
if (m->statusat == 0 && y >= m->statuslines)
py = y - m->statuslines;
else if (m->statusat > 0 && y >= (u_int)m->statusat)
py = m->statusat - 1;
else
py = y;
tty_window_offset(&c->tty, &m->ox, &m->oy, &sx, &sy);
log_debug("mouse window @%u at %u,%u (%ux%u)",
w->id, m->ox, m->oy, sx, sy);
if (px > sx || py > sy) {
tty_window_offset(&c->tty, &m->ox, &m->oy, &sx, &sy);
log_debug("mouse window @%u at %u,%u (%ux%u)", w->id, m->ox,
m->oy, sx, sy);
if (px > sx || py > sy) {
server_client_update_scrollbar_hover(c, type, -1, -1);
return (KEYC_UNKNOWN);
}
px = px + m->ox;
py = py + m->oy;
if (w->modal != NULL &&
!window_pane_contains(w->modal, px, py)) {
if (lwp == w->modal &&
c->tty.mouse_drag_flag != 0 &&
(type == KEYC_TYPE_MOUSEDRAG ||
type == KEYC_TYPE_MOUSEUP)) {
modal_drag = 1;
wp = lwp;
loc = KEYC_MOUSE_LOCATION_PANE;
m->wp = wp->id;
m->w = wp->window->id;
} else {
server_client_update_scrollbar_hover(c, type,
-1, -1);
c->tty.mouse_drag_update = NULL;
c->tty.mouse_drag_release = NULL;
c->tty.mouse_drag_flag = 0;
c->tty.mouse_scrolling_flag = 0;
c->tty.mouse_slider_mpos = -1;
c->tty.mouse_last_pane = -1;
return (KEYC_UNKNOWN);
}
px = px + m->ox;
py = py + m->oy;
server_client_update_scrollbar_hover(c, type, px, py);
}
server_client_update_scrollbar_hover(c, type, px, py);
if (type == KEYC_TYPE_MOUSEDRAG && lwp != NULL) {
/* Use pane from last mouse event. */
wp = lwp;
} else {
/* Try inside the pane. */
wp = window_get_active_at(w, px, py);
if (modal_drag) {
/* Keep the drag with the modal pane. */
} else if (type == KEYC_TYPE_MOUSEDRAG && lwp != NULL) {
/* Use pane from last mouse event. */
wp = lwp;
} else {
/* Try inside the pane. */
wp = window_get_active_at(w, px, py);
}
if (wp == NULL) {
loc = KEYC_MOUSE_LOCATION_EMPTY;
m->w = w->id;
log_debug("mouse %u,%u on empty area", x, y);
} else {
if (!modal_drag) {
loc = server_client_check_mouse_in_pane(wp, px,
py, &sl_mpos);
}
if (wp == NULL)
return (KEYC_UNKNOWN);
loc = server_client_check_mouse_in_pane(wp, px, py,
&sl_mpos);
if (loc == KEYC_MOUSE_LOCATION_PANE) {
log_debug("mouse %u,%u on pane %%%u", x, y,
wp->id);
@@ -3058,16 +3086,20 @@ struct window_pane *
server_client_get_pane(struct client *c)
{
struct session *s = c->session;
struct window *w;
struct client_window *cw;
if (s == NULL)
return (NULL);
w = s->curw->window;
if (w->modal != NULL)
return (w->modal);
if (~c->flags & CLIENT_ACTIVEPANE)
return (s->curw->window->active);
cw = server_client_get_client_window(c, s->curw->window->id);
return (w->active);
cw = server_client_get_client_window(c, w->id);
if (cw == NULL)
return (s->curw->window->active);
return (w->active);
return (cw->pane);
}
@@ -3080,6 +3112,8 @@ server_client_set_pane(struct client *c, struct window_pane *wp)
if (s == NULL)
return;
if (wp->window->modal != NULL && wp != wp->window->modal)
return;
cw = server_client_add_client_window(c, s->curw->window->id);
cw->pane = wp;