2 * Copyright (c) 2011-2012, Andy Spencer <andy753421@gmail.com>
4 * Permission to use, copy, modify, and/or distribute this software for any
5 * purpose with or without fee is hereby granted, provided that the above
6 * copyright notice and this permission notice appear in all copies.
8 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
9 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
10 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
11 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
12 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
13 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 /* Brain-dead multiple desktop manager */
34 /* Window management functions */
39 int wm_handle_event(win_t *win, event_t ev, mod_t mod, ptr_t ptr)
42 if (!win || !mod.MODKEY || mod.up || new == tag ||
47 list_t *node = list_find(tags[tag], win);
50 tags[tag] = list_remove(tags[tag], node, 0);
51 tags[new] = list_insert(tags[new], win);
52 sys_show(win, ST_HIDE);
54 for (list_t *cur = tags[new]; cur; cur = cur->next)
55 sys_show(cur->data, ST_SHOW);
56 for (list_t *cur = tags[tag]; cur; cur = cur->next)
57 sys_show(cur->data, ST_HIDE);
63 int wm_handle_ptr(win_t *cwin, ptr_t ptr)
68 int wm_handle_state(win_t *win, state_t prev, state_t next)
73 void wm_insert(win_t *win)
75 tags[tag] = list_insert(tags[tag], win);
78 void wm_remove(win_t *win)
80 for (int i = 0; i < 10; i++) {
81 list_t *node = list_find(tags[i], win);
84 tags[i] = list_remove(tags[i], node, 0);
90 event_t keys[] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9'};
91 for (int i = 0; i < countof(keys); i++) {
92 sys_watch(NULL, keys[i], MOD(.MODKEY=1));
93 sys_watch(NULL, keys[i], MOD(.MODKEY=1,.shift=1));
99 for (int i = 0; i < 10; i++) {
101 sys_show(tags[i]->data, ST_SHOW);
102 tags[i] = list_remove(tags[i], tags[i], 0);