Пример #1
0
void initialize_presel_feedback(node_t *n)
{
	if (n == NULL || n->presel == NULL || n->presel->feedback != XCB_NONE) {
		return;
	}

	xcb_window_t win = xcb_generate_id(dpy);
	uint32_t mask = XCB_CW_BACK_PIXEL | XCB_CW_SAVE_UNDER;
	uint32_t values[] = {get_color_pixel(presel_feedback_color), 1};
	xcb_create_window(dpy, XCB_COPY_FROM_PARENT, win, root, 0, 0, 1, 1, 0, XCB_WINDOW_CLASS_INPUT_OUTPUT,
			          XCB_COPY_FROM_PARENT, mask, values);

	xcb_icccm_set_wm_class(dpy, win, sizeof(PRESEL_FEEDBACK_IC), PRESEL_FEEDBACK_IC);
	stacking_list_t *s = stack_tail;
	while (s != NULL && !IS_TILED(s->node->client)) {
		s = s->prev;
	}
	if (s != NULL) {
		window_above(win, s->node->id);
	}
	n->presel->feedback = win;
}
Пример #2
0
void stack(node_t *n, bool focused)
{
    if (IS_FLOATING(n->client) && !auto_raise) {
        return;
    }

    if (stack_head == NULL) {
        stack_insert_after(NULL, n);
    } else {
        stacking_list_t *s = (focused ? limit_above(n) : limit_below(n));
        if (s == NULL) {
            return;
        }
        int i = stack_cmp(n->client, s->node->client);
        if (i < 0 || (i == 0 && !focused)) {
            stack_insert_before(s, n);
            window_below(n->client->window, s->node->client->window);
        } else {
            stack_insert_after(s, n);
            window_above(n->client->window, s->node->client->window);
        }
    }
}
Пример #3
0
void stack(node_t *n, stack_flavor_t f)
{
	PRINTF("stack %X\n", n->client->window);

	if (stack_head == NULL) {
		stack_insert_after(NULL, n);
	} else if (n->client->fullscreen) {
		if (f == STACK_ABOVE) {
			stack_insert_after(stack_tail, n);
			window_raise(n->client->window);
		}
	} else {
		if (f == STACK_ABOVE && n->client->floating && !auto_raise)
			return;
		stacking_list_t *latest_tiled = NULL;
		stacking_list_t *oldest_floating = NULL;
		stacking_list_t *oldest_fullscreen = NULL;
		for (stacking_list_t *s = (f == STACK_ABOVE ? stack_tail : stack_head); s != NULL; s = (f == STACK_ABOVE ? s->prev : s->next)) {
			if (s->node != n) {
				if (s->node->client->fullscreen) {
					if (oldest_fullscreen == NULL)
						oldest_fullscreen = s;
					continue;
				}
				if (s->node->client->floating == n->client->floating) {
					if (f == STACK_ABOVE) {
						stack_insert_after(s, n);
						window_above(n->client->window, s->node->client->window);
					} else {
						stack_insert_before(s, n);
						window_below(n->client->window, s->node->client->window);
					}
					return;
				} else if ((f != STACK_ABOVE || latest_tiled == NULL) && !s->node->client->floating) {
					latest_tiled = s;
				} else if ((f == STACK_ABOVE || oldest_floating == NULL) && s->node->client->floating) {
					oldest_floating = s;
				}
			}
		}
		if (latest_tiled == NULL && oldest_floating == NULL && oldest_fullscreen == NULL)
			return;
		if (n->client->floating) {
			if (latest_tiled != NULL) {
				window_above(n->client->window, latest_tiled->node->client->window);
				stack_insert_after(latest_tiled, n);
			} else if (oldest_fullscreen != NULL) {
				window_below(n->client->window, oldest_fullscreen->node->client->window);
				stack_insert_before(oldest_fullscreen, n);
			}
		} else {
			if (oldest_floating != NULL) {
				window_below(n->client->window, oldest_floating->node->client->window);
				stack_insert_before(oldest_floating, n);
			} else if (oldest_fullscreen != NULL) {
				window_below(n->client->window, oldest_fullscreen->node->client->window);
				stack_insert_before(oldest_fullscreen, n);
			}
		}
	}
}