添加调整焦点快捷键

This commit is contained in:
2025-08-26 16:45:47 +08:00
parent 84b07ebcf4
commit a0c8baa863
3 changed files with 33 additions and 0 deletions

View File

@@ -6,3 +6,4 @@ void spawn(const user_action_arg_t *arg);
void quit(const user_action_arg_t *arg);
void select_tag(const user_action_arg_t *arg);
void kill_client(const user_action_arg_t *arg);
void focus_stack(const user_action_arg_t *arg);

View File

@@ -91,6 +91,8 @@ const keybinding_t keys[] = {
{SUPER | SHIFT, XK_q, quit, {.b = false}},
{SUPER | CTRL, XK_r, quit, {.b = true}},
{SUPER | SHIFT, XK_c, kill_client, {0}},
{ALT, XK_j, focus_stack, {.b = true}},
{ALT, XK_k, focus_stack, {.b = false}},
{SUPER, XK_1, select_tag, {.ui = 0}},
{SUPER, XK_2, select_tag, {.ui = 1}},
{SUPER, XK_3, select_tag, {.ui = 2}},

View File

@@ -117,6 +117,36 @@ void kill_client(const user_action_arg_t *arg) {
}
}
void focus_stack(const user_action_arg_t *arg) {
if (!current_monitor->selected_client) return;
bool forward = arg->b;
client_t *client = NULL;
if (forward) {
for (client = current_monitor->selected_client->next;
client && !CLIENT_VISIBLE(client); client = client->next);
if (!client) {
for (client = current_monitor->clients; client && !CLIENT_VISIBLE(client);
client = client->next);
}
} else {
client_t *c = NULL;
for (c = current_monitor->clients; c != current_monitor->selected_client;
c = c->next) {
if (CLIENT_VISIBLE(c)) client = c;
}
if (!client) {
for (; c; c = c->next) {
if (CLIENT_VISIBLE(c)) client = c;
}
}
}
if (client) {
focus(client);
restack(current_monitor);
}
}
/* 调试函数,开发完成后删除 */
static void print_monitor_list_info(monitor_t *monitor_list) {
logger("========================= monitor info =========================\n");