aboutsummaryrefslogtreecommitdiffstats
path: root/sway
diff options
context:
space:
mode:
authorLibravatar Kenny Levinsen <kl@kl.wtf>2024-04-21 17:41:19 +0200
committerLibravatar Kenny Levinsen <kl@kl.wtf>2024-05-02 16:16:42 +0200
commit2686afb95c5dd76b22abdd76ffbb4b30688f8fd3 (patch)
treee923c1eab4935c987d61f11f78b69cc4bc05f18c /sway
parentconfig/output: Search for output config fallbacks (diff)
downloadsway-2686afb95c5dd76b22abdd76ffbb4b30688f8fd3.tar.gz
sway-2686afb95c5dd76b22abdd76ffbb4b30688f8fd3.tar.zst
sway-2686afb95c5dd76b22abdd76ffbb4b30688f8fd3.zip
config/output: Print output state during tests
Instead of having each search function print its various test decisions, print the full state at the end of every search. This makes it much clearer what state a particular test includes.
Diffstat (limited to 'sway')
-rw-r--r--sway/config/output.c46
1 files changed, 32 insertions, 14 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 3ec5d77b..fb1956df 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -641,6 +641,30 @@ struct search_context {
641 bool degrade_to_off; 641 bool degrade_to_off;
642}; 642};
643 643
644static void dump_output_state(struct wlr_output *wlr_output, struct wlr_output_state *state) {
645 sway_log(SWAY_DEBUG, "Output state for %s", wlr_output->name);
646 if (state->committed & WLR_OUTPUT_STATE_ENABLED) {
647 sway_log(SWAY_DEBUG, " enabled: %s", state->enabled ? "yes" : "no");
648 }
649 if (state->committed & WLR_OUTPUT_STATE_RENDER_FORMAT) {
650 sway_log(SWAY_DEBUG, " render_format: %d", state->render_format);
651 }
652 if (state->committed & WLR_OUTPUT_STATE_MODE) {
653 if (state->mode_type == WLR_OUTPUT_STATE_MODE_CUSTOM) {
654 sway_log(SWAY_DEBUG, " custom mode: %dx%d@%dmHz",
655 state->custom_mode.width, state->custom_mode.height, state->custom_mode.refresh);
656 } else {
657 sway_log(SWAY_DEBUG, " mode: %dx%d@%dmHz%s",
658 state->mode->width, state->mode->height, state->mode->refresh,
659 state->mode->preferred ? " (preferred)" : "");
660 }
661 }
662 if (state->committed & WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED) {
663 sway_log(SWAY_DEBUG, " adaptive_sync: %s",
664 state->adaptive_sync_enabled ? "enabled": "disabled");
665 }
666}
667
644static bool search_valid_config(struct search_context *ctx, size_t output_idx); 668static bool search_valid_config(struct search_context *ctx, size_t output_idx);
645 669
646static void reset_output_state(struct wlr_output_state *state) { 670static void reset_output_state(struct wlr_output_state *state) {
@@ -664,7 +688,12 @@ static void clear_later_output_states(struct wlr_backend_output_state *states,
664} 688}
665 689
666static bool search_finish(struct search_context *ctx, size_t output_idx) { 690static bool search_finish(struct search_context *ctx, size_t output_idx) {
691 struct wlr_backend_output_state *backend_state = &ctx->states[output_idx];
692 struct wlr_output_state *state = &backend_state->base;
693 struct wlr_output *wlr_output = backend_state->output;
694
667 clear_later_output_states(ctx->states, ctx->configs_len, output_idx); 695 clear_later_output_states(ctx->states, ctx->configs_len, output_idx);
696 dump_output_state(wlr_output, state);
668 return wlr_output_swapchain_manager_prepare(ctx->swapchain_mgr, ctx->states, ctx->configs_len) && 697 return wlr_output_swapchain_manager_prepare(ctx->swapchain_mgr, ctx->states, ctx->configs_len) &&
669 search_valid_config(ctx, output_idx+1); 698 search_valid_config(ctx, output_idx+1);
670} 699}
@@ -681,8 +710,6 @@ static bool search_adaptive_sync(struct search_context *ctx, size_t output_idx)
681 } 710 }
682 } 711 }
683 if (!cfg->config || cfg->config->adaptive_sync != -1) { 712 if (!cfg->config || cfg->config->adaptive_sync != -1) {
684 sway_log(SWAY_DEBUG, "Trying with adaptive sync disabled for: %s",
685 backend_state->output->name);
686 wlr_output_state_set_adaptive_sync_enabled(state, false); 713 wlr_output_state_set_adaptive_sync_enabled(state, false);
687 if (search_finish(ctx, output_idx)) { 714 if (search_finish(ctx, output_idx)) {
688 return true; 715 return true;
@@ -690,8 +717,6 @@ static bool search_adaptive_sync(struct search_context *ctx, size_t output_idx)
690 } 717 }
691 // If adaptive sync has not been set, or fallback in case we are on a 718 // If adaptive sync has not been set, or fallback in case we are on a
692 // backend that cannot disable adaptive sync such as the wayland backend. 719 // backend that cannot disable adaptive sync such as the wayland backend.
693 sway_log(SWAY_DEBUG, "Trying with adaptive sync unset for: %s",
694 backend_state->output->name);
695 state->committed &= ~WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED; 720 state->committed &= ~WLR_OUTPUT_STATE_ADAPTIVE_SYNC_ENABLED;
696 return search_finish(ctx, output_idx); 721 return search_finish(ctx, output_idx);
697} 722}
@@ -708,7 +733,6 @@ static bool search_mode(struct search_context *ctx, size_t output_idx) {
708 733
709 struct wlr_output_mode *preferred_mode = wlr_output_preferred_mode(wlr_output); 734 struct wlr_output_mode *preferred_mode = wlr_output_preferred_mode(wlr_output);
710 if (preferred_mode) { 735 if (preferred_mode) {
711 sway_log(SWAY_DEBUG, "Trying with preferred mode for: %s", backend_state->output->name);
712 wlr_output_state_set_mode(state, preferred_mode); 736 wlr_output_state_set_mode(state, preferred_mode);
713 if (search_adaptive_sync(ctx, output_idx)) { 737 if (search_adaptive_sync(ctx, output_idx)) {
714 return true; 738 return true;
@@ -725,8 +749,6 @@ static bool search_mode(struct search_context *ctx, size_t output_idx) {
725 if (mode == preferred_mode) { 749 if (mode == preferred_mode) {
726 continue; 750 continue;
727 } 751 }
728 sway_log(SWAY_DEBUG, "Trying with mode %dx%d@%dmHz for: %s",
729 mode->width, mode->height, mode->refresh, backend_state->output->name);
730 wlr_output_state_set_mode(state, mode); 752 wlr_output_state_set_mode(state, mode);
731 if (search_adaptive_sync(ctx, output_idx)) { 753 if (search_adaptive_sync(ctx, output_idx)) {
732 return true; 754 return true;
@@ -765,8 +787,6 @@ static bool search_render_format(struct search_context *ctx, size_t output_idx)
765 // This is not a supported format for this output 787 // This is not a supported format for this output
766 continue; 788 continue;
767 } 789 }
768 sway_log(SWAY_DEBUG, "Trying with render format %d for: %s", fmts[idx],
769 wlr_output->name);
770 wlr_output_state_set_render_format(state, fmts[idx]); 790 wlr_output_state_set_render_format(state, fmts[idx]);
771 if (search_mode(ctx, output_idx)) { 791 if (search_mode(ctx, output_idx)) {
772 return true; 792 return true;
@@ -784,9 +804,7 @@ static bool search_valid_config(struct search_context *ctx, size_t output_idx) {
784 struct matched_output_config *cfg = &ctx->configs[output_idx]; 804 struct matched_output_config *cfg = &ctx->configs[output_idx];
785 struct wlr_backend_output_state *backend_state = &ctx->states[output_idx]; 805 struct wlr_backend_output_state *backend_state = &ctx->states[output_idx];
786 struct wlr_output_state *state = &backend_state->base; 806 struct wlr_output_state *state = &backend_state->base;
787 807 struct wlr_output *wlr_output = backend_state->output;
788 sway_log(SWAY_DEBUG, "Finding valid config for: %s",
789 backend_state->output->name);
790 808
791 if (!output_config_is_disabling(cfg->config)) { 809 if (!output_config_is_disabling(cfg->config)) {
792 // Search through our possible configurations, doing a depth-first 810 // Search through our possible configurations, doing a depth-first
@@ -800,8 +818,8 @@ static bool search_valid_config(struct search_context *ctx, size_t output_idx) {
800 } 818 }
801 // We could not get anything to work, try to disable this output to see 819 // We could not get anything to work, try to disable this output to see
802 // if we can at least make the outputs before us work. 820 // if we can at least make the outputs before us work.
803 sway_log(SWAY_DEBUG, "Trying with disabled output for: %s", 821 sway_log(SWAY_DEBUG, "Unable to find valid config with output %s, disabling",
804 backend_state->output->name); 822 wlr_output->name);
805 reset_output_state(state); 823 reset_output_state(state);
806 } 824 }
807 825