mirror of
https://github.com/hyprwm/wlroots-hyprland.git
synced 2024-11-12 16:35:58 +01:00
surface: move subsurface lists to state
This commit is contained in:
parent
3ac99fa4dc
commit
90e62390d9
2 changed files with 30 additions and 36 deletions
|
@ -47,6 +47,9 @@ struct wlr_surface_state {
|
|||
int width, height; // in surface-local coordinates
|
||||
int buffer_width, buffer_height;
|
||||
|
||||
struct wl_list subsurfaces_below;
|
||||
struct wl_list subsurfaces_above;
|
||||
|
||||
/**
|
||||
* The viewport is applied after the surface transform and scale.
|
||||
*
|
||||
|
@ -139,14 +142,6 @@ struct wlr_surface {
|
|||
struct wl_signal destroy;
|
||||
} events;
|
||||
|
||||
// wlr_subsurface.parent_link
|
||||
struct wl_list subsurfaces_below;
|
||||
struct wl_list subsurfaces_above;
|
||||
|
||||
// wlr_subsurface.parent_pending_link
|
||||
struct wl_list subsurfaces_pending_below;
|
||||
struct wl_list subsurfaces_pending_above;
|
||||
|
||||
struct wl_list current_outputs; // wlr_surface_output::link
|
||||
|
||||
void *data;
|
||||
|
|
|
@ -341,11 +341,11 @@ static void surface_damage_subsurfaces(struct wlr_subsurface *subsurface) {
|
|||
subsurface->reordered = false;
|
||||
|
||||
struct wlr_subsurface *child;
|
||||
wl_list_for_each(child, &subsurface->surface->subsurfaces_below,
|
||||
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_below,
|
||||
current.link) {
|
||||
surface_damage_subsurfaces(child);
|
||||
}
|
||||
wl_list_for_each(child, &subsurface->surface->subsurfaces_above,
|
||||
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_above,
|
||||
current.link) {
|
||||
surface_damage_subsurfaces(child);
|
||||
}
|
||||
|
@ -459,10 +459,10 @@ static void surface_commit_state(struct wlr_surface *surface,
|
|||
|
||||
// commit subsurface order
|
||||
struct wlr_subsurface *subsurface;
|
||||
wl_list_for_each_reverse(subsurface, &surface->subsurfaces_pending_above,
|
||||
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_above,
|
||||
pending.link) {
|
||||
wl_list_remove(&subsurface->current.link);
|
||||
wl_list_insert(&surface->subsurfaces_above,
|
||||
wl_list_insert(&surface->current.subsurfaces_above,
|
||||
&subsurface->current.link);
|
||||
|
||||
if (subsurface->reordered) {
|
||||
|
@ -470,10 +470,10 @@ static void surface_commit_state(struct wlr_surface *surface,
|
|||
surface_damage_subsurfaces(subsurface);
|
||||
}
|
||||
}
|
||||
wl_list_for_each_reverse(subsurface, &surface->subsurfaces_pending_below,
|
||||
wl_list_for_each_reverse(subsurface, &surface->pending.subsurfaces_below,
|
||||
pending.link) {
|
||||
wl_list_remove(&subsurface->current.link);
|
||||
wl_list_insert(&surface->subsurfaces_below,
|
||||
wl_list_insert(&surface->current.subsurfaces_below,
|
||||
&subsurface->current.link);
|
||||
|
||||
if (subsurface->reordered) {
|
||||
|
@ -542,11 +542,11 @@ static void subsurface_parent_commit(struct wlr_subsurface *subsurface,
|
|||
}
|
||||
|
||||
struct wlr_subsurface *subsurface;
|
||||
wl_list_for_each(subsurface, &surface->subsurfaces_below,
|
||||
wl_list_for_each(subsurface, &surface->current.subsurfaces_below,
|
||||
current.link) {
|
||||
subsurface_parent_commit(subsurface, true);
|
||||
}
|
||||
wl_list_for_each(subsurface, &surface->subsurfaces_above,
|
||||
wl_list_for_each(subsurface, &surface->current.subsurfaces_above,
|
||||
current.link) {
|
||||
subsurface_parent_commit(subsurface, true);
|
||||
}
|
||||
|
@ -579,10 +579,10 @@ static void surface_commit(struct wl_client *client,
|
|||
|
||||
surface_commit_pending(surface);
|
||||
|
||||
wl_list_for_each(subsurface, &surface->subsurfaces_below, current.link) {
|
||||
wl_list_for_each(subsurface, &surface->current.subsurfaces_below, current.link) {
|
||||
subsurface_parent_commit(subsurface, false);
|
||||
}
|
||||
wl_list_for_each(subsurface, &surface->subsurfaces_above, current.link) {
|
||||
wl_list_for_each(subsurface, &surface->current.subsurfaces_above, current.link) {
|
||||
subsurface_parent_commit(subsurface, false);
|
||||
}
|
||||
}
|
||||
|
@ -649,6 +649,9 @@ static void surface_state_init(struct wlr_surface_state *state) {
|
|||
state->scale = 1;
|
||||
state->transform = WL_OUTPUT_TRANSFORM_NORMAL;
|
||||
|
||||
wl_list_init(&state->subsurfaces_above);
|
||||
wl_list_init(&state->subsurfaces_below);
|
||||
|
||||
wl_list_init(&state->frame_callback_list);
|
||||
|
||||
pixman_region32_init(&state->surface_damage);
|
||||
|
@ -775,10 +778,6 @@ struct wlr_surface *surface_create(struct wl_client *client,
|
|||
wl_signal_init(&surface->events.commit);
|
||||
wl_signal_init(&surface->events.destroy);
|
||||
wl_signal_init(&surface->events.new_subsurface);
|
||||
wl_list_init(&surface->subsurfaces_above);
|
||||
wl_list_init(&surface->subsurfaces_below);
|
||||
wl_list_init(&surface->subsurfaces_pending_above);
|
||||
wl_list_init(&surface->subsurfaces_pending_below);
|
||||
wl_list_init(&surface->current_outputs);
|
||||
wl_list_init(&surface->cached);
|
||||
pixman_region32_init(&surface->buffer_damage);
|
||||
|
@ -911,12 +910,12 @@ static struct wlr_subsurface *subsurface_find_sibling(
|
|||
struct wlr_surface *parent = subsurface->parent;
|
||||
|
||||
struct wlr_subsurface *sibling;
|
||||
wl_list_for_each(sibling, &parent->subsurfaces_below, current.link) {
|
||||
wl_list_for_each(sibling, &parent->current.subsurfaces_below, current.link) {
|
||||
if (sibling->surface == surface && sibling != subsurface) {
|
||||
return sibling;
|
||||
}
|
||||
}
|
||||
wl_list_for_each(sibling, &parent->subsurfaces_above, current.link) {
|
||||
wl_list_for_each(sibling, &parent->current.subsurfaces_above, current.link) {
|
||||
if (sibling->surface == surface && sibling != subsurface) {
|
||||
return sibling;
|
||||
}
|
||||
|
@ -937,7 +936,7 @@ static void subsurface_handle_place_above(struct wl_client *client,
|
|||
|
||||
struct wl_list *node;
|
||||
if (sibling_surface == subsurface->parent) {
|
||||
node = &subsurface->parent->subsurfaces_pending_above;
|
||||
node = &subsurface->parent->pending.subsurfaces_above;
|
||||
} else {
|
||||
struct wlr_subsurface *sibling =
|
||||
subsurface_find_sibling(subsurface, sibling_surface);
|
||||
|
@ -969,7 +968,7 @@ static void subsurface_handle_place_below(struct wl_client *client,
|
|||
|
||||
struct wl_list *node;
|
||||
if (sibling_surface == subsurface->parent) {
|
||||
node = &subsurface->parent->subsurfaces_pending_below;
|
||||
node = &subsurface->parent->pending.subsurfaces_below;
|
||||
} else {
|
||||
struct wlr_subsurface *sibling =
|
||||
subsurface_find_sibling(subsurface, sibling_surface);
|
||||
|
@ -1061,11 +1060,11 @@ static void subsurface_consider_map(struct wlr_subsurface *subsurface,
|
|||
|
||||
// Try mapping all children too
|
||||
struct wlr_subsurface *child;
|
||||
wl_list_for_each(child, &subsurface->surface->subsurfaces_below,
|
||||
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_below,
|
||||
current.link) {
|
||||
subsurface_consider_map(child, false);
|
||||
}
|
||||
wl_list_for_each(child, &subsurface->surface->subsurfaces_above,
|
||||
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_above,
|
||||
current.link) {
|
||||
subsurface_consider_map(child, false);
|
||||
}
|
||||
|
@ -1081,11 +1080,11 @@ static void subsurface_unmap(struct wlr_subsurface *subsurface) {
|
|||
|
||||
// Unmap all children
|
||||
struct wlr_subsurface *child;
|
||||
wl_list_for_each(child, &subsurface->surface->subsurfaces_below,
|
||||
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_below,
|
||||
current.link) {
|
||||
subsurface_unmap(child);
|
||||
}
|
||||
wl_list_for_each(child, &subsurface->surface->subsurfaces_above,
|
||||
wl_list_for_each(child, &subsurface->surface->current.subsurfaces_above,
|
||||
current.link) {
|
||||
subsurface_unmap(child);
|
||||
}
|
||||
|
@ -1196,8 +1195,8 @@ struct wlr_subsurface *subsurface_create(struct wlr_surface *surface,
|
|||
subsurface->parent = parent;
|
||||
wl_signal_add(&parent->events.destroy, &subsurface->parent_destroy);
|
||||
subsurface->parent_destroy.notify = subsurface_handle_parent_destroy;
|
||||
wl_list_insert(parent->subsurfaces_above.prev, &subsurface->current.link);
|
||||
wl_list_insert(parent->subsurfaces_pending_above.prev,
|
||||
wl_list_insert(parent->current.subsurfaces_above.prev, &subsurface->current.link);
|
||||
wl_list_insert(parent->pending.subsurfaces_above.prev,
|
||||
&subsurface->pending.link);
|
||||
|
||||
surface->role_data = subsurface;
|
||||
|
@ -1233,7 +1232,7 @@ bool wlr_surface_point_accepts_input(struct wlr_surface *surface,
|
|||
struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
|
||||
double sx, double sy, double *sub_x, double *sub_y) {
|
||||
struct wlr_subsurface *subsurface;
|
||||
wl_list_for_each_reverse(subsurface, &surface->subsurfaces_above,
|
||||
wl_list_for_each_reverse(subsurface, &surface->current.subsurfaces_above,
|
||||
current.link) {
|
||||
double _sub_x = subsurface->current.x;
|
||||
double _sub_y = subsurface->current.y;
|
||||
|
@ -1254,7 +1253,7 @@ struct wlr_surface *wlr_surface_surface_at(struct wlr_surface *surface,
|
|||
return surface;
|
||||
}
|
||||
|
||||
wl_list_for_each_reverse(subsurface, &surface->subsurfaces_below,
|
||||
wl_list_for_each_reverse(subsurface, &surface->current.subsurfaces_below,
|
||||
current.link) {
|
||||
double _sub_x = subsurface->current.x;
|
||||
double _sub_y = subsurface->current.y;
|
||||
|
@ -1361,7 +1360,7 @@ void wlr_surface_send_frame_done(struct wlr_surface *surface,
|
|||
static void surface_for_each_surface(struct wlr_surface *surface, int x, int y,
|
||||
wlr_surface_iterator_func_t iterator, void *user_data) {
|
||||
struct wlr_subsurface *subsurface;
|
||||
wl_list_for_each(subsurface, &surface->subsurfaces_below, current.link) {
|
||||
wl_list_for_each(subsurface, &surface->current.subsurfaces_below, current.link) {
|
||||
struct wlr_subsurface_parent_state *state = &subsurface->current;
|
||||
int sx = state->x;
|
||||
int sy = state->y;
|
||||
|
@ -1372,7 +1371,7 @@ static void surface_for_each_surface(struct wlr_surface *surface, int x, int y,
|
|||
|
||||
iterator(surface, x, y, user_data);
|
||||
|
||||
wl_list_for_each(subsurface, &surface->subsurfaces_above, current.link) {
|
||||
wl_list_for_each(subsurface, &surface->current.subsurfaces_above, current.link) {
|
||||
struct wlr_subsurface_parent_state *state = &subsurface->current;
|
||||
int sx = state->x;
|
||||
int sy = state->y;
|
||||
|
|
Loading…
Reference in a new issue