Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

output: fix assert when re-adding output to layout #315

Merged
merged 1 commit into from
Feb 23, 2024

Conversation

emersion
Copy link
Contributor

wlr_scene_output_layout_add_output() aborts when called with an already-added output.

To reproduce, run wlr-randr to reconfigure one of the enabled outputs.

cc @kennylevinsen

wlr_scene_output_layout_add_output() aborts when called with an
already-added output.

To reproduce, run wlr-randr to reconfigure one of the enabled
outputs.
@joggee-fr
Copy link
Collaborator

I ran into the same issue but my patch was not ready yet. Instead of checking existence each time, I assume wlr_scene_output_layout_add_output() has been called in handle_new_output(). Then, these output_layout_add*() inline functions can be replaced by the only call done to the wlr API.

@emersion
Copy link
Contributor Author

Instead of checking existence each time, I assume wlr_scene_output_layout_add_output() has been called in handle_new_output().

That won't work if a user disables an output via the wlr-output-management-v1 protocol, then enables it.

Copy link
Contributor

@kennylevinsen kennylevinsen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch. I left a suggestion in the comment, but either way is fine.

Comment on lines +83 to +88
bool exists = wlr_output_layout_get(output->server->output_layout, output->wlr_output);
struct wlr_output_layout_output *layout_output =
wlr_output_layout_add(output->server->output_layout, output->wlr_output, x, y);
if (exists) {
return;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Alternatively one could just wlr_output_layout_remove before calls to wlr_output_layout_add(_auto), avoiding the need to check anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, but that would re-create the wl_output global which I'd prefer not to do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point, that would be a bit annoying on the wire.

Maybe we should replace that assert in scene_output_layout with a an early return to better match how wlr_output_layout works...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4559

(Note that unless we're backporting that patch to wlroots 0.17, this PR is still necessary.)

udfn pushed a commit to udfn/wlroots that referenced this pull request Feb 21, 2024
An assert was added in [1] to avoid tracking the same output multiple
times. However, this is cumbersome for compositors [2]: they need to
add a special check for this. Additionally, this is inconsistent with
wlr_output_layout_add().

[1]: https://gitlab.freedesktop.org/wlroots/wlroots/-/merge_requests/4380
[2]: cage-kiosk/cage#315
@emersion
Copy link
Contributor Author

emersion commented Feb 23, 2024

Let's merge for now, and revert later if the wlroots patch ends up backported + released.

@emersion emersion merged commit d07afac into cage-kiosk:master Feb 23, 2024
10 checks passed
@emersion emersion deleted the fix-layout-add-assert branch February 23, 2024 11:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants