Skip to content
This repository has been archived by the owner on Nov 1, 2021. It is now read-only.

layer-shell: refactor configure/state flow #3201

Merged
merged 1 commit into from
Sep 23, 2021

Conversation

vyivel
Copy link
Member

@vyivel vyivel commented Sep 18, 2021

Same logic as xdg-toplevel.


Preliminary work for #3151.

This is a breaking change: compositors that used to check wlr_layer_surface_v1.client_pending will now have to check wlr_layer_surface_v1.pending

Copy link
Member

@ifreund ifreund left a comment

Choose a reason for hiding this comment

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

This is a nice simplification, I think it can be made even simpler though

include/wlr/types/wlr_layer_shell_v1.h Outdated Show resolved Hide resolved
include/wlr/types/wlr_layer_shell_v1.h Outdated Show resolved Hide resolved
@vyivel vyivel force-pushed the layer-surface-state-refactor branch from 69f68fd to 6efc586 Compare September 18, 2021 15:02
@vyivel vyivel marked this pull request as draft September 20, 2021 14:53
@ifreund ifreund added the breaking Breaking change in public API label Sep 21, 2021
@vyivel vyivel force-pushed the layer-surface-state-refactor branch from 6efc586 to 077ded3 Compare September 21, 2021 12:51
@vyivel vyivel marked this pull request as ready for review September 21, 2021 12:58
@vyivel vyivel force-pushed the layer-surface-state-refactor branch from 077ded3 to 136e388 Compare September 21, 2021 13:30
Copy link
Member

@ifreund ifreund left a comment

Choose a reason for hiding this comment

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

I'm not entirely convinced that using the idle event source/configure scheduling strategy here makes sense. It feels like we're doing it just because the code is a bit closer to the xdg shell implementation, not because it actually provides a meaningful benefit for layer shell.

The refactor of the states you have done looks unambiguously good to me, and I'd be happy to merge that part. Maybe it would make sense to move the commit adding scheduling/batching to a separate PR and keep this one focused on the refactor without adding features?

@vyivel
Copy link
Member Author

vyivel commented Sep 22, 2021

I guess the benefits are 1) not sending two configure events one after other (although that's unlikely to happen) and 2) having more predictable logic and API, which I consider to be more important than the simplicity of implementation (partly the reason I made these PRs), especially considering that scheduling isn't that complex anyway.

@vyivel
Copy link
Member Author

vyivel commented Sep 22, 2021

Note to self: move adding scheduled to the second commit. Done.

@vyivel vyivel force-pushed the layer-surface-state-refactor branch 3 times, most recently from 4b659af to df2adff Compare September 23, 2021 18:00
@vyivel
Copy link
Member Author

vyivel commented Sep 23, 2021

Moved scheduling logic commit to #3212.

@vyivel vyivel requested a review from ifreund September 23, 2021 18:08
@vyivel vyivel force-pushed the layer-surface-state-refactor branch from df2adff to 8906365 Compare September 23, 2021 18:27
Copy link
Member

@ifreund ifreund left a comment

Choose a reason for hiding this comment

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

Thanks for splitting this up, this patch looks nearly ready to merge.

types/wlr_layer_shell_v1.c Outdated Show resolved Hide resolved
@@ -257,49 +256,45 @@ static void layer_surface_resource_destroy(struct wl_resource *resource) {
}
}

static bool layer_surface_state_changed(struct wlr_layer_surface_v1 *surface) {
struct wlr_layer_surface_v1_state *state;
static bool layer_surface_state_changed(struct wlr_layer_surface_v1 *surface,
Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we shouldn't just get rid of this function and the configure_next_serial field in this patch already.

Copy link
Member

Choose a reason for hiding this comment

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

Though actually, I don't think the layer shell protocol ever requires the compositor to send a noop configure, unlike the xdg-shell protocol. This is fine as-is I believe.

Copy link
Member

@ifreund ifreund Sep 23, 2021

Choose a reason for hiding this comment

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

On the other hand, if the compositor saves the configure serial returned and waits for the client to ack that serial, this function can cause problems. If this function returns false no new configure will be sent or new serial generated, which means that the compositor may hang forever. I'm back to thinking we should just get rid of it and behave in the most predictable way possible for compositors.

Copy link
Member Author

Choose a reason for hiding this comment

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

Removed the function and the associated check, if the caller wants to send a configure then why not. wlr_layer_surface_v1_configure() now returns surface->pending.configure_serial on memory allocation failure, not like it matters much.

Same logic as xdg-toplevel.
@vyivel vyivel force-pushed the layer-surface-state-refactor branch from 8906365 to 8f7a4f5 Compare September 23, 2021 19:11
Copy link
Member

@ifreund ifreund left a comment

Choose a reason for hiding this comment

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

LGTM, Thanks!

@ifreund ifreund merged commit 59fa363 into swaywm:master Sep 23, 2021
@vyivel
Copy link
Member Author

vyivel commented Sep 23, 2021

Thanks a lot for reviewing!

@emersion emersion mentioned this pull request Sep 23, 2021
@vyivel vyivel deleted the layer-surface-state-refactor branch September 23, 2021 19:24
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
breaking Breaking change in public API
Development

Successfully merging this pull request may close these issues.

2 participants