From 0d0cb3190ac6175bb0bd56c8f2504a339fd4426e Mon Sep 17 00:00:00 2001 From: Martin Duquesnoy Date: Thu, 8 Mar 2012 15:54:37 +0100 Subject: [PATCH] Fix client_gb functions --- src/barwin.c | 2 +- src/client.c | 36 +++++++++++++++++++++++++++--------- src/mouse.c | 9 ++++----- 3 files changed, 32 insertions(+), 15 deletions(-) diff --git a/src/barwin.c b/src/barwin.c index 00d3683..c3165f6 100644 --- a/src/barwin.c +++ b/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 }; diff --git a/src/client.c b/src/client.c index 642975a..3450f54 100644 --- a/src/client.c +++ b/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) - c = SLIST_NEXT(c, next); + while(c) + { + if(c->win == w) + return c; - return c; + c = SLIST_NEXT(c, next); + } + + 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) - c = SLIST_NEXT(c, next); + while(c) + { + if(c->frame == w) + return c; - return c; + c = SLIST_NEXT(c, next); + } + + 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) - c = SLIST_NEXT(c, next); + if(!c->titlebar) + return NULL; - return c; + while(c && c->titlebar->win != w) + { + if(c->titlebar->win == w) + return c; + + c = SLIST_NEXT(c, next); + } + + return NULL; } /* diff --git a/src/mouse.c b/src/mouse.c index 544b4fa..ef3e3a5 100644 --- a/src/mouse.c +++ b/src/mouse.c @@ -176,13 +176,11 @@ mouse_move(struct client *c, void (*func)(struct client*, struct client*)) } else { + c2 = NULL; + XQueryPointer(W->dpy, W->root, &w, &w, &d, &d, &d, &d, (uint *)&u); - if(!(c2 = client_gb_win(w))) - if(!(c2 = client_gb_frame(w))) - c2 = client_gb_titlebar(w); - - 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); + }