use g_[s]list_next/previous consistantly, and check for "it" instead of "it != NULL" consistantly. props to Logan again :)
@@ -119,7 +119,7 @@ /* create an array of the window ids */
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_foreach_transient(ObClient *self, ObClientForeachFunc func, void *data)
{ 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 @@ client_foreach_ancestor(self->transient_for, func, data);
} 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 @@
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 @@ /* tell our parent(s) that we're gone */
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 @@ g_slist_remove(self->transient_for->transients, 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 @@ trdesk = TRUE;
} 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 @@ (self->group ? self->group->leader : None)) {
/* 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 @@ transient myself */
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 @@ self->title_count = 1;
/* 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 @@ {
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 @@ } else {
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 @@ old = self->layer;
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 @@ screen_update_areas();
} /* 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 @@ focus_order_to_bottom(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 @@ {
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 @@
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 @@ GSList *it;
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 @@ return self->transient_for;
} 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 @@ return 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 @@
/* 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 @@
/* 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 @@
/* 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 @@
/* 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 @@ GList *it;
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 &&
@@ -224,7 +224,7 @@
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 @@
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 @@ y -= dock->y;
/* 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:
@@ -216,7 +216,7 @@ {
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 @@
/* 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 @@ /* try for group relations */
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 @@ return sit->data;
} #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 @@ GList *it;
/* 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 @@ GList *it;
/* 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); } }
@@ -50,7 +50,7 @@
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 @@ GList *it;
/* 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;
@@ -93,7 +93,7 @@ gint i;
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 @@ gint i;
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 @@ {
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 @@ g_warning("invalid context '%s'", 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);
@@ -346,7 +346,7 @@ } else {
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) {
@@ -47,7 +47,7 @@ cr = RECT_RIGHT(c->frame->area);
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 @@ t = RECT_TOP(c->frame->area);
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;
@@ -283,7 +283,7 @@
/* 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 @@
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 @@ /* may be some unnamed desktops that we need to fill in with names */
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 @@ screen_showing_desktop = 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 @@ }
} } 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 @@ }
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 @@ for (x = 1; x < screen_num_monitors; ++x)
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 @@ for (x = 1; x < screen_num_monitors; ++x)
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 @@ for (x = 1; x < screen_num_monitors; ++x)
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 @@ for (x = 1; x < screen_num_monitors; ++x)
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 @@ /* XXX optimize when this is run? */
/* 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)
@@ -360,10 +360,11 @@ GSList *sit;
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)