+/* 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);
+ 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, int name)
+{
+ tag_t *tag = new0(tag_t);
+ tag->name = 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;
+ 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(int name)
+{
+ tag_t *tag = NULL;
+ for (list_t *cur = wm->tags; cur; cur = cur->next)
+ if (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, int name)
+{
+ printf("tag_set: %p %d\n", win, name);
+ if (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(int name)
+{
+ printf("tag_switch: %d\n", name);
+ if ((wm_col == NULL || wm_row == NULL) && wm_flt == NULL)
+ wm->tags = list_remove(wm->tags,
+ list_find(wm->tags, wm_tag));
+ 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)