diff options
Diffstat (limited to 'server-client.c')
-rw-r--r-- | server-client.c | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/server-client.c b/server-client.c index fe72317a..fd31eeee 100644 --- a/server-client.c +++ b/server-client.c @@ -398,6 +398,8 @@ server_client_exec(struct client *c, const char *cmd) shell = options_get_string(s->options, "default-shell"); else shell = options_get_string(global_s_options, "default-shell"); + if (!checkshell(shell)) + shell = _PATH_BSHELL; shellsize = strlen(shell) + 1; msg = xmalloc(cmdsize + shellsize); @@ -417,7 +419,7 @@ server_client_check_mouse(struct client *c, struct key_event *event) struct winlink *wl; struct window_pane *wp; u_int x, y, b, sx, sy, px, py; - int flag; + int ignore = 0; key_code key; struct timeval tv; struct style_range *sr; @@ -441,7 +443,12 @@ server_client_check_mouse(struct client *c, struct key_event *event) m->x, m->y, m->lx, m->ly, c->tty.mouse_drag_flag); /* What type of event is this? */ - if ((m->sgr_type != ' ' && + if (event->key == KEYC_DOUBLECLICK) { + type = DOUBLE; + x = m->x, y = m->y, b = m->b; + ignore = 1; + log_debug("double-click at %u,%u", x, y); + } else if ((m->sgr_type != ' ' && MOUSE_DRAG(m->sgr_b) && MOUSE_BUTTONS(m->sgr_b) == 3) || (m->sgr_type == ' ' && @@ -475,10 +482,8 @@ server_client_check_mouse(struct client *c, struct key_event *event) evtimer_del(&c->click_timer); c->flags &= ~CLIENT_DOUBLECLICK; if (m->b == c->click_button) { - type = DOUBLE; - x = m->x, y = m->y, b = m->b; - log_debug("double-click at %u,%u", x, y); - flag = CLIENT_TRIPLECLICK; + type = NOTYPE; + c->flags |= CLIENT_TRIPLECLICK; goto add_timer; } } else if (c->flags & CLIENT_TRIPLECLICK) { @@ -488,18 +493,19 @@ server_client_check_mouse(struct client *c, struct key_event *event) type = TRIPLE; x = m->x, y = m->y, b = m->b; log_debug("triple-click at %u,%u", x, y); + ignore = 1; goto have_event; } - } + } else + c->flags |= CLIENT_DOUBLECLICK; + add_timer: type = DOWN; x = m->x, y = m->y, b = m->b; log_debug("down at %u,%u", x, y); - flag = CLIENT_DOUBLECLICK; - add_timer: if (KEYC_CLICK_TIMEOUT != 0) { - c->flags |= flag; + memcpy(&c->click_event, m, sizeof c->click_event); c->click_button = m->b; tv.tv_sec = KEYC_CLICK_TIMEOUT / 1000; @@ -516,6 +522,7 @@ have_event: /* Save the session. */ m->s = s->id; m->w = -1; + m->ignore = ignore; /* Is this on the status line? */ m->statusat = status_at_line(c); @@ -1045,7 +1052,7 @@ server_client_key_callback(struct cmdq_item *item, void *data) /* Check for mouse keys. */ m->valid = 0; - if (key == KEYC_MOUSE) { + if (key == KEYC_MOUSE || key == KEYC_DOUBLECLICK) { if (c->flags & CLIENT_READONLY) goto out; key = server_client_check_mouse(c, event); @@ -1547,8 +1554,22 @@ server_client_repeat_timer(__unused int fd, __unused short events, void *data) static void server_client_click_timer(__unused int fd, __unused short events, void *data) { - struct client *c = data; + struct client *c = data; + struct key_event *event; + + log_debug("click timer expired"); + if (c->flags & CLIENT_TRIPLECLICK) { + /* + * Waiting for a third click that hasn't happened, so this must + * have been a double click. + */ + event = xmalloc(sizeof *event); + event->key = KEYC_DOUBLECLICK; + memcpy(&event->m, &c->click_event, sizeof event->m); + if (!server_client_handle_key(c, event)) + free(event); + } c->flags &= ~(CLIENT_DOUBLECLICK|CLIENT_TRIPLECLICK); } @@ -1992,7 +2013,7 @@ server_client_dispatch_shell(struct client *c) const char *shell; shell = options_get_string(global_s_options, "default-shell"); - if (*shell == '\0' || areshell(shell)) + if (!checkshell(shell)) shell = _PATH_BSHELL; proc_send(c->peer, MSG_SHELL, -1, shell, strlen(shell) + 1); |