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;