From 38f122abbb30f0b0559a803195cc4220f8f42893 Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Fri, 13 Jan 2012 20:35:29 +0100 Subject: [PATCH] Add uicb mouse_tab, set by default on mouse2 -> titlebar --- src/client.c | 2 ++ src/config.h | 1 + src/mouse.c | 20 +++++++++++++++++--- src/mouse.h | 1 + 4 files changed, 21 insertions(+), 3 deletions(-) diff --git a/src/client.c b/src/client.c index c404c25..2f0b872 100644 --- a/src/client.c +++ b/src/client.c @@ -733,6 +733,8 @@ client_frame_new(struct client *c) uicb_client_focus_with_wid, cmd); barwin_mousebind_new(c->titlebar, Button1, false, g, uicb_mouse_move, cmd); + barwin_mousebind_new(c->titlebar, Button2, false, g, + uicb_mouse_tab, cmd); barwin_mousebind_new(c->titlebar, Button3, false, g, uicb_mouse_resize, cmd); } diff --git a/src/config.h b/src/config.h index 6456cd4..e8daa22 100644 --- a/src/config.h +++ b/src/config.h @@ -73,6 +73,7 @@ static const struct { char *name; void (*func)(Uicb cmd); } uicb_list[] = /* Mouse */ { "mouse_resize", uicb_mouse_resize }, { "mouse_move", uicb_mouse_move }, + { "mouse_tab", uicb_mouse_tab }, { NULL, NULL } }; diff --git a/src/mouse.c b/src/mouse.c index 2ba232d..0af12ff 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -70,7 +70,7 @@ mouse_resize(struct client *c) #define _REV_SBORDER(c) draw_reversed_rect(W->root, &(c)->geo); void -mouse_move(struct client *c) +mouse_move(struct client *c, bool type) { struct client *c2 = NULL, *last = c; XEvent ev; @@ -111,7 +111,11 @@ mouse_move(struct client *c) if(c2 && c2 != c) { _REV_SBORDER(c2); - client_swap2(c, c2); + + if(type) + client_swap2(c, c2); + else + _client_tab(c, c2); } XUngrabServer(W->dpy); @@ -134,5 +138,15 @@ uicb_mouse_move(Uicb cmd) if(mouse_check_client(W->client)) if(W->client) - mouse_move(W->client); + mouse_move(W->client, true); +} + +void +uicb_mouse_tab(Uicb cmd) +{ + (void)cmd; + + if(mouse_check_client(W->client)) + if(W->client) + mouse_move(W->client, false); } diff --git a/src/mouse.h b/src/mouse.h index 69fbd6e..9550a14 100644 --- a/src/mouse.h +++ b/src/mouse.h @@ -10,6 +10,7 @@ void uicb_mouse_resize(Uicb); void uicb_mouse_move(Uicb); +void uicb_mouse_tab(Uicb); static inline bool mouse_check_client(struct client *c)