Skip to content

Commit 4ea5a9c

Browse files
kennylevinsenemersion
authored andcommitted
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. (cherry picked from commit cdff4f7)
1 parent 4aa71ca commit 4ea5a9c

File tree

3 files changed

+17
-16
lines changed

3 files changed

+17
-16
lines changed

sway/commands/input.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
9494
return res;
9595
}
9696

97-
if (!config->reloading) {
97+
if (!config->reading) {
9898
input_manager_apply_input_config(ic);
9999
}
100100
} else {

sway/commands/output.c

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,17 +107,16 @@ struct cmd_results *cmd_output(int argc, char **argv) {
107107

108108
store_output_config(output);
109109

110-
// If reloading, the output configs will be applied after reading the
111-
// entire config and before the deferred commands so that an auto generated
112-
// workspace name is not given to re-enabled outputs.
113-
if (!config->reloading && !config->validating) {
114-
apply_stored_output_configs();
115-
if (background) {
116-
if (!spawn_swaybg()) {
117-
return cmd_results_new(CMD_FAILURE,
118-
"Failed to apply background configuration");
119-
}
120-
}
110+
if (config->reading) {
111+
// When reading the config file, we wait till the end to do a single
112+
// modeset and swaybg spawn.
113+
return cmd_results_new(CMD_SUCCESS, NULL);
114+
}
115+
request_modeset();
116+
117+
if (background && !spawn_swaybg()) {
118+
return cmd_results_new(CMD_FAILURE,
119+
"Failed to apply background configuration");
121120
}
122121

123122
return cmd_results_new(CMD_SUCCESS, NULL);

sway/config.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
516516
// Only really necessary if not explicitly `font` is set in the config.
517517
config_update_font_height();
518518

519-
if (is_active && !validating) {
519+
if (!validating) {
520520
input_manager_verify_fallback_seat();
521521

522522
for (int i = 0; i < config->input_configs->length; i++) {
@@ -533,12 +533,14 @@ bool load_main_config(const char *file, bool is_active, bool validating) {
533533
}
534534
sway_switch_retrigger_bindings_for_all();
535535

536-
apply_stored_output_configs();
537536
spawn_swaybg();
538537

539538
config->reloading = false;
540-
if (config->swaynag_config_errors.client != NULL) {
541-
swaynag_show(&config->swaynag_config_errors);
539+
if (is_active) {
540+
request_modeset();
541+
if (config->swaynag_config_errors.client != NULL) {
542+
swaynag_show(&config->swaynag_config_errors);
543+
}
542544
}
543545
}
544546

0 commit comments

Comments
 (0)