void fallback_arrange(void) { int clients_len = sglib_client_t_len(client_list); if (clients_len == 0) return; uint16_t screen_width = wm_conf.screen->width_in_pixels; uint16_t screen_height = wm_conf.screen->height_in_pixels; uint16_t client_width = screen_width / clients_len; client_t *client = client_list; int i = 0; fprintf(stderr, "Fallback window arrangement is being used. You should define arrange-hook.\n"); while (i < clients_len) { client->rect.x = i * client_width; client->rect.y = 0; client->rect.width = client_width; client->rect.height = screen_height; client->border_width = 0; update_client_geometry(client); ++i; client = client->next; } client_t *focus_client = get_focus_client(); if (focus_client) { draw_border(focus_client); } else if (client_list) { set_focus_client(client_list); draw_border(client_list); } }
static SCM scm_focus_client(SCM client_smob) { client_t *client = NULL; if (scm_is_eq(client_smob, SCM_UNSPECIFIED)) client = client_list; // Use first client in list if we aren't given a good client_smob else client = (client_t *)SCM_SMOB_DATA(client_smob); if (!client) return SCM_UNSPECIFIED; if (!is_mapped(client)) return SCM_UNSPECIFIED; set_focus_client(client); return SCM_UNSPECIFIED; }
void run_arrange_hook(void) { SCM arrange_hook_sym = scm_from_locale_symbol("arrange-hook"); if (scm_defined_p(arrange_hook_sym, SCM_UNDEFINED) == SCM_BOOL_T) { scm_c_eval_string("(arrange-hook)"); } else { fallback_arrange(); } client_t *focus_client = get_focus_client(); if (focus_client) { draw_border(focus_client); } else if (client_list) { set_focus_client(client_list); draw_border(client_list); } }
void auto_focus_pointer(void) { xcb_query_pointer_cookie_t c = xcb_query_pointer_unchecked(wm_conf.connection, wm_conf.screen->root); xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(wm_conf.connection, c, NULL); if (reply) { client_t *focus_client = get_focus_client(); client_t *pointer_client = find_client(reply->child); if (!wm_conf.pointer_window) /* pointer_window hasn't been initialized yet */ wm_conf.pointer_window = reply->child; if (pointer_client) { if (wm_conf.pointer_window != pointer_client->window) { set_focus_client(pointer_client); draw_border(pointer_client); } wm_conf.pointer_window = pointer_client->window; } free(reply); } }