Skip to content

Commit

Permalink
output: simplify layer surface iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
Vyivel authored and emersion committed Mar 11, 2021
1 parent 2e06403 commit ba6c0eb
Showing 1 changed file with 28 additions and 65 deletions.
93 changes: 28 additions & 65 deletions sway/desktop/output.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,40 +206,20 @@ void output_layer_for_each_surface(struct sway_output *output,
wl_list_for_each(layer_surface, layer_surfaces, link) {
struct wlr_layer_surface_v1 *wlr_layer_surface_v1 =
layer_surface->layer_surface;
output_surface_for_each_surface(output, wlr_layer_surface_v1->surface,
layer_surface->geo.x, layer_surface->geo.y, iterator,
user_data);

struct wlr_xdg_popup *state;
wl_list_for_each(state, &wlr_layer_surface_v1->popups, link) {
struct wlr_xdg_surface *popup = state->base;
if (!popup->configured) {
continue;
}

double popup_sx, popup_sy;
popup_sx = layer_surface->geo.x +
popup->popup->geometry.x - popup->geometry.x;
popup_sy = layer_surface->geo.y +
popup->popup->geometry.y - popup->geometry.y;

struct wlr_surface *surface = popup->surface;

struct surface_iterator_data data = {
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.view = NULL,
.ox = popup_sx,
.oy = popup_sy,
.width = surface->current.width,
.height = surface->current.height,
.rotation = 0,
};

wlr_xdg_surface_for_each_surface(
popup, output_for_each_surface_iterator, &data);
}
struct wlr_surface *surface = wlr_layer_surface_v1->surface;
struct surface_iterator_data data = {
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.view = NULL,
.ox = layer_surface->geo.x,
.oy = layer_surface->geo.y,
.width = surface->current.width,
.height = surface->current.height,
.rotation = 0,
};
wlr_layer_surface_v1_for_each_surface(wlr_layer_surface_v1,
output_for_each_surface_iterator, &data);
}
}

Expand All @@ -264,37 +244,20 @@ void output_layer_for_each_popup_surface(struct sway_output *output,
wl_list_for_each(layer_surface, layer_surfaces, link) {
struct wlr_layer_surface_v1 *wlr_layer_surface_v1 =
layer_surface->layer_surface;

struct wlr_xdg_popup *state;
wl_list_for_each(state, &wlr_layer_surface_v1->popups, link) {
struct wlr_xdg_surface *popup = state->base;
if (!popup->configured) {
continue;
}

double popup_sx, popup_sy;
popup_sx = layer_surface->geo.x +
popup->popup->geometry.x - popup->geometry.x;
popup_sy = layer_surface->geo.y +
popup->popup->geometry.y - popup->geometry.y;

struct wlr_surface *surface = popup->surface;

struct surface_iterator_data data = {
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.view = NULL,
.ox = popup_sx,
.oy = popup_sy,
.width = surface->current.width,
.height = surface->current.height,
.rotation = 0,
};

wlr_xdg_surface_for_each_surface(
popup, output_for_each_surface_iterator, &data);
}
struct wlr_surface *surface = wlr_layer_surface_v1->surface;
struct surface_iterator_data data = {
.user_iterator = iterator,
.user_data = user_data,
.output = output,
.view = NULL,
.ox = layer_surface->geo.x,
.oy = layer_surface->geo.y,
.width = surface->current.width,
.height = surface->current.height,
.rotation = 0,
};
wlr_layer_surface_v1_for_each_popup_surface(wlr_layer_surface_v1,
output_for_each_surface_iterator, &data);
}
}

Expand Down

0 comments on commit ba6c0eb

Please sign in to comment.