use g_[s]list_next/previous consistantly, and check for "it" instead of "it != NULL" consistantly. props to Logan again :)

This commit is contained in:
Dana Jansens 2003-10-25 19:27:09 +00:00
parent 4cb183401c
commit 174de91c34
9 changed files with 71 additions and 61 deletions

View file

@ -119,7 +119,7 @@ void client_set_list()
if (size > 0) {
windows = g_new(Window, size);
win_it = windows;
for (it = client_list; it != NULL; it = it->next, ++win_it)
for (it = client_list; it; it = g_list_next(it), ++win_it)
*win_it = ((ObClient*)it->data)->window;
} else
windows = NULL;
@ -138,7 +138,7 @@ void client_set_list()
{
GSList *it;
for (it = self->transients; it; it = it->next) {
for (it = self->transients; it; it = g_slist_next(it)) {
if (!func(it->data, data)) return;
client_foreach_transient(it->data, func, data);
}
@ -153,7 +153,7 @@ void client_set_list()
} else {
GSList *it;
for (it = self->group->members; it; it = it->next)
for (it = self->group->members; it; it = g_slist_next(it))
if (it->data != self &&
!((ObClient*)it->data)->transient_for) {
if (!func(it->data, data)) return;
@ -314,7 +314,7 @@ void client_manage(Window window)
if (self->group) {
GSList *it;
for (it = self->group->members; it; it = it->next)
for (it = self->group->members; it; it = g_slist_next(it))
{
if (client_focused(it->data))
{
@ -457,7 +457,7 @@ void client_unmanage(ObClient *self)
if (self->transient_for == OB_TRAN_GROUP) { /* transient of group */
GSList *it;
for (it = self->group->members; it; it = it->next)
for (it = self->group->members; it; it = g_slist_next(it))
if (it->data != self)
((ObClient*)it->data)->transients =
g_slist_remove(((ObClient*)it->data)->transients, self);
@ -467,7 +467,7 @@ void client_unmanage(ObClient *self)
}
/* tell our transients that we're gone */
for (it = self->transients; it != NULL; it = it->next) {
for (it = self->transients; it; it = g_slist_next(it)) {
if (((ObClient*)it->data)->transient_for != OB_TRAN_GROUP) {
((ObClient*)it->data)->transient_for = NULL;
client_calc_layer(it->data);
@ -786,7 +786,7 @@ static void client_get_desktop(ObClient *self)
} else {
GSList *it;
for (it = self->group->members; it; it = it->next)
for (it = self->group->members; it; it = g_slist_next(it))
if (it->data != self &&
!((ObClient*)it->data)->transient_for) {
self->desktop = ((ObClient*)it->data)->desktop;
@ -1353,13 +1353,15 @@ void client_update_wmhints(ObClient *self)
/* remove from the old group if there was one */
if (self->group != NULL) {
/* remove transients of the group */
for (it = self->group->members; it; it = it->next)
for (it = self->group->members; it; it = g_slist_next(it))
self->transients = g_slist_remove(self->transients,
it->data);
/* remove myself from parents in the group */
if (self->transient_for == OB_TRAN_GROUP) {
for (it = self->group->members; it; it = it->next) {
for (it = self->group->members; it;
it = g_slist_next(it))
{
ObClient *c = it->data;
if (c != self && !c->transient_for)
@ -1379,7 +1381,9 @@ void client_update_wmhints(ObClient *self)
if (!self->transient_for) {
/* add other transients of the group that are already
set up */
for (it = self->group->members; it; it = it->next) {
for (it = self->group->members; it;
it = g_slist_next(it))
{
ObClient *c = it->data;
if (c != self && c->transient_for == OB_TRAN_GROUP)
self->transients =
@ -1433,7 +1437,7 @@ void client_update_title(ObClient *self)
/* look for duplicates and append a number */
nums = 0;
for (it = client_list; it; it = it->next)
for (it = client_list; it; it = g_list_next(it))
if (it->data != self) {
ObClient *c = it->data;
if (0 == strncmp(c->title, data, strlen(data)))
@ -1714,7 +1718,7 @@ ObClient *client_search_focus_tree(ObClient *self)
GSList *it;
ObClient *ret;
for (it = self->transients; it != NULL; it = it->next) {
for (it = self->transients; it; it = g_slist_next(it)) {
if (client_focused(it->data)) return it->data;
if ((ret = client_search_focus_tree(it->data))) return ret;
}
@ -1730,7 +1734,7 @@ ObClient *client_search_focus_tree_full(ObClient *self)
GSList *it;
gboolean recursed = FALSE;
for (it = self->group->members; it; it = it->next)
for (it = self->group->members; it; it = g_slist_next(it))
if (!((ObClient*)it->data)->transient_for) {
ObClient *c;
if ((c = client_search_focus_tree_full(it->data)))
@ -1780,7 +1784,7 @@ static void client_calc_layer_recursive(ObClient *self, ObClient *orig,
own = calc_layer(self);
self->layer = l > own ? l : own;
for (it = self->transients; it; it = it->next)
for (it = self->transients; it; it = g_slist_next(it))
client_calc_layer_recursive(it->data, orig,
l, raised ? raised : l != old);
@ -2243,7 +2247,7 @@ static void client_iconify_recursive(ObClient *self,
}
/* iconify all transients */
for (it = self->transients; it != NULL; it = it->next)
for (it = self->transients; it; it = g_slist_next(it))
if (it->data != self) client_iconify_recursive(it->data,
iconic, curdesk);
}
@ -2435,7 +2439,7 @@ void client_set_desktop_recursive(ObClient *self,
}
/* move all transients */
for (it = self->transients; it != NULL; it = it->next)
for (it = self->transients; it; it = g_slist_next(it))
if (it->data != self) client_set_desktop_recursive(it->data,
target, donthide);
}
@ -2451,7 +2455,7 @@ ObClient *client_search_modal_child(ObClient *self)
GSList *it;
ObClient *ret;
for (it = self->transients; it != NULL; it = it->next) {
for (it = self->transients; it; it = g_slist_next(it)) {
ObClient *c = it->data;
if ((ret = client_search_modal_child(c))) return ret;
if (c->modal) return c;
@ -2858,7 +2862,7 @@ ObClient *client_find_directional(ObClient *c, ObDirection dir)
best_score = -1;
best_client = NULL;
for(it = g_list_first(client_list); it; it = it->next) {
for(it = g_list_first(client_list); it; it = g_list_next(it)) {
cur = it->data;
/* the currently selected window isn't interesting */
@ -2995,7 +2999,7 @@ ObClient *client_search_top_transient(ObClient *self)
g_assert(self->group);
for (it = self->group->members; it; it = it->next) {
for (it = self->group->members; it; it = g_slist_next(it)) {
ObClient *c = it->data;
/* checking transient_for prevents infinate loops! */
@ -3019,7 +3023,7 @@ ObClient *client_search_focus_parent(ObClient *self)
} else {
GSList *it;
for (it = self->group->members; it; it = it->next) {
for (it = self->group->members; it; it = g_slist_next(it)) {
ObClient *c = it->data;
/* checking transient_for prevents infinate loops! */
@ -3042,7 +3046,7 @@ ObClient *client_search_parent(ObClient *self, ObClient *search)
} else {
GSList *it;
for (it = self->group->members; it; it = it->next) {
for (it = self->group->members; it; it = g_slist_next(it)) {
ObClient *c = it->data;
/* checking transient_for prevents infinate loops! */
@ -3105,7 +3109,7 @@ gint client_directional_edge_search(ObClient *c, ObDirection dir)
/* default: top of screen */
dest = a->y;
for(it = g_list_first(client_list); it; it = it->next) {
for(it = client_list; it; it = g_list_next(it)) {
gint his_edge_start, his_edge_end, his_offset;
ObClient *cur = it->data;
@ -3146,7 +3150,7 @@ gint client_directional_edge_search(ObClient *c, ObDirection dir)
/* default: bottom of screen */
dest = a->y + a->height;
for(it = g_list_first(client_list); it; it = it->next) {
for(it = client_list; it; it = g_list_next(it)) {
gint his_edge_start, his_edge_end, his_offset;
ObClient *cur = it->data;
@ -3188,7 +3192,7 @@ gint client_directional_edge_search(ObClient *c, ObDirection dir)
/* default: leftmost egde of screen */
dest = a->x;
for(it = g_list_first(client_list); it; it = it->next) {
for(it = client_list; it; it = g_list_next(it)) {
gint his_edge_start, his_edge_end, his_offset;
ObClient *cur = it->data;
@ -3230,7 +3234,7 @@ gint client_directional_edge_search(ObClient *c, ObDirection dir)
/* default: rightmost edge of screen */
dest = a->x + a->width;
for(it = g_list_first(client_list); it; it = it->next) {
for(it = client_list; it; it = g_list_next(it)) {
gint his_edge_start, his_edge_end, his_offset;
ObClient *cur = it->data;
@ -3281,7 +3285,7 @@ ObClient* client_under_pointer()
ObClient *ret = NULL;
if (screen_pointer_pos(&x, &y)) {
for (it = stacking_list; it != NULL; it = it->next) {
for (it = stacking_list; it; it = g_list_next(it)) {
if (WINDOW_IS_CLIENT(it->data)) {
ObClient *c = WINDOW_AS_CLIENT(it->data);
if (c->frame->visible &&

View file

@ -224,7 +224,7 @@ void dock_configure()
dock->w = dock->h = 0;
/* get the size */
for (it = dock->dock_apps; it; it = it->next) {
for (it = dock->dock_apps; it; it = g_list_next(it)) {
ObDockApp *app = it->data;
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
@ -241,7 +241,7 @@ void dock_configure()
spot = (config_dock_orient == OB_ORIENTATION_HORZ ? minw : minh) / 2;
/* position the apps */
for (it = dock->dock_apps; it; it = it->next) {
for (it = dock->dock_apps; it; it = g_list_next(it)) {
ObDockApp *app = it->data;
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:
@ -550,7 +550,7 @@ void dock_app_drag(ObDockApp *app, XMotionEvent *e)
/* which dock app are we on top of? */
stop = FALSE;
for (it = dock->dock_apps; it; it = it->next) {
for (it = dock->dock_apps; it; it = g_list_next(it)) {
over = it->data;
switch (config_dock_orient) {
case OB_ORIENTATION_HORZ:

View file

@ -216,7 +216,7 @@ static ObClient *find_transient_recursive(ObClient *c, ObClient *top,
GSList *it;
ObClient *ret;
for (it = c->transients; it; it = it->next) {
for (it = c->transients; it; it = g_slist_next(it)) {
if (it->data == top) return NULL;
ret = find_transient_recursive(it->data, top, skip);
if (ret && ret != skip && client_normal(ret)) return ret;
@ -266,14 +266,19 @@ ObClient* focus_fallback_target(ObFocusFallbackType type)
/* try for transient relations */
if (trans) {
if (old->transient_for == OB_TRAN_GROUP) {
for (it = focus_order[screen_desktop]; it; it = it->next) {
for (it = focus_order[screen_desktop]; it;
it = g_list_next(it))
{
GSList *sit;
for (sit = old->group->members; sit; sit = sit->next)
for (sit = old->group->members; sit;
sit = g_slist_next(sit))
{
if (sit->data == it->data)
if ((target =
focus_fallback_transient(sit->data, old)))
return target;
}
}
} else {
if ((target =
@ -295,8 +300,8 @@ ObClient* focus_fallback_target(ObFocusFallbackType type)
if (old->group) {
GSList *sit;
for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
for (sit = old->group->members; sit; sit = sit->next)
for (it = focus_order[screen_desktop]; it; it = g_list_next(it))
for (sit = old->group->members; sit; sit = g_slist_next(sit))
if (sit->data == it->data)
if (sit->data != old && client_normal(sit->data))
if (client_can_focus(sit->data))
@ -304,7 +309,7 @@ ObClient* focus_fallback_target(ObFocusFallbackType type)
}
#endif
for (it = focus_order[screen_desktop]; it != NULL; it = it->next)
for (it = focus_order[screen_desktop]; it; it = g_list_next(it))
if (type != OB_FOCUS_FALLBACK_UNFOCUSING || it->data != old)
if (client_normal(it->data) && client_can_focus(it->data))
return it->data;
@ -699,7 +704,7 @@ static void to_top(ObClient *c, guint d)
/* insert before first iconic window */
for (it = focus_order[d];
it && !((ObClient*)it->data)->iconic; it = it->next);
it && !((ObClient*)it->data)->iconic; it = g_list_next(it));
focus_order[d] = g_list_insert_before(focus_order[d], it, c);
}
}
@ -726,7 +731,7 @@ static void to_bottom(ObClient *c, guint d)
/* insert before first iconic window */
for (it = focus_order[d];
it && !((ObClient*)it->data)->iconic; it = it->next);
it && !((ObClient*)it->data)->iconic; it = g_list_next(it));
g_list_insert_before(focus_order[d], it, c);
}
}

View file

@ -50,7 +50,7 @@ KeyBindingTree *tree_build(GList *keylist)
if (g_list_length(keylist) <= 0)
return NULL; /* nothing in the list.. */
for (it = g_list_last(keylist); it != NULL; it = it->prev) {
for (it = g_list_last(keylist); it; it = g_list_previous(it)) {
p = ret;
ret = g_new0(KeyBindingTree, 1);
if (p == NULL) {
@ -58,7 +58,7 @@ KeyBindingTree *tree_build(GList *keylist)
/* this is the first built node, the bottom node of the tree */
ret->keylist = g_list_copy(keylist); /* shallow copy */
for (it = ret->keylist; it != NULL; it = it->next) /* deep copy */
for (it = ret->keylist; it; it = g_list_next(it)) /* deep copy */
it->data = g_strdup(it->data);
}
ret->first_child = p;

View file

@ -93,7 +93,7 @@ void mouse_grab_for_client(ObClient *client, gboolean grab)
GSList *it;
for (i = 0; i < OB_FRAME_NUM_CONTEXTS; ++i)
for (it = bound_contexts[i]; it != NULL; it = g_slist_next(it)) {
for (it = bound_contexts[i]; it; it = g_slist_next(it)) {
/* grab/ungrab the button */
ObMouseBinding *b = it->data;
Window win;
@ -124,7 +124,7 @@ static void grab_all_clients(gboolean grab)
{
GList *it;
for (it = client_list; it != NULL; it = it->next)
for (it = client_list; it; it = g_list_next(it))
mouse_grab_for_client(it->data, grab);
}
@ -134,14 +134,14 @@ void mouse_unbind_all()
GSList *it;
for(i = 0; i < OB_FRAME_NUM_CONTEXTS; ++i) {
for (it = bound_contexts[i]; it != NULL; it = it->next) {
for (it = bound_contexts[i]; it; it = g_slist_next(it)) {
ObMouseBinding *b = it->data;
gint j;
for (j = 0; j < OB_NUM_MOUSE_ACTIONS; ++j) {
GSList *it;
for (it = b->actions[j]; it; it = it->next)
for (it = b->actions[j]; it; it = g_slist_next(it))
action_unref(it->data);
g_slist_free(b->actions[j]);
}
@ -159,7 +159,7 @@ static gboolean fire_binding(ObMouseAction a, ObFrameContext context,
GSList *it;
ObMouseBinding *b;
for (it = bound_contexts[context]; it != NULL; it = it->next) {
for (it = bound_contexts[context]; it; it = g_slist_next(it)) {
b = it->data;
if (b->state == state && b->button == button)
break;
@ -314,7 +314,7 @@ gboolean mouse_bind(const gchar *buttonstr, const gchar *contextstr,
return FALSE;
}
for (it = bound_contexts[context]; it != NULL; it = it->next){
for (it = bound_contexts[context]; it; it = g_slist_next(it)) {
b = it->data;
if (b->state == state && b->button == button) {
b->actions[mact] = g_slist_append(b->actions[mact], action);

View file

@ -346,7 +346,7 @@ static gboolean place_transient(ObClient *client, gint *x, gint *y)
GSList *it;
gboolean first = TRUE;
gint l, r, t, b;
for (it = client->group->members; it; it = it->next) {
for (it = client->group->members; it; it = g_slist_next(it)) {
ObClient *m = it->data;
if (!(m == client || m->transient_for)) {
if (first) {

View file

@ -47,7 +47,7 @@ void resist_move_windows(ObClient *c, gint *x, gint *y)
cb = RECT_BOTTOM(c->frame->area);
if (config_resist_win)
for (it = stacking_list; it != NULL; it = it->next) {
for (it = stacking_list; it; it = g_list_next(it)) {
ObClient *target;
gint tl, tt, tr, tb; /* 1 past the target's edges on each side */
@ -187,7 +187,7 @@ void resist_size_windows(ObClient *c, gint *w, gint *h, ObCorner corn)
b = RECT_BOTTOM(c->frame->area);
if (config_resist_win) {
for (it = stacking_list; it != NULL; it = it->next) {
for (it = stacking_list; it; it = g_list_next(it)) {
if (!WINDOW_IS_CLIENT(it->data))
continue;
target = it->data;

View file

@ -283,7 +283,7 @@ void screen_startup(gboolean reconfig)
/* set the names */
screen_desktop_names = g_new(gchar*,
g_slist_length(config_desktops_names) + 1);
for (i = 0, it = config_desktops_names; it; ++i, it = it->next)
for (i = 0, it = config_desktops_names; it; ++i, it = g_slist_next(it))
screen_desktop_names[i] = it->data; /* dont strdup */
screen_desktop_names[i] = NULL;
PROP_SETSS(RootWindow(ob_display, ob_screen),
@ -360,7 +360,7 @@ void screen_resize()
screen_update_areas();
dock_configure();
for (it = client_list; it; it = it->next)
for (it = client_list; it; it = g_list_next(it))
client_move_onscreen(it->data, FALSE);
}
@ -392,7 +392,7 @@ void screen_set_num_desktops(guint num)
screen_update_desktop_names();
/* move windows on desktops that will no longer exist! */
for (it = client_list; it != NULL; it = it->next) {
for (it = client_list; it; it = g_list_next(it)) {
ObClient *c = it->data;
if (c->desktop >= num && c->desktop != DESKTOP_ALL)
client_set_desktop(c, num - 1, FALSE);
@ -868,7 +868,7 @@ void screen_show_desktop(gboolean show)
if (show) {
/* bottom to top */
for (it = g_list_last(stacking_list); it != NULL; it = it->prev) {
for (it = g_list_last(stacking_list); it; it = g_list_previous(it)) {
if (WINDOW_IS_CLIENT(it->data)) {
ObClient *client = it->data;
if (client->frame->visible && !client_should_show(client))
@ -877,7 +877,7 @@ void screen_show_desktop(gboolean show)
}
} else {
/* top to bottom */
for (it = stacking_list; it != NULL; it = it->next) {
for (it = stacking_list; it; it = g_list_next(it)) {
if (WINDOW_IS_CLIENT(it->data)) {
ObClient *client = it->data;
if (!client->frame->visible && client_should_show(client))
@ -888,7 +888,7 @@ void screen_show_desktop(gboolean show)
if (show) {
/* focus desktop */
for (it = focus_order[screen_desktop]; it; it = it->next)
for (it = focus_order[screen_desktop]; it; it = g_list_next(it))
if (((ObClient*)it->data)->type == OB_CLIENT_TYPE_DESKTOP &&
client_focus(it->data))
break;
@ -1021,7 +1021,7 @@ void screen_update_areas()
o = MIN(o, area[i][x].x);
for (x = 0; x < screen_num_monitors; ++x) {
for (it = client_list; it; it = it->next) {
for (it = client_list; it; it = g_list_next(it)) {
ObClient *c = it->data;
screen_area_add_strut_left(&c->strut,
&monitor_area[x],
@ -1043,7 +1043,7 @@ void screen_update_areas()
o = MIN(o, area[i][x].y);
for (x = 0; x < screen_num_monitors; ++x) {
for (it = client_list; it; it = it->next) {
for (it = client_list; it; it = g_list_next(it)) {
ObClient *c = it->data;
screen_area_add_strut_top(&c->strut,
&monitor_area[x],
@ -1065,7 +1065,7 @@ void screen_update_areas()
o = MAX(o, area[i][x].x + area[i][x].width - 1);
for (x = 0; x < screen_num_monitors; ++x) {
for (it = client_list; it; it = it->next) {
for (it = client_list; it; it = g_list_next(it)) {
ObClient *c = it->data;
screen_area_add_strut_right(&c->strut,
&monitor_area[x],
@ -1090,7 +1090,7 @@ void screen_update_areas()
o = MAX(o, area[i][x].y + area[i][x].height - 1);
for (x = 0; x < screen_num_monitors; ++x) {
for (it = client_list; it; it = it->next) {
for (it = client_list; it; it = g_list_next(it)) {
ObClient *c = it->data;
screen_area_add_strut_bottom(&c->strut,
&monitor_area[x],
@ -1126,7 +1126,7 @@ void screen_update_areas()
/* the area has changed, adjust all the maximized
windows */
for (it = client_list; it; it = it->next) {
for (it = client_list; it; it = g_list_next(it)) {
ObClient *c = it->data;
if (i < screen_num_desktops) {
if (c->desktop == i)

View file

@ -360,10 +360,11 @@ void stacking_add_nonintrusive(ObWindow *win)
GList *it;
if (client->group)
for (it = stacking_list; !parent && it; it = it->next) {
for (it = stacking_list; !parent && it; it = g_list_next(it)) {
if ((sit = g_slist_find(client->group->members, it->data)))
for (sit = client->group->members; !parent && sit;
sit = sit->next) {
sit = g_slist_next(sit))
{
ObClient *c = sit->data;
/* checking transient_for prevents infinate loops! */
if (sit->data == it->data && !c->transient_for)