version 1.65, 2012/01/29 02:22:11 |
version 1.66, 2012/01/29 09:37:02 |
|
|
|
|
#include "tmux.h" |
#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_handle_key(int, struct mouse_event *, void *); |
void server_client_repeat_timer(int, short, void *); |
void server_client_repeat_timer(int, short, void *); |
void server_client_check_exit(struct client *); |
void server_client_check_exit(struct client *); |
|
|
} |
} |
} |
} |
|
|
|
/* 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. */ |
/* Handle data key input from client. */ |
void |
void |
server_client_handle_key(int key, struct mouse_event *mouse, void *data) |
server_client_handle_key(int key, struct mouse_event *mouse, void *data) |
|
|
if (key == KEYC_MOUSE) { |
if (key == KEYC_MOUSE) { |
if (c->flags & CLIENT_READONLY) |
if (c->flags & CLIENT_READONLY) |
return; |
return; |
if (options_get_number(oo, "mouse-select-pane") && |
server_client_check_mouse(c, wp, mouse); |
(!(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; |
return; |
} |
} |
|
|
|
|
struct screen *s = wp->screen; |
struct screen *s = wp->screen; |
struct options *oo = &c->session->options; |
struct options *oo = &c->session->options; |
struct options *wo = &w->options; |
struct options *wo = &w->options; |
int status, mode; |
int status, mode, o; |
|
|
if (c->flags & CLIENT_SUSPENDED) |
if (c->flags & CLIENT_SUSPENDED) |
return; |
return; |
|
|
status = options_get_number(oo, "status"); |
status = options_get_number(oo, "status"); |
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status) |
if (!window_pane_visible(wp) || wp->yoff + s->cy >= c->tty.sy - status) |
tty_cursor(&c->tty, 0, 0); |
tty_cursor(&c->tty, 0, 0); |
else |
else { |
tty_cursor(&c->tty, wp->xoff + s->cx, wp->yoff + s->cy); |
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 |
* Resizing panes with the mouse requires at least button mode to give |