config: Batch input/output configuration on load

We batch modesets and input configuration performed during config reload
but commit for every command during the intial config load. There is no
need to perform commits during the initial config load as outputs have
not yet been created, but swaybg spawn should still be batched.

At the same time, replace direct calls to apply output configuration
with request_modeset to properly handle the modeset timer.
This commit is contained in:
Kenny Levinsen 2024-09-21 01:00:04 +02:00 committed by Alexander Orzechowski
parent b73f54a966
commit cdff4f7c74
3 changed files with 17 additions and 16 deletions

View file

@ -94,7 +94,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
return res; return res;
} }
if (!config->reloading) { if (!config->reading) {
input_manager_apply_input_config(ic); input_manager_apply_input_config(ic);
} }
} else { } else {

View file

@ -107,18 +107,17 @@ struct cmd_results *cmd_output(int argc, char **argv) {
store_output_config(output); store_output_config(output);
// If reloading, the output configs will be applied after reading the if (config->reading) {
// entire config and before the deferred commands so that an auto generated // When reading the config file, we wait till the end to do a single
// workspace name is not given to re-enabled outputs. // modeset and swaybg spawn.
if (!config->reloading && !config->validating) { return cmd_results_new(CMD_SUCCESS, NULL);
apply_stored_output_configs(); }
if (background) { request_modeset();
if (!spawn_swaybg()) {
if (background && !spawn_swaybg()) {
return cmd_results_new(CMD_FAILURE, return cmd_results_new(CMD_FAILURE,
"Failed to apply background configuration"); "Failed to apply background configuration");
} }
}
}
return cmd_results_new(CMD_SUCCESS, NULL); return cmd_results_new(CMD_SUCCESS, NULL);

View file

@ -516,7 +516,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
// Only really necessary if not explicitly `font` is set in the config. // Only really necessary if not explicitly `font` is set in the config.
config_update_font_height(); config_update_font_height();
if (is_active && !validating) { if (!validating) {
input_manager_verify_fallback_seat(); input_manager_verify_fallback_seat();
for (int i = 0; i < config->input_configs->length; i++) { for (int i = 0; i < config->input_configs->length; i++) {
@ -533,14 +533,16 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
} }
sway_switch_retrigger_bindings_for_all(); sway_switch_retrigger_bindings_for_all();
apply_stored_output_configs();
spawn_swaybg(); spawn_swaybg();
config->reloading = false; config->reloading = false;
if (is_active) {
request_modeset();
if (config->swaynag_config_errors.client != NULL) { if (config->swaynag_config_errors.client != NULL) {
swaynag_show(&config->swaynag_config_errors); swaynag_show(&config->swaynag_config_errors);
} }
} }
}
if (old_config) { if (old_config) {
destroy_removed_seats(old_config, config); destroy_removed_seats(old_config, config);