Esempio n. 1
0
File: monitor.c Progetto: dj95/bspwm
void update_root(monitor_t *m, xcb_rectangle_t *rect)
{
	xcb_rectangle_t last_rect = m->rectangle;
	m->rectangle = *rect;
	if (m->root == XCB_NONE) {
		uint32_t values[] = {XCB_EVENT_MASK_ENTER_WINDOW};
		m->root = xcb_generate_id(dpy);
		xcb_create_window(dpy, XCB_COPY_FROM_PARENT, m->root, root,
		                  rect->x, rect->y, rect->width, rect->height, 0,
		                  XCB_WINDOW_CLASS_INPUT_ONLY, XCB_COPY_FROM_PARENT, XCB_CW_EVENT_MASK, values);
		xcb_icccm_set_wm_class(dpy, m->root, sizeof(ROOT_WINDOW_IC), ROOT_WINDOW_IC);
		window_lower(m->root);
		if (focus_follows_pointer) {
			window_show(m->root);
		}
	} else {
		window_move_resize(m->root, rect->x, rect->y, rect->width, rect->height);
		put_status(SBSC_MASK_MONITOR_GEOMETRY, "monitor_geometry 0x%08X %ux%u+%i+%i\n",
		           m->id, rect->width, rect->height, rect->x, rect->y);
	}
	for (desktop_t *d = m->desk_head; d != NULL; d = d->next) {
		for (node_t *n = first_extrema(d->root); n != NULL; n = next_leaf(n, d->root)) {
			if (n->client == NULL) {
				continue;
			}
			adapt_geometry(&last_rect, rect, n);
		}
		arrange(m, d);
	}
}
Esempio n. 2
0
void center_pointer(xcb_rectangle_t r)
{
	int16_t cx = r.x + r.width / 2;
	int16_t cy = r.y + r.height / 2;
	window_lower(motion_recorder);
	xcb_warp_pointer(dpy, XCB_NONE, root, 0, 0, 0, 0, cx, cy);
	window_raise(motion_recorder);
}
Esempio n. 3
0
monitor_t *make_monitor(xcb_rectangle_t rect)
{
    monitor_t *m = malloc(sizeof(monitor_t));
    snprintf(m->name, sizeof(m->name), "%s%02d", DEFAULT_MON_NAME, ++monitor_uid);
    m->prev = m->next = NULL;
    m->desk = m->desk_head = m->desk_tail = NULL;
    m->rectangle = rect;
    m->top_padding = m->right_padding = m->bottom_padding = m->left_padding = 0;
    m->wired = true;
    m->num_sticky = 0;
    uint32_t mask = XCB_CW_EVENT_MASK;
    uint32_t values[] = {XCB_EVENT_MASK_ENTER_WINDOW};
    m->root = xcb_generate_id(dpy);
    xcb_create_window(dpy, XCB_COPY_FROM_PARENT, m->root, root, rect.x, rect.y, rect.width, rect.height, 0, XCB_WINDOW_CLASS_INPUT_ONLY, XCB_COPY_FROM_PARENT, mask, values);
    window_lower(m->root);
    if (focus_follows_pointer)
        window_show(m->root);
    return m;
}
Esempio n. 4
0
void query_pointer(xcb_window_t *win, xcb_point_t *pt)
{
	window_lower(motion_recorder);

	xcb_query_pointer_reply_t *qpr = xcb_query_pointer_reply(dpy, xcb_query_pointer(dpy, root), NULL);

	if (qpr != NULL) {
		if (win != NULL) {
			*win = qpr->child;
		}
		if (pt != NULL) {
			*pt = (xcb_point_t) {qpr->root_x, qpr->root_y};
		}
	}

	free(qpr);

	window_raise(motion_recorder);
}