调整窗口管理器重启后恢复 client tag 信息时机让 rule 尽可能多的生效

This commit is contained in:
2025-08-30 18:57:29 +08:00
parent fc543e6f9e
commit e347dabc21

View File

@@ -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 monitor_t *get_monitor_by_direction(bool forward);
static void send_client_to_monitor(client_t *client, monitor_t *monitor); static void send_client_to_monitor(client_t *client, monitor_t *monitor);
static void set_client_tag_prop(client_t *client); 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, static gboolean handle_xcb_event(GIOChannel *channel, GIOCondition condition,
gpointer userdata); gpointer userdata);
static void cleanup(bool will_restart); 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))) { if (tw != WINDOW_NONE && (tc = get_client_of_window(tw))) {
c->monitor = tc->monitor; c->monitor = tc->monitor;
c->tags = tc->tags; c->tags = tc->tags;
} else if (!apply_initial_client_tag(c)) { } else {
c->monitor = current_monitor; c->monitor = current_monitor;
apply_rules(c); apply_rules(c);
} }
@@ -947,13 +947,9 @@ void apply_rules(client_t *client) {
} }
} }
if (!client->tags) { if (!client->tags && !restore_client_tag(client)) {
client_tag_info_t client_info; client->monitor = current_monitor;
if (get_window_tag(client->window, &client_info)) { client->tags = current_monitor->selected_tags;
} else {
client->monitor = current_monitor;
client->tags = current_monitor->selected_tags;
}
} }
if (switch_to_tag) { if (switch_to_tag) {
current_monitor = client->monitor; 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 * @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; client_tag_info_t client_tag_info;
if (!get_window_tag(client->window, &client_tag_info)) return false; if (!get_window_tag(client->window, &client_tag_info)) return false;