Hi
Thanks.
Some minor nits:
- I think the big bit added to server_client_handle_key would be better
in a separate function.
- return should have brackets - return (-1) not return -1.
On Sun, Jul 03, 2011 at 03:58:31AM +0200, marcel partap wrote:
> ...With this, a double click on the status line (any part not
> belonging to the window list) creates a new window.
> Tricky stuff. Now i know much more about tmux debugging ^^
> As i couldn't find a way to receive mouse button AND modifier,
> window closing on CTRL+double click is yet missing.
> #n8/regards/marcel
> --- work/tmux/server-client.c.orig 2011-07-02 05:41:16.745038555 +0200
> +++ work/tmux/server-client.c 2011-07-03 03:36:07.999608557 +0200
> @@ -64,6 +64,8 @@
> if (gettimeofday(&c->creation_time, NULL) != 0)
> fatal("gettimeofday failed");
> memcpy(&c->activity_time, &c->creation_time, sizeof c->activity_time);
> + memcpy(&c->dblclick_start, &c->creation_time, sizeof c->dblclick_start);
> + c->dblclick_start.tv_usec -= DBLCLICK_USEC;
>
> c->stdin_event = NULL;
> c->stdout_event = NULL;
> @@ -267,12 +269,15 @@
> struct session *s;
> struct window *w;
> struct window_pane *wp;
> + struct winlink *wl;
> struct options *oo;
> + struct cmd_ctx ctx;
> struct timeval tv;
> struct key_binding *bd;
> struct keylist *keylist;
> - int xtimeout, isprefix;
> + int xtimeout, isprefix, winidx, diff_usec;
> u_int i;
> + char *cause;
>
> /* Check the client is good to accept input. */
> if ((c->flags & (CLIENT_DEAD|CLIENT_SUSPENDED)) != 0)
> @@ -332,8 +337,29 @@
> options_get_number(oo, "status")) {
> if (mouse->b == MOUSE_UP &&
> c->last_mouse.b != MOUSE_UP) {
> - status_set_window_at(c, mouse->x);
> - return;
> + winidx = status_find_window_at(s, mouse->x);
> + if (winidx != -1 && session_select(s, winidx)
> != -1) {
> + server_redraw_session(s);
> + return;
> + }
> + /* Measure time since last click and update
> start time. */
> + gettimeofday(&tv, NULL);
> + diff_usec = tv.tv_usec -
> c->dblclick_start.tv_usec;
> + diff_usec += (tv.tv_sec -
> c->dblclick_start.tv_sec) * 1000000;
> + memcpy(&c->dblclick_start, &tv, sizeof
> c->dblclick_start);
> + /* Check for double click within DBLCLICK_USEC
> time. */
> + if (diff_usec <= DBLCLICK_USEC) {
> + wl = session_new(s, NULL, "", c->cwd,
> -1, &cause);
> + if (wl == NULL) {
> + memset(&ctx, 0, sizeof ctx);
> + ctx.cmdclient = c;
> + server_client_msg_error(&ctx,
> "%s", cause);
> + xfree(cause);
> + }
> + else {
> + session_select(s, wl->idx);
> + }
> + }
> }
> if (mouse->b & MOUSE_45) {
> if ((mouse->b & MOUSE_BUTTON) == MOUSE_1) {
> --- work/tmux/tmux.h.orig 2011-07-02 05:41:16.749038497 +0200
> +++ work/tmux/tmux.h 2011-07-03 02:05:17.122512753 +0200
> @@ -1188,6 +1188,8 @@
> struct session *last_session;
>
> struct mouse_event last_mouse;
> + struct timeval dblclick_start;
> +#define DBLCLICK_USEC 350000
>
> int references;
> };
> @@ -1694,7 +1696,7 @@
> RB_PROTOTYPE(status_out_tree, status_out, entry, status_out_cmp);
> void status_free_jobs(struct status_out_tree *);
> void status_update_jobs(struct client *);
> -void status_set_window_at(struct client *, u_int);
> +int status_find_window_at(struct session *, u_int);
> int status_redraw(struct client *);
> char *status_replace(struct client *, struct session *,
> struct winlink *, struct window_pane *, const char *, time_t, int);
> --- work/tmux/status.c.orig 2011-07-02 05:41:16.747038527 +0200
> +++ work/tmux/status.c 2011-07-03 03:35:07.862500610 +0200
> @@ -120,21 +120,19 @@
> return (right);
> }
>
> -/* Set window at window list position. */
> -void
> -status_set_window_at(struct client *c, u_int x)
> +/* Find window at window list coordinate. */
> +int
> +status_find_window_at(struct session *s, u_int x)
> {
> - struct session *s = c->session;
> struct winlink *wl;
>
> x += s->wlmouse;
> RB_FOREACH(wl, winlinks, &s->windows) {
> - if (x < wl->status_width &&
> - session_select(s, wl->idx) == 0) {
> - server_redraw_session(s);
> - }
> + if (x < wl->status_width)
> + return wl->idx;
> x -= wl->status_width + 1;
> }
> + return -1;
> }
>
> /* Draw status for client on the last lines of given context. */
> ------------------------------------------------------------------------------
> All of the data generated in your IT infrastructure is seriously valuable.
> Why? It contains a definitive record of application performance, security
> threats, fraudulent activity, and more. Splunk takes this data and makes
> sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-d2d-c2
> _______________________________________________
> tmux-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/tmux-users
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
tmux-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tmux-users