refactor(command): 从 switch_workspace 命令中移除冗余的 output 字段
This commit is contained in:
@@ -21,7 +21,6 @@ typedef struct manage_window_command_t {
|
|||||||
} manage_window_command_t;
|
} manage_window_command_t;
|
||||||
|
|
||||||
typedef struct switch_workspace_command_t {
|
typedef struct switch_workspace_command_t {
|
||||||
output_id_t output;
|
|
||||||
workspace_id_t workspace;
|
workspace_id_t workspace;
|
||||||
} switch_workspace_command_t;
|
} switch_workspace_command_t;
|
||||||
|
|
||||||
|
|||||||
@@ -101,22 +101,18 @@ static void route_map_request(
|
|||||||
}
|
}
|
||||||
|
|
||||||
command_buffer_push(out, &manage_window_cmd);
|
command_buffer_push(out, &manage_window_cmd);
|
||||||
if (have_rule_match && action.switch_to_workspace) {
|
if (!have_rule_match || !action.switch_to_workspace) return;
|
||||||
workspace_id_t workspace_id = manage_window_cmd.as.manage_window.workspace;
|
|
||||||
const workspace_t *workspace = state_workspace_get(state, workspace_id);
|
|
||||||
|
|
||||||
if (workspace) {
|
workspace_id_t workspace_id = manage_window_cmd.as.manage_window.workspace;
|
||||||
command_t switch_workspace_cmd = {
|
const workspace_t *workspace = state_workspace_get(state, workspace_id);
|
||||||
.type = ZDWM_COMMAND_SWITCH_WORKSPACE,
|
if (!workspace) return;
|
||||||
.as.switch_workspace = {
|
|
||||||
.output = workspace->output_id,
|
|
||||||
.workspace = workspace_id,
|
|
||||||
},
|
|
||||||
};
|
|
||||||
|
|
||||||
command_buffer_push(out, &switch_workspace_cmd);
|
command_t switch_workspace_cmd = {
|
||||||
}
|
.type = ZDWM_COMMAND_SWITCH_WORKSPACE,
|
||||||
}
|
.as.switch_workspace.workspace = workspace_id,
|
||||||
|
};
|
||||||
|
|
||||||
|
command_buffer_push(out, &switch_workspace_cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void route_window_remove(
|
static void route_window_remove(
|
||||||
@@ -589,13 +585,12 @@ static void change_window_state(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void switch_workspace(
|
static void
|
||||||
state_t *state,
|
switch_workspace(state_t *state, workspace_id_t workspace_id, plan_t *plan) {
|
||||||
const switch_workspace_command_t *command,
|
auto workspace = state_workspace_get(state, workspace_id);
|
||||||
plan_t *plan
|
if (!workspace) return;
|
||||||
) {
|
|
||||||
auto output_id = command->output;
|
auto output_id = workspace->output_id;
|
||||||
auto workspace_id = command->workspace;
|
|
||||||
workspace_id_t old_workspace = ZDWM_WORKSPACE_ID_INVALID;
|
workspace_id_t old_workspace = ZDWM_WORKSPACE_ID_INVALID;
|
||||||
|
|
||||||
if (state_output_set_current_workspace(
|
if (state_output_set_current_workspace(
|
||||||
@@ -642,7 +637,7 @@ void policy_apply_command(
|
|||||||
change_window_state(ctx, &cmd->as.state_change, plan);
|
change_window_state(ctx, &cmd->as.state_change, plan);
|
||||||
break;
|
break;
|
||||||
case ZDWM_COMMAND_SWITCH_WORKSPACE:
|
case ZDWM_COMMAND_SWITCH_WORKSPACE:
|
||||||
switch_workspace(state, &cmd->as.switch_workspace, plan);
|
switch_workspace(state, cmd->as.switch_workspace.workspace, plan);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user