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); }
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(); }
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); }
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); } } } }
void enable_motion_recorder(void) { window_raise(motion_recorder); window_show(motion_recorder); }