Skip to content

Commit

Permalink
fix(#101): failure following DISABLE (#102)
Browse files Browse the repository at this point in the history
  • Loading branch information
alex-courtis authored May 9, 2023
1 parent f876213 commit 9bfccc0
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 16 deletions.
7 changes: 0 additions & 7 deletions src/layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -154,8 +154,6 @@ void desire_enabled(struct Head *head) {
}

void desire_mode(struct Head *head) {
head->desired.mode = NULL;

if (!head->desired.enabled) {
return;
}
Expand All @@ -173,13 +171,10 @@ void desire_mode(struct Head *head) {
head->warned_no_mode = true;
}
head->desired.enabled = false;
head->desired.mode = NULL;
}
}

void desire_scale(struct Head *head) {
head->desired.scale = 0;

if (!head->desired.enabled) {
return;
}
Expand Down Expand Up @@ -209,8 +204,6 @@ void desire_scale(struct Head *head) {
}

void desire_adaptive_sync(struct Head *head) {
head->desired.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_DISABLED;

if (!head->desired.enabled) {
return;
}
Expand Down
19 changes: 10 additions & 9 deletions tst/tst-layout.c
Original file line number Diff line number Diff line change
Expand Up @@ -363,12 +363,13 @@ void desire_mode__disabled(void **state) {
struct Mode mode0 = { 0 };
struct Head head0 = {
.name = "head0",
.desired.enabled = false,
.desired.mode = &mode0,
};

desire_mode(&head0);

assert_null(head0.desired.mode);
assert_ptr_equal(head0.desired.mode, &mode0);
assert_false(head0.desired.enabled);
assert_false(head0.warned_no_mode);
}
Expand All @@ -392,7 +393,7 @@ void desire_mode__no_mode(void **state) {

assert_log(WARNING, "\nNo mode for head0, disabling.\n");

assert_null(head0.desired.mode);
assert_ptr_equal(head0.desired.mode, &mode0);
assert_false(head0.desired.enabled);
assert_true(head0.warned_no_mode);
}
Expand All @@ -411,7 +412,7 @@ void desire_mode__no_mode_warned(void **state) {

desire_mode(&head0);

assert_null(head0.desired.mode);
assert_ptr_equal(head0.desired.mode, &mode0);
assert_false(head0.desired.enabled);
assert_true(head0.warned_no_mode);
}
Expand Down Expand Up @@ -501,18 +502,18 @@ void desire_scale__user(void **state) {
void desire_adaptive_sync__head_disabled(void **state) {
struct Head head0 = {
.desired.enabled = false,
.desired.adaptive_sync = true,
.desired.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED,
};

desire_adaptive_sync(&head0);

assert_int_equal(head0.desired.adaptive_sync, ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_DISABLED);
assert_int_equal(head0.desired.adaptive_sync, ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED);
}

void desire_adaptive_sync__failed(void **state) {
struct Head head0 = {
.desired.enabled = true,
.desired.adaptive_sync = true,
.desired.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_DISABLED,
.adaptive_sync_failed = true,
};

Expand All @@ -525,20 +526,20 @@ void desire_adaptive_sync__adaptive_sync_off(void **state) {
struct Head head0 = {
.name = "some head",
.desired.enabled = true,
.desired.adaptive_sync = true,
.desired.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED,
};

slist_append(&cfg->adaptive_sync_off_name_desc, strdup("!.*hea"));

desire_adaptive_sync(&head0);

assert_int_equal(head0.desired.adaptive_sync, ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_DISABLED);
assert_int_equal(head0.desired.adaptive_sync, ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_ENABLED);
}

void desire_adaptive_sync__ok(void **state) {
struct Head head0 = {
.desired.enabled = true,
.desired.adaptive_sync = true,
.desired.adaptive_sync = ZWLR_OUTPUT_HEAD_V1_ADAPTIVE_SYNC_STATE_DISABLED,
};

desire_adaptive_sync(&head0);
Expand Down

0 comments on commit 9bfccc0

Please sign in to comment.