mirror of
https://github.com/tmux/tmux.git
synced 2026-10-07 02:04:22 +00:00
Merge remote-tracking branch 'refs/remotes/tmux-openbsd/master'
* refs/remotes/tmux-openbsd/master: Small section missed from previous. Add modal panes, created currently with new-pane -O. There is one modal pane per window and it must be a floating pane. These are intended to replace popups. Currently a modal pane will unzoom a zoomed window and rezoom it when it is closed (a bit like modes do), but this is planned to change when we get an always-on-top flag.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* $OpenBSD: server-client.c,v 1.492 2026/07/15 10:38:31 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;
|
||||
@@ -1053,9 +1054,34 @@ have_event:
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
server_client_update_scrollbar_hover(c, type, px, py);
|
||||
|
||||
if (type == KEYC_TYPE_MOUSEDRAG && lwp != NULL) {
|
||||
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 {
|
||||
@@ -1067,8 +1093,10 @@ have_event:
|
||||
m->w = w->id;
|
||||
log_debug("mouse %u,%u on empty area", x, y);
|
||||
} else {
|
||||
loc = server_client_check_mouse_in_pane(wp, px, py,
|
||||
&sl_mpos);
|
||||
if (!modal_drag) {
|
||||
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);
|
||||
@@ -3083,16 +3111,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);
|
||||
}
|
||||
|
||||
@@ -3105,6 +3137,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;
|
||||
|
||||
Reference in New Issue
Block a user