From e347dabc212ce44695a18f00bcf455528836e683 Mon Sep 17 00:00:00 2001 From: Zedhugh Chen Date: Sat, 30 Aug 2025 18:57:29 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E7=AA=97=E5=8F=A3=E7=AE=A1?= =?UTF-8?q?=E7=90=86=E5=99=A8=E9=87=8D=E5=90=AF=E5=90=8E=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=20client=20tag=20=E4=BF=A1=E6=81=AF=E6=97=B6=E6=9C=BA=E8=AE=A9?= =?UTF-8?q?=20rule=20=E5=B0=BD=E5=8F=AF=E8=83=BD=E5=A4=9A=E7=9A=84?= =?UTF-8?q?=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.c | 18 +++++++----------- 1 file changed, 7 insertions(+), 11 deletions(-) diff --git a/src/main.c b/src/main.c index e385cce..f74f662 100644 --- a/src/main.c +++ b/src/main.c @@ -72,7 +72,7 @@ static monitor_t *get_monitor_of_window(xcb_window_t window); static monitor_t *get_monitor_by_direction(bool forward); static void send_client_to_monitor(client_t *client, monitor_t *monitor); static void set_client_tag_prop(client_t *client); -static bool apply_initial_client_tag(client_t *client); +static bool restore_client_tag(client_t *client); static gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition, gpointer userdata); static void cleanup(bool will_restart); @@ -836,7 +836,7 @@ void manage_window(xcb_window_t window) { if (tw != WINDOW_NONE && (tc = get_client_of_window(tw))) { c->monitor = tc->monitor; c->tags = tc->tags; - } else if (!apply_initial_client_tag(c)) { + } else { c->monitor = current_monitor; apply_rules(c); } @@ -947,13 +947,9 @@ void apply_rules(client_t *client) { } } - if (!client->tags) { - client_tag_info_t client_info; - if (get_window_tag(client->window, &client_info)) { - } else { - client->monitor = current_monitor; - client->tags = current_monitor->selected_tags; - } + if (!client->tags && !restore_client_tag(client)) { + client->monitor = current_monitor; + client->tags = current_monitor->selected_tags; } if (switch_to_tag) { current_monitor = client->monitor; @@ -1183,10 +1179,10 @@ void set_client_tag_prop(client_t *client) { } /** - * @brief 设置 client 的初始 tag 信息 + * @brief 恢复 client 的 tag 信息 * @returns 成功返回 true 否则返回 false */ -bool apply_initial_client_tag(client_t *client) { +bool restore_client_tag(client_t *client) { client_tag_info_t client_tag_info; if (!get_window_tag(client->window, &client_tag_info)) return false;