From 2902c994ba9f99dadf62dfaf53193b069ab2ac36 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Wed, 7 Jan 2026 11:39:46 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=87=E6=8D=A2=20client=20=E6=89=80?= =?UTF-8?q?=E5=9C=A8=20tag?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/action.c | 4 ++++ src/action.h | 1 + src/client.c | 6 ++++++ src/default_config.h | 15 +++++++++++++++ 4 files changed, 26 insertions(+) diff --git a/src/action.c b/src/action.c index fd0066b..63973a8 100644 --- a/src/action.c +++ b/src/action.c @@ -29,6 +29,10 @@ void select_tag_of_current_monitor(const user_action_arg_t *arg) { monitor_select_tag(wm.current_monitor, arg->ui); } +void send_client_to_tag(const user_action_arg_t *arg) { + if (wm.client_focused) client_send_to_tag(wm.client_focused, arg->ui); +} + void spawn(const user_action_arg_t *arg) { const char *cmd = (const char *)arg->ptr; if (cmd == nullptr || strlen(cmd) == 0) return; diff --git a/src/action.h b/src/action.h index 8c16804..10fe453 100644 --- a/src/action.h +++ b/src/action.h @@ -50,5 +50,6 @@ typedef struct keyboard_t { void focus_client_in_same_tag(const user_action_arg_t *arg); void select_tag_of_current_monitor(const user_action_arg_t *arg); +void send_client_to_tag(const user_action_arg_t *arg); void spawn(const user_action_arg_t *arg); void quit(const user_action_arg_t *arg); diff --git a/src/client.c b/src/client.c index aebc218..59e9ba4 100644 --- a/src/client.c +++ b/src/client.c @@ -232,6 +232,12 @@ bool client_need_layout(client_t *client) { return true; } +void client_send_to_tag(client_t *client, uint32_t tag_mask) { + client->tags = tag_mask; + client_tags_apply(client); + monitor_select_tag(client->monitor, tag_mask); +} + void client_move_to(client_t *client, int16_t x, int16_t y) { client->geometry.x = x; client->geometry.y = y; diff --git a/src/default_config.h b/src/default_config.h index 0eba302..bb13530 100644 --- a/src/default_config.h +++ b/src/default_config.h @@ -30,6 +30,11 @@ static const button_t button_list[] = { {click_tag, modifier_none, button_left, select_tag_of_current_monitor, {0}}, }; +#define TAGKEYS(KEY, TAG) \ + {modifier_alt, KEY, select_tag_of_current_monitor, {.ui = TAG}}, { \ + modifier_alt | modifier_shift, KEY, send_client_to_tag, {.ui = TAG}, \ + } + static const char launcher[] = "rofi -show combi -modes combi -combi-modes window,drun,run,ssh,windowcd"; static const keyboard_t key_list[] = { @@ -38,6 +43,16 @@ static const keyboard_t key_list[] = { {modifier_alt, XK_r, quit, {.b = true}}, {modifier_alt | modifier_shift, XK_j, focus_client_in_same_tag, {.b = true}}, {modifier_alt | modifier_shift, XK_k, focus_client_in_same_tag, {.b = false}}, + + TAGKEYS(XK_1, 1 << 0), + TAGKEYS(XK_2, 1 << 1), + TAGKEYS(XK_3, 1 << 2), + TAGKEYS(XK_4, 1 << 3), + TAGKEYS(XK_5, 1 << 4), + TAGKEYS(XK_6, 1 << 5), + TAGKEYS(XK_7, 1 << 6), + TAGKEYS(XK_8, 1 << 7), + TAGKEYS(XK_9, 1 << 8), }; static const layout_t layout_list[] = {