output: avoid use of wlr_scene_output.WLR_PRIVATE.index

We were only using it to allow quick bitset comparisons of sets of
outputs (such as view->outputs). We can maintain our own bit IDs for
this purpose and avoid using the private wlroots field.

Note: from my reading of wlr_scene_output_create(), it appears to
always take the lowest unused index, resulting in aggressive re-use of
index values when outputs are disconnected and reconnected. I've tried
to make re-use as infrequent as possible. This could theoretically
reduce the chance of a mix-up in view_update_outputs(), although I'm
not aware of any practical scenario where it matters.

v2: prevent adding more than 64 outputs
This commit is contained in:
John Lindgren 2025-11-25 17:36:02 -05:00 committed by Consolatis
parent 6521067171
commit e96f4a032b
5 changed files with 59 additions and 4 deletions

View file

@ -570,7 +570,7 @@ view_update_outputs(struct view *view)
wl_list_for_each(output, &view->server->outputs, link) {
if (output_is_usable(output) && wlr_output_layout_intersects(
layout, output->wlr_output, &view->current)) {
new_outputs |= (1ull << output->scene_output->WLR_PRIVATE.index);
new_outputs |= output->id_bit;
}
}
@ -586,8 +586,7 @@ view_on_output(struct view *view, struct output *output)
{
assert(view);
assert(output);
return output->scene_output
&& (view->outputs & (1ull << output->scene_output->WLR_PRIVATE.index));
return (view->outputs & output->id_bit) != 0;
}
void