Browse Source

Add uicb mouse_tab, set by default on mouse2 -> titlebar

Martin Duquesnoy 12 years ago
parent
commit
38f122abbb
4 changed files with 21 additions and 3 deletions
  1. 2 0
      src/client.c
  2. 1 0
      src/config.h
  3. 17 3
      src/mouse.c
  4. 1 0
      src/mouse.h

+ 2 - 0
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);
      }

+ 1 - 0
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 }
 };

+ 17 - 3
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);
 }

+ 1 - 0
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)