summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFurkan Sahin <furkan-dev@proton.me>2024-09-21 01:00:04 +0200
committerFurkan Sahin <furkan-dev@proton.me>2024-09-21 01:00:04 +0200
commitfa6c65450703887540f96e574b2ac6aac447fbd0 (patch)
tree12c342c00cf3f1b8d0fde17daf51b1194145d193
parent93f785e3b5d84fbd32eb5554dc74a247f298a281 (diff)
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 cdff4f7c74b76e9141164b8c154621646140d8ec)
-rw-r--r--sway/commands/input.c2
-rw-r--r--sway/commands/output.c21
-rw-r--r--sway/config.c10
3 files changed, 17 insertions, 16 deletions
diff --git a/sway/commands/input.c b/sway/commands/input.c
index 35846b1c..310375a9 100644
--- a/sway/commands/input.c
+++ b/sway/commands/input.c
@@ -94,7 +94,7 @@ struct cmd_results *cmd_input(int argc, char **argv) {
return res;
}
- if (!config->reloading) {
+ if (!config->reading) {
input_manager_apply_input_config(ic);
}
} else {
diff --git a/sway/commands/output.c b/sway/commands/output.c
index 3f65b909..9d58413f 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -107,17 +107,16 @@ struct cmd_results *cmd_output(int argc, char **argv) {
store_output_config(output);
- // If reloading, the output configs will be applied after reading the
- // entire config and before the deferred commands so that an auto generated
- // workspace name is not given to re-enabled outputs.
- if (!config->reloading && !config->validating) {
- apply_stored_output_configs();
- if (background) {
- if (!spawn_swaybg()) {
- return cmd_results_new(CMD_FAILURE,
- "Failed to apply background configuration");
- }
- }
+ if (config->reading) {
+ // When reading the config file, we wait till the end to do a single
+ // modeset and swaybg spawn.
+ return cmd_results_new(CMD_SUCCESS, NULL);
+ }
+ request_modeset();
+
+ if (background && !spawn_swaybg()) {
+ return cmd_results_new(CMD_FAILURE,
+ "Failed to apply background configuration");
}
return cmd_results_new(CMD_SUCCESS, NULL);
diff --git a/sway/config.c b/sway/config.c
index 5fc414a1..1090edc5 100644
--- a/sway/config.c
+++ b/sway/config.c
@@ -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.
config_update_font_height();
- if (is_active && !validating) {
+ if (!validating) {
input_manager_verify_fallback_seat();
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) {
}
sway_switch_retrigger_bindings_for_all();
- apply_stored_output_configs();
spawn_swaybg();
config->reloading = false;
- if (config->swaynag_config_errors.client != NULL) {
- swaynag_show(&config->swaynag_config_errors);
+ if (is_active) {
+ request_modeset();
+ if (config->swaynag_config_errors.client != NULL) {
+ swaynag_show(&config->swaynag_config_errors);
+ }
}
}