+xcb_window_t
+get_sibling(struct ws_win *win, int mode)
+{
+ struct ws_win *w = win;
+
+ switch (mode) {
+ case SWM_STACK_TOP:
+ TAILQ_FOREACH_REVERSE(w, &w->ws->winlist, ws_win_list, entry)
+ if (w != win && !w->floating && !w->iconic)
+ break;
+ break;
+ case SWM_STACK_ABOVE:
+ do {
+ w = TAILQ_NEXT(w, entry);
+ } while (w != NULL && (w == win || w->floating || w->iconic));
+ break;
+ case SWM_STACK_BELOW:
+ do {
+ w = TAILQ_PREV(w, ws_win_list, entry);
+ } while (w != NULL && (w == win || w->floating || w->iconic));
+ break;
+ case SWM_STACK_BOTTOM:
+ TAILQ_FOREACH(w, &w->ws->winlist, entry)
+ if (w != win && !w->floating && !w->iconic)
+ break;
+ break;
+ default:
+ w = NULL;
+ }
+
+ if (w == NULL)
+ return (win->ws->r->id);
+ else
+ return (w->id);
+}
+