Skip to content

Commit

Permalink
#151 add VRR_OFF hint on adaptive sync failure (#152)
Browse files Browse the repository at this point in the history
* #151 add VRR_OFF hint on adaptive sync failure
  • Loading branch information
alex-courtis authored Jan 16, 2024
1 parent 648f1c4 commit 4a510af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
12 changes: 10 additions & 2 deletions src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ void apply(void) {
slist_free(&heads_changing);
}

void report_adaptive_sync_fail(struct Head *head) {
log_info("\n%s:", head->name);
log_info(" Cannot enable VRR: this display or compositor may not support it.");
log_info(" To speed things up you can disable VRR for this display by adding the following or similar to your cfg.yaml");
log_info(" VRR_OFF:");
log_info(" - '%s'", head->model ? head->model : "monitor description");
}

void handle_success(void) {
if (head_changing_mode) {

Expand All @@ -338,7 +346,7 @@ void handle_success(void) {

// sway reports adaptive sync failure as success
if (head_current_adaptive_sync_not_desired(head)) {
log_info("\n%s: Cannot enable VRR, display or compositor may not support it.", head->name);
report_adaptive_sync_fail(head);
head->adaptive_sync_failed = true;
return;
}
Expand All @@ -365,7 +373,7 @@ void handle_failure(void) {
} else if (head_changing_adaptive_sync && head_current_adaptive_sync_not_desired(head_changing_adaptive_sync)) {

// river reports adaptive sync failure as failure
log_info("\n%s: Cannot enable VRR, display or compositor may not support it.", head_changing_adaptive_sync->name);
report_adaptive_sync_fail(head_changing_adaptive_sync);
head_changing_adaptive_sync->adaptive_sync_failed = true;

head_changing_adaptive_sync = NULL;
Expand Down
14 changes: 12 additions & 2 deletions tst/tst-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,14 +613,19 @@ void handle_success__head_changing_adaptive_sync(void **state) {
void handle_success__head_changing_adaptive_sync_fail(void **state) {
struct Head head = {
.name = "head",
.model = NULL, // fall back to placeholder
.desired.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED,
.current.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_DISABLED,
};
head_changing_adaptive_sync = &head;

handle_success();

assert_log(INFO, "\nhead: Cannot enable VRR, display or compositor may not support it.\n");
assert_log(INFO, "\nhead:\n"
" Cannot enable VRR: this display or compositor may not support it.\n"
" To speed things up you can disable VRR for this display by adding the following or similar to your cfg.yaml\n"
" VRR_OFF:\n"
" - 'monitor description'\n");

assert_null(head_changing_adaptive_sync);
assert_true(head.adaptive_sync_failed);
Expand Down Expand Up @@ -677,14 +682,19 @@ void handle_failure__mode(void **state) {
void handle_failure__adaptive_sync(void **state) {
struct Head head = {
.name = "nam",
.model = "mod",
.current.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_DISABLED,
.desired.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED,
};
head_changing_adaptive_sync = &head;

handle_failure();

assert_log(INFO, "\nnam: Cannot enable VRR, display or compositor may not support it.\n");
assert_log(INFO, "\nnam:\n"
" Cannot enable VRR: this display or compositor may not support it.\n"
" To speed things up you can disable VRR for this display by adding the following or similar to your cfg.yaml\n"
" VRR_OFF:\n"
" - 'mod'\n");

assert_null(head_changing_adaptive_sync);

Expand Down

0 comments on commit 4a510af

Please sign in to comment.