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

surface: add WLR_SURFACE_STATE_SUBSURFACES #3170

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions include/wlr/types/wlr_surface.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ enum wlr_surface_state_field {
WLR_SURFACE_STATE_SCALE = 1 << 6,
WLR_SURFACE_STATE_FRAME_CALLBACK_LIST = 1 << 7,
WLR_SURFACE_STATE_VIEWPORT = 1 << 8,
WLR_SURFACE_STATE_SUBSURFACES = 1 << 9,
};

struct wlr_surface_state {
Expand Down
49 changes: 28 additions & 21 deletions types/wlr_surface.c
Original file line number Diff line number Diff line change
Expand Up @@ -458,28 +458,31 @@ static void surface_commit_state(struct wlr_surface *surface,
surface_update_opaque_region(surface);
surface_update_input_region(surface);

// commit subsurface order
struct wlr_subsurface *subsurface;
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_above,
pending.link) {
wl_list_remove(&subsurface->current.link);
wl_list_insert(&surface->current.subsurfaces_above,
&subsurface->current.link);

if (subsurface->reordered) {
// TODO: damage all the subsurfaces
surface_damage_subsurfaces(subsurface);
// TODO: use `next` instead of `surface->pending`
if (surface->pending.committed & WLR_SURFACE_STATE_SUBSURFACES) {
// commit subsurface order
struct wlr_subsurface *subsurface;
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_above,
pending.link) {
wl_list_remove(&subsurface->current.link);
wl_list_insert(&surface->current.subsurfaces_above,
&subsurface->current.link);

if (subsurface->reordered) {
// TODO: damage all the subsurfaces
surface_damage_subsurfaces(subsurface);
}
}
}
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_below,
pending.link) {
wl_list_remove(&subsurface->current.link);
wl_list_insert(&surface->current.subsurfaces_below,
&subsurface->current.link);

if (subsurface->reordered) {
// TODO: damage all the subsurfaces
surface_damage_subsurfaces(subsurface);
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_below,
pending.link) {
wl_list_remove(&subsurface->current.link);
wl_list_insert(&surface->current.subsurfaces_below,
&subsurface->current.link);

if (subsurface->reordered) {
// TODO: damage all the subsurfaces
surface_damage_subsurfaces(subsurface);
}
}
}

Expand Down Expand Up @@ -698,6 +701,7 @@ static void subsurface_destroy(struct wlr_subsurface *subsurface) {
wl_list_remove(&subsurface->surface_destroy.link);

if (subsurface->parent) {
subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES;
Copy link
Member

Choose a reason for hiding this comment

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

Subsurfaces are destroyed instantly, their removal isn't double-buffered.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, but I'd still like to give the caller a chance to figure out that the subsurface list changed…

Copy link
Member

Choose a reason for hiding this comment

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

I think callers should simply listen to new_subsurface/destroy signals, and WLR_SURFACE_STATE_SUBSURFACES should be left as an optimization thing.

wl_list_remove(&subsurface->current.link);
wl_list_remove(&subsurface->pending.link);
wl_list_remove(&subsurface->parent_destroy.link);
Expand Down Expand Up @@ -947,6 +951,7 @@ static void subsurface_handle_place_above(struct wl_client *client,
node = &sibling->pending.link;
}

subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES;
wl_list_remove(&subsurface->pending.link);
wl_list_insert(node, &subsurface->pending.link);

Expand Down Expand Up @@ -979,6 +984,7 @@ static void subsurface_handle_place_below(struct wl_client *client,
node = &sibling->pending.link;
}

subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES;
wl_list_remove(&subsurface->pending.link);
wl_list_insert(node->prev, &subsurface->pending.link);

Expand Down Expand Up @@ -1190,6 +1196,7 @@ struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,

// link parent
subsurface->parent = parent;
subsurface->parent->pending.committed |= WLR_SURFACE_STATE_SUBSURFACES;
wl_signal_add(&parent->events.destroy, &subsurface->parent_destroy);
subsurface->parent_destroy.notify = subsurface_handle_parent_destroy;
wl_list_insert(parent->current.subsurfaces_above.prev, &subsurface->current.link);
Expand Down