void update_current(void) { if (mon->desk->focus == NULL) ewmh_update_active_window(); else focus_node(mon, mon->desk, mon->desk->focus, true); put_status(); }
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 window_unfocus_last() { if (lastfocus) { window_unfocus(lastfocus); } hsobject_unlink_by_name(g_client_object, "focus"); // give focus to root window XSetInputFocus(g_display, g_root, RevertToPointerRoot, CurrentTime); if (lastfocus) { /* only emit the hook if the focus *really* changes */ hook_emit_list("focus_changed", "0x0", "", NULL); ewmh_update_active_window(None); tag_update_each_focus_layer(); } lastfocus = 0; }
void window_focus(Window window) { HSClient* client = get_client_from_window(window); assert(client != NULL); // set keyboard focus if (!client->neverfocus) { XSetInputFocus(g_display, window, RevertToPointerRoot, CurrentTime); } else client_sendevent(client, g_wmatom[WMTakeFocus]); if (window != lastfocus) { /* FIXME: this is a workaround because window_focus always is called * twice. see BUGS for more information * * only emit the hook if the focus *really* changes */ // unfocus last one window_unfocus(lastfocus); hsobject_link(g_client_object, &client->object, "focus"); ewmh_update_active_window(window); tag_update_each_focus_layer(); char* title = client ? client->title->str : "?"; char winid_str[STRING_BUF_SIZE]; snprintf(winid_str, STRING_BUF_SIZE, "0x%x", (unsigned int)window); hook_emit_list("focus_changed", winid_str, title, NULL); } // change window-colors HSDebug("window_focus ACTIVE\n"); window_update_border(window, g_window_border_active_color); lastfocus = window; /* do some specials for the max layout */ bool is_max_layout = frame_focused_window(g_cur_frame) == window && g_cur_frame->content.clients.layout == LAYOUT_MAX && get_current_monitor()->tag->floating == false; if (*g_raise_on_focus || is_max_layout) { client_raise(client); } tag_update_focus_layer(get_current_monitor()->tag); grab_client_buttons(get_client_from_window(window), true); client_set_urgent(client, false); }