Browse Source

Fix client_gb functions

Martin Duquesnoy 12 years ago
parent
commit
0d0cb3190a
3 changed files with 29 additions and 12 deletions
  1. 1 1
      src/barwin.c
  2. 24 6
      src/client.c
  3. 4 5
      src/mouse.c

+ 1 - 1
src/barwin.c

@@ -23,7 +23,7 @@ barwin_new(Window parent, int x, int y, int w, int h, Color fg, Color bg, bool e
      struct barwin *b = (struct barwin*)xcalloc(1, sizeof(struct barwin));
      XSetWindowAttributes at =
      {
-          .override_redirect = True,
+          .override_redirect = true,
           .background_pixmap = ParentRelative,
           .event_mask = BARWIN_MASK
      };

+ 24 - 6
src/client.c

@@ -113,10 +113,15 @@ client_gb_win(Window w)
 {
      struct client *c = SLIST_FIRST(&W->h.client);
 
-     while(c && c->win != w)
+     while(c)
+     {
+          if(c->win == w)
+               return c;
+
           c = SLIST_NEXT(c, next);
+     }
 
-     return c;
+     return NULL;
 }
 
 struct client*
@@ -124,10 +129,15 @@ client_gb_frame(Window w)
 {
      struct client *c = SLIST_FIRST(&W->h.client);
 
-     while(c && c->frame != w)
+     while(c)
+     {
+          if(c->frame == w)
+               return c;
+
           c = SLIST_NEXT(c, next);
+     }
 
-     return c;
+     return NULL;
 }
 
 struct client*
@@ -147,10 +157,18 @@ client_gb_titlebar(Window w)
 {
      struct client *c = SLIST_FIRST(&W->h.client);
 
-     while(c && c->titlebar && c->titlebar->win != w)
+     if(!c->titlebar)
+          return NULL;
+
+     while(c && c->titlebar->win != w)
+     {
+          if(c->titlebar->win == w)
+               return c;
+
           c = SLIST_NEXT(c, next);
+     }
 
-     return c;
+     return NULL;
 }
 
 /*

+ 4 - 5
src/mouse.c

@@ -176,13 +176,11 @@ mouse_move(struct client *c, void (*func)(struct client*, struct client*))
           }
           else
           {
-               XQueryPointer(W->dpy, W->root, &w, &w, &d, &d, &d, &d, (uint *)&u);
+               c2 = NULL;
 
-               if(!(c2 = client_gb_win(w)))
-                    if(!(c2 = client_gb_frame(w)))
-                         c2 = client_gb_titlebar(w);
+               XQueryPointer(W->dpy, W->root, &w, &w, &d, &d, &d, &d, (uint *)&u);
 
-               if(c2)
+               if((c2 = client_gb_win(w)) || (c2 = client_gb_frame(w)) || (c2 = client_gb_titlebar(w)))
                {
                     if(c2 != last)
                     {
@@ -240,4 +238,5 @@ uicb_mouse_tab(Uicb cmd)
 
      if(W->client && mouse_check_client(W->client))
           mouse_move(W->client, _client_tab);
+
 }