mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2024-11-21 22:52:20 +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);
|
||||
|
||||
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;
|
||||
|
||||
size_t j = i;
|
||||
while (j < states_len && by_backend[j].output->backend == sub) {
|
||||
j++;
|
||||
size_t len = 1;
|
||||
while (i + len < states_len &&
|
||||
by_backend[i + len].output->backend == sub) {
|
||||
len++;
|
||||
}
|
||||
|
||||
if (test_only) {
|
||||
ok = wlr_backend_test(sub, &by_backend[i], j - i);
|
||||
ok = wlr_backend_test(sub, &by_backend[i], len);
|
||||
} else {
|
||||
ok = wlr_backend_commit(sub, &by_backend[i], j - i);
|
||||
ok = wlr_backend_commit(sub, &by_backend[i], len);
|
||||
}
|
||||
if (!ok) {
|
||||
break;
|
||||
}
|
||||
i += len;
|
||||
}
|
||||
|
||||
free(by_backend);
|
||||
|
Loading…
Reference in New Issue
Block a user