WMFS: Use SLIST from sys/queue.h instead homemade linked list

This commit is contained in:
Martin Duquesnoy 2011-07-29 10:54:08 +02:00
parent 5d80ec8538
commit 58f6f674ca
13 changed files with 117 additions and 122 deletions

View File

@ -108,10 +108,10 @@ static void
_cfactor_arrange_row(Client *c, Position p, int fac)
{
Geo cgeo = c->frame_geo;
Client *cc;
Client *cc = tiled_client(c->screen, SLIST_FIRST(&clients));
/* Travel clients to search parents of row and apply fact */
for(cc = tiled_client(c->screen, clients); cc; cc = tiled_client(c->screen, cc->next))
for(; cc; cc = tiled_client(c->screen, SLIST_NEXT(cc, next)))
if(CFACTOR_PARENTROW(cgeo, cc->frame_geo, p))
{
cc->tilefact[p] += fac;
@ -131,13 +131,13 @@ static bool
_cfactor_check_geo_row(Client *c, Position p, int fac)
{
Geo cgeo = c->frame_geo;
Client *cc;
Client *cc = tiled_client(c->screen, SLIST_FIRST(&clients));
int e, f[4] = { 0 };
f[p] += fac;
/* Travel clients to search parents of row and check geos */
for(cc = tiled_client(c->screen, clients); cc; cc = tiled_client(c->screen, cc->next))
for(; cc; cc = tiled_client(c->screen, SLIST_NEXT(cc, next)))
if(CFACTOR_PARENTROW(cgeo, cc->frame_geo, p))
{
(Geo)cfactor_geo(cc->wrgeo, f, &e);

View File

@ -87,11 +87,7 @@ CLIENT_ACTION_DIR(swapsel, Bottom);
void
client_attach(Client *c)
{
if(clients)
clients->prev = c;
c->next = clients;
clients = c;
SLIST_INSERT_HEAD(&clients, c, next);
return;
}
@ -126,10 +122,7 @@ client_configure(Client *c)
void
client_detach(Client *c)
{
Client **cc;
for(cc = &clients; *cc && *cc != c; cc = &(*cc)->next);
*cc = c->next;
SLIST_REMOVE(&clients, c, Client, next);
return;
}
@ -147,10 +140,10 @@ client_get_next(void)
if(!sel || ishide(sel, selscreen))
return NULL;
for(c = sel->next; c && ishide(c, selscreen); c = c->next);
for(c = SLIST_NEXT(sel, next); c && ishide(c, selscreen); c = SLIST_NEXT(c, next));
if(!c && conf.client_round)
for(c = clients; c && ishide(c, selscreen); c = c->next);
for(c = SLIST_FIRST(&clients); c && ishide(c, selscreen); c = SLIST_NEXT(c, next));
return c;
}
@ -161,19 +154,19 @@ client_get_next(void)
Client*
client_get_prev(void)
{
Client *c = NULL, *d;
Client *c = NULL, *d = SLIST_FIRST(&clients);
screen_get_sel();
if(!sel || ishide(sel, selscreen))
return NULL;
for(d = clients; d != sel; d = d->next)
for(; d != sel; d = SLIST_NEXT(d, next))
if(!ishide(d, selscreen))
c = d;
if(!c && conf.client_round)
for(; d; d = d->next)
for(; d; d = SLIST_NEXT(d, next))
if(!ishide(d, selscreen))
c = d;
@ -273,7 +266,7 @@ client_focus(Client *c)
if((sel = c))
{
/* Set focusontag option */
for(cc = clients; cc; cc = cc->next)
SLIST_FOREACH(cc, &clients, next)
if(cc->focusontag == (int)c->tag)
cc->focusontag = -1;
@ -338,10 +331,10 @@ client_urgent(Client *c, bool u)
*/
Client* client_gb_win(Window w)
{
Client *c = clients;
Client *c = SLIST_FIRST(&clients);
while(c && c->win != w)
c = c->next;
c = SLIST_NEXT(c, next);
return c;
}
@ -352,10 +345,10 @@ client_urgent(Client *c, bool u)
*/
Client* client_gb_frame(Window w)
{
Client *c = clients;
Client *c = SLIST_FIRST(&clients);
while(c && c->frame != w)
c = c->next;
c = SLIST_NEXT(c, next);
return c;
}
@ -366,13 +359,13 @@ client_urgent(Client *c, bool u)
*/
Client* client_gb_titlebar(Window w)
{
Client *c = clients;
Client *c = SLIST_FIRST(&clients);
if(!(TBARH - BORDH))
return NULL;
while(c && c->titlebar->win != w)
c = c->next;
c = SLIST_NEXT(c, next);
return c;
}
@ -383,10 +376,10 @@ client_urgent(Client *c, bool u)
*/
Client* client_gb_resize(Window w)
{
Client *c = clients;
Client *c = SLIST_FIRST(&clients);
while(c && (c->resize[Right] != w) && (c->resize[Left] != w))
c = c->next;
c = SLIST_NEXT(c, next);
return c;
}
@ -398,13 +391,13 @@ client_urgent(Client *c, bool u)
*/
Client* client_gb_button(Window w, int *n)
{
Client *c = clients;
Client *c;
int i;
if(!BUTTONWH || !(TBARH - BORDH))
return NULL;
for(; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
for(i = 0; i < conf.titlebar.nbutton; ++i)
if(c->button[i] == w)
{
@ -422,13 +415,13 @@ client_urgent(Client *c, bool u)
*/
Client* client_gb_pos(Client *c, int x, int y)
{
Client *cc = clients;
Client *cc;
if((x | y) < 0 || x > spgeo[c->screen].x + spgeo[c->screen].width
|| y > spgeo[c->screen].y + spgeo[c->screen].height)
return NULL;
for(; cc; cc = cc->next)
SLIST_FOREACH(cc, &clients, next)
if(cc != c && cc->screen == c->screen && cc->tag == c->tag
&& (cc->flags & TileFlag))
if(cc->frame_geo.x < x && cc->frame_geo.x + cc->frame_geo.width > x
@ -767,7 +760,7 @@ client_manage(Window w, XWindowAttributes *wa, bool ar)
/* Transient for tag setting */
if((rettrans = XGetTransientForHint(dpy, w, &trans) == Success))
for(t = clients; t && t->win != trans; t = t->next);
for(t = SLIST_FIRST(&clients); t && t->win != trans; t = SLIST_NEXT(t, next));
if(t)
{
@ -1146,16 +1139,13 @@ client_unhide(Client *c)
void
client_focus_next(Client *c)
{
Client *c_next = NULL;
Client *c_next = SLIST_FIRST(&clients);
for(c_next = clients;
c_next && c_next != c->prev
&& c_next->tag != c->tag
&& c_next->screen != c->screen;
c_next = c_next->next);
for(; c_next && c_next->tag != c->tag && c_next->screen != c->screen;
c_next = SLIST_NEXT(c_next, next));
if(c_next && c_next->tag == (uint)seltag[selscreen]
&& c_next->screen == selscreen)
&& c_next->screen == selscreen)
client_focus(c_next);
return;
@ -1443,8 +1433,8 @@ uicb_client_select(uicb_t cmd)
void
uicb_clientlist(uicb_t cmd)
{
int i, d, u, x, y;
int n = 0;
int d, u, x, y;
int n = 0, i = 0;
bool all = False;
Window w;
Client *c = NULL;
@ -1454,7 +1444,7 @@ uicb_clientlist(uicb_t cmd)
if(cmd && !strcmp(cmd, "all"))
all = True;
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(!ishide(c, selscreen) || all)
++n;
@ -1472,7 +1462,7 @@ uicb_clientlist(uicb_t cmd)
clientlist.align = MA_Left;
for(i = 0, c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(!ishide(c, selscreen) || all)
{
sprintf(clist_index[i].key, "%d", i);
@ -1530,7 +1520,7 @@ uicb_client_ignore_tag(uicb_t cmd)
void
uicb_client_set_master(uicb_t cmd)
{
Client *c;
Client *c = SLIST_FIRST(&clients);
(void)cmd;
/* get the first client */
@ -1538,7 +1528,7 @@ uicb_client_set_master(uicb_t cmd)
if(!sel || ishide(sel, selscreen))
return;
for(c = clients; c && ishide(c, selscreen); c = c->next);
for(; c && ishide(c, selscreen); c = SLIST_NEXT(c, next));
if (c && c != sel)
{

View File

@ -250,13 +250,16 @@ ewmh_get_client_list(void)
{
Window *list;
Client *c;
int win_n;
int win_n = 0;
SLIST_FOREACH(c, &clients, next)
++win_n;
for(win_n = 0, c = clients; c; c = c->next, ++win_n);
list = xcalloc(win_n, sizeof(Window));
for(win_n = 0, c = clients; c; c = c->next, ++win_n)
list[win_n] = c->win;
win_n = 0;
SLIST_FOREACH(c, &clients, next)
list[win_n++] = c->win;
XChangeProperty(dpy, ROOT, net_atom[net_client_list], XA_WINDOW, 32,
PropModeReplace, (uchar *)list, win_n);

View File

@ -240,7 +240,7 @@ void
infobar_draw_taglist(InfoBar *i)
{
int j, x, sc = i->screen;
Client *c = NULL;
Client *c = SLIST_FIRST(&clients);
uint occupied = 0;
if(conf.layout_placement)
@ -249,7 +249,7 @@ infobar_draw_taglist(InfoBar *i)
? (uint)conf.layout_button_width
: (textw(tags[sc][seltag[sc]].layout.symbol) + PAD)) + (PAD >> 1), 0);
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->screen == sc)
occupied |= TagFlag(c->tag);

View File

@ -216,6 +216,9 @@ init(void)
ewmh_update_current_tag_prop();
grabkeys();
/* Init lists heads */
SLIST_INIT(&clients);
return;
}

View File

@ -42,7 +42,7 @@ arrange(int screen, bool update_layout)
if(screen < 0 || screen > screen_count() - 1)
screen = screen_get_sel();
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->screen == screen)
{
if(!ishide(c, screen))
@ -87,7 +87,7 @@ freelayout(int screen)
Client *c;
(void)screen;
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(!ishide(c, selscreen)
&& c->screen == screen
&& !(c->flags & MaxFlag))
@ -108,12 +108,12 @@ void
layoutswitch(bool b)
{
int i;
Client *c;
Client *c = SLIST_FIRST(&clients);
screen_get_sel();
if(tags[selscreen][seltag[selscreen]].layout.func == freelayout)
for(c = clients; c && (c->tag != (uint)seltag[selscreen] && c->screen != selscreen); c = c->next)
for(; c && (c->tag != (uint)seltag[selscreen] && c->screen != selscreen); c = SLIST_NEXT(c, next))
{
c->ogeo = c->geo;
c->free_geo = c->geo;
@ -173,9 +173,9 @@ uicb_layout_prev(uicb_t cmd)
Client*
tiled_client(int screen, Client *c)
{
for(;c && (c->flags & (MaxFlag | FreeFlag | FSSFlag | AboveFlag)
for(; c && (c->flags & (MaxFlag | FreeFlag | FSSFlag | AboveFlag)
|| c->screen != screen
|| ishide(c, screen)); c = c->next);
|| ishide(c, screen)); c = SLIST_NEXT(c, next));
if(c)
c->flags |= FLayFlag;
@ -188,10 +188,10 @@ tiled_client(int screen, Client *c)
void
maxlayout(int screen)
{
Client *c;
int i;
Client *c = tiled_client(screen, SLIST_FIRST(&clients));
int i = 0;
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
for(; c; c = tiled_client(screen, SLIST_NEXT(c, next)), ++i)
{
c->flags &= ~TileFlag;
c->flags |= LMaxFlag;
@ -233,12 +233,12 @@ uicb_set_mwfact(uicb_t cmd)
void
uicb_set_nmaster(uicb_t cmd)
{
int nc, n = atoi(cmd);
Client *c;
int nc = 0, n = atoi(cmd);
Client *c = tiled_client(selscreen, SLIST_FIRST(&clients));
screen_get_sel();
for(nc = 0, c = tiled_client(selscreen, clients); c; c = tiled_client(selscreen, c->next), ++nc);
for(; c; c = tiled_client(selscreen, SLIST_NEXT(c, next)), ++nc);
if(!nc || tags[selscreen][seltag[selscreen]].nmaster + n == 0
|| tags[selscreen][seltag[selscreen]].nmaster + n > nc)
@ -258,12 +258,12 @@ uicb_set_nmaster(uicb_t cmd)
static void
grid(int screen, bool horizontal)
{
Client *c;
Client *c = tiled_client(screen, SLIST_FIRST(&clients));
Geo sg = sgeo[screen];
Geo cgeo = {sg.x, sg.y, 0, 0};
unsigned int i, n, temp, cols, rows, cpcols = 0;
unsigned int i = 0, n = 0, temp, cols, rows, cpcols = 0;
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
for(; c; c = tiled_client(screen, SLIST_NEXT(c, next)), ++n);
CHECK((tags[screen][seltag[screen]].nclients = n));
for(rows = 0; rows <= (n >> 1); ++rows)
@ -281,7 +281,7 @@ grid(int screen, bool horizontal)
rows = temp;
}
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
for(c = tiled_client(screen, SLIST_FIRST(&clients)); c; c = tiled_client(screen, SLIST_NEXT(c, next)), ++i)
{
/* Set client property */
c->flags &= ~(MaxFlag | LMaxFlag);
@ -327,13 +327,13 @@ grid(int screen, bool horizontal)
static void
multi_tile(int screen, Position type)
{
Client *c;
Client *c = tiled_client(screen, SLIST_FIRST(&clients));
Geo sg = sgeo[screen];
Geo mastergeo = {sg.x, sg.y, 0, 0};
Geo cgeo = {sg.x, sg.y, 0, 0};
uint i, n, tilesize = 0, mwfact, nmaster = tags[screen][seltag[screen]].nmaster;
int i = 0, n = 0, tilesize = 0, mwfact, nmaster = tags[screen][seltag[screen]].nmaster;
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
for(; c; c = tiled_client(screen, SLIST_NEXT(c, next)), ++n);
CHECK((tags[screen][seltag[screen]].nclients = n));
/* FIX NMASTER */
@ -369,7 +369,7 @@ multi_tile(int screen, Position type)
}
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
for(c = tiled_client(screen, SLIST_FIRST(&clients)); c; c = tiled_client(screen, SLIST_NEXT(c, next)), ++i)
{
/* Set client property */
c->flags &= ~(MaxFlag | LMaxFlag);
@ -459,19 +459,19 @@ multi_tile(int screen, Position type)
static void
mirror(int screen, bool horizontal)
{
Client *c;
Client *c = tiled_client(screen, SLIST_FIRST(&clients));
Geo sg = sgeo[screen];
Geo mastergeo = {sg.x, sg.y, sg.width, sg.height};
Geo cgeo = {sg.x, sg.y , sg.width, sg.height};
Geo nextg[2];
uint i, n, tilesize = 0, mwfact;
uint nmaster = tags[screen][seltag[screen]].nmaster;
int i = 0, n = 0, tilesize = 0, mwfact;
int nmaster = tags[screen][seltag[screen]].nmaster;
int pa, imp;
bool isp = False;
memset(nextg, 0, sizeof(nextg));
for(n = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++n);
for(; c; c = tiled_client(screen, SLIST_NEXT(c, next)), ++n);
CHECK((tags[screen][seltag[screen]].nclients = n));
/* Fix nmaster */
@ -527,7 +527,7 @@ mirror(int screen, bool horizontal)
}
}
for(i = 0, c = tiled_client(screen, clients); c; c = tiled_client(screen, c->next), ++i)
for(c = tiled_client(screen, SLIST_FIRST(&clients)); c; c = tiled_client(screen, SLIST_NEXT(c, next)), ++i)
{
/* Set client property */
c->flags &= ~(MaxFlag | LMaxFlag);
@ -794,14 +794,14 @@ uicb_togglemax(uicb_t cmd)
void
uicb_toggle_resizehint(uicb_t cmd)
{
Client *c;
Client *c = tiled_client(selscreen, SLIST_FIRST(&clients));
screen_get_sel();
(void)cmd;
tags[selscreen][seltag[selscreen]].flags ^= ResizeHintFlag;
for(c = tiled_client(selscreen, clients); c; c = tiled_client(selscreen, c->next))
for(; c; c = tiled_client(selscreen, SLIST_NEXT(c, next)))
client_moveresize(c, c->geo, (tags[selscreen][seltag[selscreen]].flags & ResizeHintFlag));
return;
@ -822,7 +822,7 @@ uicb_toggle_abovefc(uicb_t cmd)
if(!(tags[selscreen][seltag[selscreen]].flags & AboveFCFlag))
{
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->flags & AboveFlag
&& c->screen == selscreen
&& c->tag == (uint)seltag[selscreen])
@ -877,8 +877,8 @@ layout_set_client_master(Client *c)
if(!c || (c->flags & (HintFlag | FSSFlag)) || !(c->flags & TileFlag))
return;
if(c == tiled_client(selscreen, clients))
CHECK((c = tiled_client(selscreen, c->next)));
if(c == tiled_client(selscreen, SLIST_FIRST(&clients)))
CHECK((c = tiled_client(selscreen, SLIST_NEXT(c, next))));
client_detach(c);
client_attach(c);

View File

@ -18,7 +18,6 @@
#define PARSE_H
#include "wmfs.h"
#include <sys/queue.h>
#define INCLUDE_CMD "@include"
#define PARSE_MAX_LIST 32

View File

@ -121,14 +121,13 @@ split_apply_current(int screen, int tag)
static bool
_split_check_row_dir(Client *c, Client *g, Position p)
{
int s, cs;
Geo cgeo;
Client *cc;
int s = 0, cs;
Geo cgeo = c->frame_geo;
Client *cc = tiled_client(c->screen, SLIST_FIRST(&clients));
cs = (LDIR(p) ? g->frame_geo.height : g->frame_geo.width);
for(s = 0, cgeo = c->frame_geo, cc = tiled_client(c->screen, clients);
cc; cc = tiled_client(c->screen, cc->next))
for(; cc; cc = tiled_client(c->screen, SLIST_NEXT(cc, next)))
if(CFACTOR_PARENTROW(cgeo, cc->frame_geo, RPOS(p))
&& SPLIT_CHECK_ROW(cc->frame_geo, g->frame_geo, p))
{
@ -197,8 +196,8 @@ split_arrange_closed(Client *ghost)
for(p = Right; p < Center && !b; ++p)
if((c = client_get_next_with_direction(ghost, p)) && _split_check_row_dir(c, ghost, p))
{
for(cgeo = c->frame_geo, cc = tiled_client(c->screen, clients);
cc; cc = tiled_client(c->screen, cc->next))
for(cgeo = c->frame_geo, cc = tiled_client(c->screen, SLIST_FIRST(&clients));
cc; cc = tiled_client(c->screen, SLIST_NEXT(cc, next)))
if(CFACTOR_PARENTROW(cgeo, cc->frame_geo, RPOS(p))
&& SPLIT_CHECK_ROW(cc->frame_geo, ghost->frame_geo, p))
{
@ -296,7 +295,8 @@ split_client_integrate(Client *c, Client *sc, int screen, int tag)
|| sc->screen != screen || sc->tag != tag)
{
/* Looking for first client on wanted tag */
for(b = False, sc = clients; sc; sc = sc->next)
b = False;
SLIST_FOREACH(sc, &clients, next)
if(sc != c && sc->screen == screen && sc->tag == tag
&& (sc->flags & TileFlag))
{

View File

@ -244,9 +244,8 @@ struct Client
} colors;
/* Client Information by flags */
uint flags;
/* Struct in chains */
Client *next;
Client *prev;
/* Simply-linked list */
SLIST_ENTRY(Client) next;
};
/* Keybind Structure */
@ -297,7 +296,7 @@ struct Systray
{
Window win;
Geo geo;
Systray *next, *prev;
SLIST_ENTRY(Systray) next;
};
/* Tag Structure */

View File

@ -98,11 +98,7 @@ systray_add(Window win)
ewmh_send_message(s->win, s->win, "_XEMBED", CurrentTime, XEMBED_EMBEDDED_NOTIFY, 0, traywin, 0);
/* Attach */
if(trayicons)
trayicons->prev = s;
s->next = trayicons;
trayicons = s;
SLIST_INSERT_HEAD(&trayicons, s, next);
return;
}
@ -115,9 +111,7 @@ systray_del(Systray *s)
if(!conf.systray.active)
return;
for(ss = &trayicons; *ss && *ss != s; ss = &(*ss)->next);
*ss = s->next;
SLIST_REMOVE(&trayicons, s, Systray, next);
free(s);
return;
@ -158,10 +152,13 @@ systray_freeicons(void)
if(!conf.systray.active)
return;
for(i = trayicons; i; i = i->next)
while(!SLIST_EMPTY(&trayicons))
{
i = SLIST_FIRST(&trayicons);
SLIST_REMOVE_HEAD(&trayicons, next);
XUnmapWindow(dpy, i->win);
XReparentWindow(dpy, i->win, ROOT, 0, 0);
XReparentWindow(dpy, i->win, ROOT, 0, 0);
free(i);
}
@ -181,7 +178,7 @@ systray_find(Window win)
if(!conf.systray.active)
return NULL;
for(i = trayicons; i; i = i->next)
SLIST_FOREACH(i, &trayicons, next)
if(i->win == win)
return i;
@ -197,7 +194,7 @@ systray_get_width(void)
if(!conf.systray.active)
return 0;
for(i = trayicons; i; i = i->next)
SLIST_FOREACH(i, &trayicons, next)
w += i->geo.width + conf.systray.spacing + 1;
return w;
@ -212,13 +209,13 @@ systray_update(void)
if(!conf.systray.active)
return;
if(!trayicons)
if(!SLIST_FIRST(&trayicons))
{
XMoveResizeWindow(dpy, traywin, infobar[conf.systray.screen].bar->geo.width - 1, 0, 1, 1);
return;
}
for(i = trayicons; i; i = i->next)
SLIST_FOREACH(i, &trayicons, next)
{
XMapWindow(dpy, i->win);

View File

@ -95,7 +95,7 @@ tag_set(int tag)
}
/* Check for ignore_tag clients */
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->tag == MAXTAG + 1 && c->screen == selscreen)
{
al = True;
@ -111,13 +111,13 @@ tag_set(int tag)
}
/* To focus selected client of the via focusontag option */
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->focusontag == tag && c->screen == selscreen)
break;
/* No focusontag option found on any client, try to find the first of the tag */
if(!c)
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->tag == (uint)seltag[selscreen] && c->screen == selscreen)
break;
@ -237,7 +237,7 @@ uicb_tag_next_visible(uicb_t cmd)
return;
}
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->screen == selscreen)
occupied |= TagFlag(c->tag);
@ -278,7 +278,7 @@ uicb_tag_prev_visible(uicb_t cmd)
return;
}
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->screen == selscreen)
occupied |= TagFlag(c->tag);
@ -351,7 +351,7 @@ tag_swap(int s, int t1, int t2)
tags[s][t1] = tags[s][t2];
tags[s][t2] = t;
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
{
if(c->screen == s && c->tag == (uint)t1)
c->tag = t2;
@ -477,7 +477,7 @@ uicb_tag_urgent(uicb_t cmd)
(void)cmd;
/* Check if there is a urgent client */
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->flags & UrgentFlag)
{
screen_set_sel(c->screen);
@ -658,7 +658,7 @@ tag_delete(int s, int tag)
if(tag < 0 || tag > conf.ntag[s] || conf.ntag[s] == 1)
return;
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->screen == s && c->tag == (uint)tag)
{
warnx("Client(s) present in this tag, can't delete it");
@ -674,7 +674,7 @@ tag_delete(int s, int tag)
for(i = tag; i < (size_t)conf.ntag[s] + 1; ++i)
{
/* Set clients tag because of shift */
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
if(c->screen == s && c->tag == i + 1)
c->tag = i;
@ -751,7 +751,7 @@ uicb_tag_toggle_expose(uicb_t cmd)
{
if(strcmp(tags[selscreen][i].name, conf.tag_expose_name) == 0)
{
if(clients && sel->tag)
if(SLIST_FIRST(&clients) && sel->tag)
tag_set(sel->tag);
tag_delete(selscreen, i);

View File

@ -86,10 +86,13 @@ quit(void)
XSetErrorHandler(errorhandlerdummy);
/* Unmanage all clients */
for(c = clients; c; c = c->next)
while(!SLIST_EMPTY(&clients))
{
c = SLIST_FIRST(&clients);
client_unhide(c);
XReparentWindow(dpy, c->win, ROOT, c->geo.x, c->geo.y);
free(c);
SLIST_REMOVE_HEAD(&clients, next);
}
free(tags);
@ -230,7 +233,7 @@ scan(void)
}
/* Set update layout request */
for(c = clients; c; c = c->next)
SLIST_FOREACH(c, &clients, next)
{
if(c->tag > (uint)conf.ntag[c->screen])
c->tag = conf.ntag[c->screen];

View File

@ -51,6 +51,7 @@
#include <err.h>
#include <pthread.h>
#include <locale.h>
#include <sys/queue.h>
#include <sys/select.h>
#include <sys/types.h>
#include <sys/wait.h>
@ -472,7 +473,7 @@ struct clndx {
} clist_index[MAXCLIST];
/* Important Client */
Client *clients;
SLIST_HEAD(, Client) clients;
Client *sel;
/* Other */
@ -481,7 +482,7 @@ void (**event_handle)(XEvent*);
extern const func_name_list_t func_list[];
extern const func_name_list_t layout_list[];
uint numlockmask;
Systray *trayicons;
SLIST_HEAD(, Systray) trayicons;
Window traywin;
int tray_width;