From 9f9757e1b4b9b4d78abbb4275ffecdc284c50325 Mon Sep 17 00:00:00 2001 From: Julien Danjou Date: Thu, 6 Sep 2007 20:02:30 +0200 Subject: [PATCH] deprected nexttiled, add IS_TILED macro to check if a client is tiled to current tags --- layout.c | 15 ++++++++------- layout.h | 3 ++- layouts/grid.c | 5 +++-- layouts/spiral.c | 5 +++-- layouts/tile.c | 25 ++++++++++++++++++------- tag.h | 3 +++ 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/layout.c b/layout.c index 90385da9..dd676926 100644 --- a/layout.c +++ b/layout.c @@ -138,13 +138,14 @@ restack(Display * disp, jdwm_config *jdwmconf) XConfigureWindow(disp, sel->win, CWSibling | CWStackMode, &wc); wc.sibling = sel->win; } - for(c = nexttiled(clients, jdwmconf->selected_tags, jdwmconf->ntags); c; c = nexttiled(c->next, jdwmconf->selected_tags, jdwmconf->ntags)) - { - if(c == sel) - continue; - XConfigureWindow(disp, c->win, CWSibling | CWStackMode, &wc); - wc.sibling = c->win; - } + for(c = clients; c; c = c->next) + if(IS_TILED(c, jdwmconf->selected_tags, jdwmconf->ntags)) + { + if(c == sel) + continue; + XConfigureWindow(disp, c->win, CWSibling | CWStackMode, &wc); + wc.sibling = c->win; + } } XSync(disp, False); while(XCheckMaskEvent(disp, EnterWindowMask, &ev)); diff --git a/layout.h b/layout.h index 7ee4407e..82dd09a1 100644 --- a/layout.h +++ b/layout.h @@ -5,11 +5,12 @@ #include "client.h" +/** Check if current layout is arranged with a layout */ #define IS_ARRANGE(layout) (layout == jdwmconf->current_layout->arrange) void arrange(Display *, jdwm_config *); /* arranges all windows depending on the layout in use */ void initlayouts(jdwm_config *); /* initialize layout array */ -Client *nexttiled(Client *, Bool *, int); /* returns tiled successor of c */ +Client *nexttiled(Client *, Bool *, int) __attribute__ ((deprecated)); void restack(Display *, jdwm_config *); /* restores z layers of all clients */ void uicb_focusnext(Display *, jdwm_config *, const char *); /* focuses next visible client */ void uicb_focusprev(Display *, jdwm_config *, const char *); /* focuses prev visible client */ diff --git a/layouts/grid.c b/layouts/grid.c index 8119d305..a2da5fc5 100644 --- a/layouts/grid.c +++ b/layouts/grid.c @@ -15,8 +15,9 @@ grid(Display *disp, jdwm_config *jdwmconf) unsigned int i, n, cx, cy, cw, ch, aw, ah, cols, rows; Client *c; - for(n = 0, c = nexttiled(clients, jdwmconf->selected_tags, jdwmconf->ntags); c; c = nexttiled(c->next, jdwmconf->selected_tags, jdwmconf->ntags)) - n++; + for(n = 0, c = clients; c; c = c->next) + if(IS_TILED(c, jdwmconf->selected_tags, jdwmconf->ntags)) + n++; /* grid dimensions */ for(rows = 0; rows <= n / 2; rows++) diff --git a/layouts/spiral.c b/layouts/spiral.c index 1e3638a9..8c0da43b 100644 --- a/layouts/spiral.c +++ b/layouts/spiral.c @@ -18,8 +18,9 @@ fibonacci(Display *disp, jdwm_config *jdwmconf, int shape) ny = 0; nw = waw; nh = wah; - for(n = 0, c = nexttiled(clients, jdwmconf->selected_tags, jdwmconf->ntags); c; c = nexttiled(c->next, jdwmconf->selected_tags, jdwmconf->ntags)) - n++; + for(n = 0, c = clients; c; c = c->next) + if(IS_TILED(c, jdwmconf->selected_tags, jdwmconf->ntags)) + n++; for(i = 0, c = clients; c; c = c->next) { c->ismax = False; diff --git a/layouts/tile.c b/layouts/tile.c index cdf23e54..28750986 100644 --- a/layouts/tile.c +++ b/layouts/tile.c @@ -3,8 +3,9 @@ #include #include -#include "layout.h" #include "layouts/tile.h" +#include "layout.h" +#include "tag.h" /* extern */ extern int wax, way, wah, waw; /* windowarea geometry */ @@ -76,8 +77,9 @@ _tile(jdwm_config *jdwmconf, const Bool right) int n, th, i, mh; Client *c; - for(n = 0, c = nexttiled(clients, jdwmconf->selected_tags, jdwmconf->ntags); c; c = nexttiled(c->next, jdwmconf->selected_tags, jdwmconf->ntags)) - n++; + for(n = 0, c = clients; c; c = c->next) + if(IS_TILED(c, jdwmconf->selected_tags, jdwmconf->ntags)) + n++; /* window geoms */ mh = (n <= nmaster) ? wah / (n > 0 ? n : 1) : wah / nmaster; @@ -88,8 +90,11 @@ _tile(jdwm_config *jdwmconf, const Bool right) nx = wax; ny = way; - for(i = 0, c = nexttiled(clients, jdwmconf->selected_tags, jdwmconf->ntags); c; c = nexttiled(c->next, jdwmconf->selected_tags, jdwmconf->ntags), i++) + for(i = 0, c = clients; c; c = c->next) { + if(!IS_TILED(c, jdwmconf->selected_tags, jdwmconf->ntags)) + continue; + c->ismax = False; if(i < nmaster) { /* master */ @@ -121,6 +126,7 @@ _tile(jdwm_config *jdwmconf, const Bool right) resize(c, nx, ny, nw, nh, False); if(n > nmaster && th != wah) ny += nh + 2 * c->border; + i++; } } @@ -143,8 +149,9 @@ _bstack(jdwm_config *jdwmconf, Bool portrait) int i, n, nx, ny, nw, nh, mw, mh, tw, th; Client *c; - for(n = 0, c = nexttiled(clients, jdwmconf->selected_tags, jdwmconf->ntags); c; c = nexttiled(c->next, jdwmconf->selected_tags, jdwmconf->ntags)) - n++; + for(n = 0, c = clients; c; c = c->next) + if(IS_TILED(c, jdwmconf->selected_tags, jdwmconf->ntags)) + n++; /* window geoms */ mh = (n > nmaster) ? (wah * mwfact) / nmaster : wah / (n > 0 ? n : 1); @@ -152,8 +159,11 @@ _bstack(jdwm_config *jdwmconf, Bool portrait) th = (n > nmaster) ? (wah * (1 - mwfact)) / (portrait ? 1 : n - nmaster) : 0; tw = (n > nmaster) ? waw / (portrait ? n - nmaster : 1) : 0; - for(i = 0, c = nexttiled(clients, jdwmconf->selected_tags, jdwmconf->ntags); c; c = nexttiled(c->next, jdwmconf->selected_tags, jdwmconf->ntags), i++) + for(i = 0, c = clients; c; c = c->next) { + if(!IS_TILED(c, jdwmconf->selected_tags, jdwmconf->ntags)) + continue; + c->ismax = False; nx = wax; ny = way; @@ -185,6 +195,7 @@ _bstack(jdwm_config *jdwmconf, Bool portrait) nh = wah - 2 * c->border; } resize(c, nx, ny, nw, nh, False); + i++; } } diff --git a/tag.h b/tag.h index b51db492..bc26811f 100644 --- a/tag.h +++ b/tag.h @@ -6,6 +6,9 @@ #include #include "client.h" +/** Check if a client is tiled */ +#define IS_TILED(client, tags, ntags) (client && !client->isfloating && isvisible(client, tags, ntags)) + void compileregs(jdwm_config *); /* initialize regexps of rules defined in config.h */ Bool isvisible(Client *, Bool *, int); void applyrules(Client * c, jdwm_config *); /* applies rules to c */