Ejemplo n.º 1
0
void motion_notify(xcb_generic_event_t *evt)
{
	PUTS("motion notify");

	xcb_motion_notify_event_t *e = (xcb_motion_notify_event_t *) evt;

	int dtime = e->time - last_motion_time;
	if (dtime > 1000) {
		last_motion_time = e->time;
		last_motion_x = e->event_x;
		last_motion_y = e->event_y;
		return;
	}

	int mdist = abs(e->event_x - last_motion_x) + abs(e->event_y - last_motion_y);
	if (mdist < 10)
		return;

	disable_motion_recorder();

	xcb_window_t win = XCB_NONE;
	xcb_point_t pt = {e->root_x, e->root_y};
	query_pointer(&win, NULL);

	bool backup = pointer_follows_monitor;
	auto_raise = false;
	pointer_follows_monitor = false;
	if (!window_focus(win)) {
		monitor_t *m = monitor_from_point(pt);
		if (m != NULL && m != mon)
			focus_node(m, m->desk, m->desk->focus);
	}
	pointer_follows_monitor = backup;
	auto_raise = true;
}
Ejemplo n.º 2
0
void enter_notify(xcb_generic_event_t *evt)
{
	xcb_enter_notify_event_t *e = (xcb_enter_notify_event_t *) evt;
	xcb_window_t win = e->event;

	PRINTF("enter notify %X %d %d\n", win, e->mode, e->detail);

	if (e->mode != XCB_NOTIFY_MODE_NORMAL ||
	    (mon->desk->focus != NULL &&
	     mon->desk->focus->client->window == win)) {
		return;
	}

	xcb_get_window_attributes_reply_t *wa = xcb_get_window_attributes_reply(dpy, xcb_get_window_attributes(dpy, motion_recorder), NULL);

	if (wa == NULL) {
		return;
	}

	if (wa->map_state == XCB_MAP_STATE_UNMAPPED) {
		enable_motion_recorder();
	} else {
		disable_motion_recorder();
	}
}
Ejemplo n.º 3
0
void focus_node(monitor_t *m, desktop_t *d, node_t *n, bool is_mapped)
{
    if (n == NULL)
        return;

    PRINTF("focus node %X\n", n->client->window);

    split_mode = MODE_AUTOMATIC;
    n->client->urgent = false;

    if (is_mapped) {
        if (mon != m) {
            for (desktop_t *cd = mon->desk_head; cd != NULL; cd = cd->next)
                window_draw_border(cd->focus, true, false);
            for (desktop_t *cd = m->desk_head; cd != NULL; cd = cd->next)
                if (cd != d)
                    window_draw_border(cd->focus, true, true);
            if (d->focus == n)
                window_draw_border(n, true, true);
        }
        if (d->focus != n) {
            window_draw_border(d->focus, false, true);
            window_draw_border(n, true, true);
        }
        xcb_set_input_focus(dpy, XCB_INPUT_FOCUS_POINTER_ROOT, n->client->window, XCB_CURRENT_TIME);
    }

    if (focus_follows_pointer) {
        xcb_window_t win = XCB_NONE;
        get_pointed_window(&win);
        if (win != n->client->window)
            enable_motion_recorder();
        else
            disable_motion_recorder();
    }

    if (!is_tiled(n->client)) {
        if (!adaptative_raise || !might_cover(d, n))
            window_raise(n->client->window);
    } else {
        window_pseudo_raise(d, n->client->window);
    }

    if (d->focus != n) {
        d->last_focus = d->focus;
        d->focus = n;
    }

    ewmh_update_active_window();
    put_status();
}
Ejemplo n.º 4
0
void motion_notify(xcb_generic_event_t *evt)
{
	xcb_motion_notify_event_t *e = (xcb_motion_notify_event_t *) evt;

	PRINTF("motion notify %X %i %i\n", e->event, e->root_x, e->root_y);

	int dtime = e->time - last_motion_time;
	if (dtime > 1000) {
		last_motion_time = e->time;
		last_motion_x = e->event_x;
		last_motion_y = e->event_y;
		return;
	}

	int mdist = abs(e->event_x - last_motion_x) + abs(e->event_y - last_motion_y);
	if (mdist < 10) {
		return;
	}

	xcb_window_t win = XCB_NONE;
	xcb_point_t pt = {e->root_x, e->root_y};
	query_pointer(&win, NULL);

	bool pfm_backup = pointer_follows_monitor;
	bool pff_backup = pointer_follows_focus;
	auto_raise = false;
	pointer_follows_monitor = false;
	pointer_follows_focus = false;
	coordinates_t loc;
	if (locate_window(win, &loc)) {
		if (loc.node != mon->desk->focus) {
			focus_node(loc.monitor, loc.desktop, loc.node);
		}
	} else {
		monitor_t *m = monitor_from_point(pt);
		if (m != NULL && m != mon) {
			focus_node(m, m->desk, m->desk->focus);
		}
	}
	pointer_follows_monitor = pfm_backup;
	pointer_follows_focus = pff_backup;
	auto_raise = true;

	disable_motion_recorder();
}