mirror of
https://github.com/tmate-io/tmate.git
synced 2025-08-16 08:38:12 +02:00
Sync OpenBSD patchset 1015:
Add an option to move the status line to the top of the screen, requested by many.
This commit is contained in:
107
server-client.c
107
server-client.c
@ -26,6 +26,8 @@
|
||||
|
||||
#include "tmux.h"
|
||||
|
||||
void server_client_check_mouse(struct client *c,
|
||||
struct window_pane *wp, struct mouse_event *mouse);
|
||||
void server_client_handle_key(int, struct mouse_event *, void *);
|
||||
void server_client_repeat_timer(int, short, void *);
|
||||
void server_client_check_exit(struct client *);
|
||||
@ -261,6 +263,65 @@ server_client_status_timer(void)
|
||||
}
|
||||
}
|
||||
|
||||
/* Check for mouse keys. */
|
||||
void
|
||||
server_client_check_mouse(
|
||||
struct client *c, struct window_pane *wp, struct mouse_event *mouse)
|
||||
{
|
||||
struct session *s = c->session;
|
||||
struct options *oo = &s->options;
|
||||
int statusat;
|
||||
|
||||
statusat = status_at_line(c);
|
||||
|
||||
/* Is this a window selection click on the status line? */
|
||||
if (statusat != -1 && mouse->y == (u_int)statusat &&
|
||||
options_get_number(oo, "mouse-select-window")) {
|
||||
if (mouse->b == MOUSE_UP && c->last_mouse.b != MOUSE_UP) {
|
||||
status_set_window_at(c, mouse->x);
|
||||
return;
|
||||
}
|
||||
if (mouse->b & MOUSE_45) {
|
||||
if ((mouse->b & MOUSE_BUTTON) == MOUSE_1) {
|
||||
session_previous(c->session, 0);
|
||||
server_redraw_session(s);
|
||||
}
|
||||
if ((mouse->b & MOUSE_BUTTON) == MOUSE_2) {
|
||||
session_next(c->session, 0);
|
||||
server_redraw_session(s);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Not on status line - adjust mouse position if status line is at the
|
||||
* top and limit if at the bottom. From here on a struct mouse
|
||||
* represents the offset onto the window itself.
|
||||
*/
|
||||
if (statusat == 0 &&mouse->y > 0)
|
||||
mouse->y--;
|
||||
else if (statusat > 0 && mouse->y >= (u_int)statusat)
|
||||
mouse->y = statusat - 1;
|
||||
|
||||
/* Is this a pane selection? Allow down only in copy mode. */
|
||||
if (options_get_number(oo, "mouse-select-pane") &&
|
||||
((!(mouse->b & MOUSE_DRAG) && mouse->b != MOUSE_UP) ||
|
||||
wp->mode != &window_copy_mode)) {
|
||||
window_set_active_at(wp->window, mouse->x, mouse->y);
|
||||
server_redraw_window_borders(wp->window);
|
||||
wp = wp->window->active; /* may have changed */
|
||||
}
|
||||
|
||||
/* Check if trying to resize pane. */
|
||||
if (options_get_number(oo, "mouse-resize-pane"))
|
||||
layout_resize_pane_mouse(c, mouse);
|
||||
|
||||
/* Update last and pass through to client. */
|
||||
memcpy(&c->last_mouse, mouse, sizeof c->last_mouse);
|
||||
window_pane_mouse(wp, c->session, mouse);
|
||||
}
|
||||
|
||||
/* Handle data key input from client. */
|
||||
void
|
||||
server_client_handle_key(int key, struct mouse_event *mouse, void *data)
|
||||
@ -316,43 +377,7 @@ server_client_handle_key(int key, struct mouse_event *mouse, void *data)
|
||||
if (key == KEYC_MOUSE) {
|
||||
if (c->flags & CLIENT_READONLY)
|
||||
return;
|
||||
if (options_get_number(oo, "mouse-select-pane") &&
|
||||
(!(options_get_number(oo, "status") &&
|
||||
mouse->y + 1 == c->tty.sy)) &&
|
||||
((!(mouse->b & MOUSE_DRAG) && mouse->b != MOUSE_UP) ||
|
||||
wp->mode != &window_copy_mode)) {
|
||||
/*
|
||||
* Allow pane switching in copy mode only by mouse down
|
||||
* (click).
|
||||
*/
|
||||
window_set_active_at(w, mouse->x, mouse->y);
|
||||
server_redraw_window_borders(w);
|
||||
wp = w->active;
|
||||
}
|
||||
if (mouse->y + 1 == c->tty.sy &&
|
||||
options_get_number(oo, "mouse-select-window") &&
|
||||
options_get_number(oo, "status")) {
|
||||
if (mouse->b == MOUSE_UP &&
|
||||
c->last_mouse.b != MOUSE_UP) {
|
||||
status_set_window_at(c, mouse->x);
|
||||
return;
|
||||
}
|
||||
if (mouse->b & MOUSE_45) {
|
||||
if ((mouse->b & MOUSE_BUTTON) == MOUSE_1) {
|
||||
session_previous(c->session, 0);
|
||||
server_redraw_session(s);
|
||||
}
|
||||
if ((mouse->b & MOUSE_BUTTON) == MOUSE_2) {
|
||||
session_next(c->session, 0);
|
||||
server_redraw_session(s);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (options_get_number(oo, "mouse-resize-pane"))
|
||||
layout_resize_pane_mouse(c, mouse);
|
||||
memcpy(&c->last_mouse, mouse, sizeof c->last_mouse);
|
||||
window_pane_mouse(wp, c->session, mouse);
|
||||
server_client_check_mouse(c, wp, mouse);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -471,7 +496,7 @@ server_client_reset_state(struct client *c)
|
||||
struct screen *s = wp->screen;
|
||||
struct options *oo = &c->session->options;
|
||||
struct options *wo = &w->options;
|
||||
int status, mode;
|
||||
int status, mode, o;
|
||||
|
||||
if (c->flags & CLIENT_SUSPENDED)
|
||||
return;
|
||||
@ -481,8 +506,10 @@ server_client_reset_state(struct client *c)
|
||||
status = options_get_number(oo, "status");
|
||||
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status)
|
||||
tty_cursor(&c->tty, 0, 0);
|
||||
else
|
||||
tty_cursor(&c->tty, wp->xoff + s->cx, wp->yoff + s->cy);
|
||||
else {
|
||||
o = status && options_get_number (oo, "status-position") == 0;
|
||||
tty_cursor(&c->tty, wp->xoff + s->cx, o + wp->yoff + s->cy);
|
||||
}
|
||||
|
||||
/*
|
||||
* Resizing panes with the mouse requires at least button mode to give
|
||||
|
Reference in New Issue
Block a user