From 27d4f15516c15599d61e45602e9698ca1532e64e Mon Sep 17 00:00:00 2001 From: Kenny Levinsen Date: Mon, 11 Nov 2024 12:16:44 +0100 Subject: [PATCH] config: Force modeset before running deferred configs Some commands require outputs to be enabled. These commands are deferred to allow outputs to be discovered, but the delayed modeset might only run some time later. Force a modeset to occur before running deferred commands. Fixes: https://github.com/swaywm/sway/issues/8433 (cherry picked from commit 6111297d91faf5f2820acaa14d76d6389b469b77) --- include/sway/config.h | 1 + sway/desktop/output.c | 14 +++++++++----- sway/main.c | 1 + 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/include/sway/config.h b/include/sway/config.h index 71721393e..013853c85 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -705,6 +705,7 @@ struct output_config *find_output_config(struct sway_output *output); void free_output_config(struct output_config *oc); void request_modeset(void); +void force_modeset(void); bool spawn_swaybg(void); diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 254c3feef..46cd73a2a 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c @@ -426,6 +426,14 @@ void request_modeset(void) { } } +void force_modeset(void) { + if (server.delayed_modeset != NULL) { + wl_event_source_remove(server.delayed_modeset); + server.delayed_modeset = NULL; + } + apply_stored_output_configs(); +} + static void begin_destroy(struct sway_output *output) { if (output->enabled) { output_disable(output); @@ -526,12 +534,8 @@ static void handle_request_state(struct wl_listener *listener, void *data) { // We do not expect or support any other changes here assert(committed == 0); store_output_config(oc); - apply_stored_output_configs(); - if (server.delayed_modeset != NULL) { - wl_event_source_remove(server.delayed_modeset); - server.delayed_modeset = NULL; - } + force_modeset(); } static unsigned int last_headless_num = 0; diff --git a/sway/main.c b/sway/main.c index 1c4939aa0..165ccc095 100644 --- a/sway/main.c +++ b/sway/main.c @@ -361,6 +361,7 @@ int main(int argc, char **argv) { } config->active = true; + force_modeset(); load_swaybars(); run_deferred_commands(); run_deferred_bindings();