6 stack_t *make_stack(node_t *n)
8 stack_t *s = malloc(sizeof(stack_t));
10 s->prev = s->next = NULL;
14 void stack_insert_after(stack_t *a, node_t *n)
16 stack_t *s = make_stack(n);
18 stack_head = stack_tail = s;
32 void stack_insert_before(stack_t *a, node_t *n)
34 stack_t *s = make_stack(n);
36 stack_head = stack_tail = s;
50 void remove_stack(stack_t *s)
67 void remove_stack_node(node_t *n)
69 for (stack_t *s = stack_head; s != NULL; s = s->next)
78 PRINTF("stack %X\n", n->client->window);
80 if (stack_head == NULL) {
81 stack_insert_after(NULL, n);
82 } else if (n->client->fullscreen) {
83 stack_insert_after(stack_tail, n);
84 window_raise(n->client->window);
86 if (n->client->floating && !auto_raise)
88 stack_t *latest_tiled = NULL;
89 stack_t *oldest_floating = NULL;
90 for (stack_t *s = stack_tail; s != NULL; s = s->prev) {
92 if (s->node->client->floating == n->client->floating) {
93 stack_insert_after(s, n);
94 window_above(n->client->window, s->node->client->window);
96 } else if (latest_tiled == NULL && !s->node->client->floating) {
98 } else if (s->node->client->floating) {
103 if (latest_tiled == NULL && oldest_floating == NULL)
105 if (n->client->floating) {
106 window_above(n->client->window, latest_tiled->node->client->window);
107 stack_insert_after(latest_tiled, n);
109 window_below(n->client->window, oldest_floating->node->client->window);
110 stack_insert_before(oldest_floating, n);
115 void stack_under(node_t *n)
117 PRINTF("stack under %X\n", n->client->window);
119 if (stack_head == NULL) {
120 stack_insert_after(NULL, n);
121 } else if (n->client->fullscreen) {
124 if (n->client->floating && !auto_raise)
126 stack_t *latest_tiled = NULL;
127 stack_t *oldest_floating = NULL;
128 for (stack_t *s = stack_head; s != NULL; s = s->next) {
130 if (s->node->client->floating == n->client->floating) {
131 stack_insert_before(s, n);
132 window_below(n->client->window, s->node->client->window);
134 } else if (!s->node->client->floating) {
136 } else if (oldest_floating == NULL && s->node->client->floating) {
141 if (latest_tiled == NULL && oldest_floating == NULL)
143 if (n->client->floating) {
144 window_above(n->client->window, latest_tiled->node->client->window);
145 stack_insert_after(latest_tiled, n);
147 window_below(n->client->window, oldest_floating->node->client->window);
148 stack_insert_before(oldest_floating, n);