mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-22 07:02:28 +00:00
backend/multi: Advance index on backend_commit
wlr_multi_backend sorts the states it is given and tries to perform sequential backend-wide commits for each sub-backend with the states that belong to it. It did not manage the index correctly for the next iteration, so given N states for a backend it would perform N backend-wide commits. Clarify the logic by calculating a length rather than an end pointer and update the index after each iteration.
This commit is contained in:
parent
7952658367
commit
ba0cc8eb05
@ -126,22 +126,24 @@ static bool commit(struct wlr_backend *backend,
|
|||||||
qsort(by_backend, states_len, sizeof(by_backend[0]), compare_output_state_backend);
|
qsort(by_backend, states_len, sizeof(by_backend[0]), compare_output_state_backend);
|
||||||
|
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
for (size_t i = 0; i < states_len; i++) {
|
for (size_t i = 0; i < states_len;) {
|
||||||
struct wlr_backend *sub = by_backend[i].output->backend;
|
struct wlr_backend *sub = by_backend[i].output->backend;
|
||||||
|
|
||||||
size_t j = i;
|
size_t len = 1;
|
||||||
while (j < states_len && by_backend[j].output->backend == sub) {
|
while (i + len < states_len &&
|
||||||
j++;
|
by_backend[i + len].output->backend == sub) {
|
||||||
|
len++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_only) {
|
if (test_only) {
|
||||||
ok = wlr_backend_test(sub, &by_backend[i], j - i);
|
ok = wlr_backend_test(sub, &by_backend[i], len);
|
||||||
} else {
|
} else {
|
||||||
ok = wlr_backend_commit(sub, &by_backend[i], j - i);
|
ok = wlr_backend_commit(sub, &by_backend[i], len);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
if (!ok) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
i += len;
|
||||||
}
|
}
|
||||||
|
|
||||||
free(by_backend);
|
free(by_backend);
|
||||||
|
Loading…
Reference in New Issue
Block a user