+/* Raise the window in the floating */
+static void raise_float(win_t *win)
+{
+ printf("raise_float: %p\n", win);
+ list_t *cur;
+ for (cur = wm_dpy->flts; cur; cur = cur->next)
+ if (FLT(cur)->win == win)
+ break;
+ if (cur) {
+ flt_t *flt = cur->data;
+ wm_dpy->flts = list_remove(wm_dpy->flts, cur, 0);
+ wm_dpy->flts = list_append(wm_dpy->flts, flt);
+ sys_raise(win);
+ }
+}
+
+/* Toggle between floating and tiling layers */
+static void switch_layer(void)
+{
+ printf("switch_float: %p %d\n",
+ wm_dpy, wm_dpy->layer);
+ wm_dpy->layer = !wm_dpy->layer;
+ wm_update();
+}
+
+/* Move current window between floating and tiling layers */
+static void set_layer(win_t *win)
+{
+ if (!win) return;
+ printf("set_float: %p %p\n", wm_dpy, win);
+ wm_dpy->layer = !cut_win(win, wm_tag);
+ put_win(win, wm_tag, wm_dpy->layer);
+ wm_update();
+}
+
+/* Allocate a new tag */
+static tag_t *tag_new(list_t *screens, const char *name)
+{
+ tag_t *tag = new0(tag_t);
+ strncpy(tag->name, name, sizeof(tag->name));
+ for (list_t *cur = screens; cur; cur = cur->next) {
+ dpy_t *dpy = new0(dpy_t);
+ dpy->geom = cur->data;
+ tag->dpys = list_append(tag->dpys, dpy);
+ }
+ tag->dpy = tag->dpys->data;
+ for (list_t *dpy = tag->dpys; dpy; dpy = dpy->next)
+ if (DPY(dpy)->geom->z > tag->dpy->geom->z)
+ tag->dpy = dpy->data;
+ return tag;
+}
+
+/* Search for a tag
+ * If it does not exist it is based on the
+ * display geometry in wm->screens */
+static tag_t *tag_find(const char *name)
+{
+ tag_t *tag = NULL;
+ for (list_t *cur = wm->tags; cur; cur = cur->next)
+ if (!strcmp(name, TAG(cur)->name)) {
+ tag = cur->data;
+ break;
+ }
+ if (!tag) {
+ tag = tag_new(wm->screens, name);
+ wm->tags = list_append(wm->tags, tag);
+ }
+ return tag;
+}
+
+/* Move the window from the current tag to the new tag
+ * Unlike wmii, only remove the current tag, not all tags */
+static void tag_set(win_t *win, const char *name)
+{
+ printf("tag_set: %p %s\n", win, name);
+ if (!strcmp(wm_tag->name, name))
+ return;
+ tag_t *tag = tag_find(name);
+ layer_t layer = cut_win(win, wm_tag);
+ put_win(win, tag, layer);
+ set_focus(wm_focus);
+}
+
+/* Switch to a different tag */
+static void tag_switch(const char *name)
+{
+ printf("tag_switch: %s\n", name);
+ tag_t *old = wm_tag;
+ if ((wm_col == NULL || wm_row == NULL) && wm_flt == NULL) {
+ while (old->dpys) {
+ dpy_t *dpy = old->dpys->data;
+ while (dpy->cols)
+ dpy->cols = list_remove(dpy->cols, dpy->cols, 1);
+ old->dpys = list_remove(old->dpys, old->dpys, 1);
+ }
+ list_t *ltag = list_find(wm->tags, old);
+ wm->tags = list_remove(wm->tags, ltag, 1);
+ }
+ wm_tag = tag_find(name);
+}
+
+/* Tile all windows in the given display
+ * This performs all the actual window tiling
+ * Currently supports split, stack and maximized modes */
+static void wm_update_cols(dpy_t *dpy)