=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/tmux/server-client.c,v retrieving revision 1.65 retrieving revision 1.66 diff -c -r1.65 -r1.66 *** src/usr.bin/tmux/server-client.c 2012/01/29 02:22:11 1.65 --- src/usr.bin/tmux/server-client.c 2012/01/29 09:37:02 1.66 *************** *** 1,4 **** ! /* $OpenBSD: server-client.c,v 1.65 2012/01/29 02:22:11 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott --- 1,4 ---- ! /* $OpenBSD: server-client.c,v 1.66 2012/01/29 09:37:02 nicm Exp $ */ /* * Copyright (c) 2009 Nicholas Marriott *************** *** 27,32 **** --- 27,34 ---- #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 *); *************** *** 262,267 **** --- 264,328 ---- } } + /* 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) *************** *** 317,359 **** 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); return; } --- 378,384 ---- if (key == KEYC_MOUSE) { if (c->flags & CLIENT_READONLY) return; ! server_client_check_mouse(c, wp, mouse); return; } *************** *** 472,478 **** struct screen *s = wp->screen; struct options *oo = &c->session->options; struct options *wo = &w->options; ! int status, mode; if (c->flags & CLIENT_SUSPENDED) return; --- 497,503 ---- struct screen *s = wp->screen; struct options *oo = &c->session->options; struct options *wo = &w->options; ! int status, mode, o; if (c->flags & CLIENT_SUSPENDED) return; *************** *** 482,489 **** 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); /* * Resizing panes with the mouse requires at least button mode to give --- 507,516 ---- 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 { ! 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