aboutsummaryrefslogtreecommitdiff
path: root/sway
diff options
context:
space:
mode:
authoremersion <contact@emersion.fr>2018-07-27 18:17:47 +0100
committeremersion <contact@emersion.fr>2018-07-29 14:33:26 +0100
commitd2172bd331937ab406175a6b4c5a76db6f406fbe (patch)
tree1fe59e7023589c1c8f0ef0f512e2de8aa6df36fa /sway
parent8fcf0505d096ce1564e39fb5f6c2256e3f704ad2 (diff)
wip: redesign output_unmanaged_for_each_surface iterator
Diffstat (limited to 'sway')
-rw-r--r--sway/desktop/output.c73
-rw-r--r--sway/desktop/render.c31
2 files changed, 96 insertions, 8 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c
index cecd300a..9c2a1a07 100644
--- a/sway/desktop/output.c
+++ b/sway/desktop/output.c
@@ -105,6 +105,56 @@ void output_surface_for_each_surface(struct wlr_surface *surface,
wlr_surface_for_each_surface(surface, iterator, user_data);
}
+struct surface_iterator_data {
+ sway_surface_iterator_func_t user_iterator;
+ void *user_data;
+
+ struct sway_output *output;
+ double ox, oy;
+ int width, height;
+ float rotation;
+};
+
+void output_surface_for_each_surface2_iterator(struct wlr_surface *surface,
+ int sx, int sy, void *_data) {
+ struct surface_iterator_data *data = _data;
+
+ struct root_geometry geo = {
+ .x = data->ox,
+ .y = data->oy,
+ .width = data->width,
+ .height = data->height,
+ .rotation = data->rotation,
+ };
+ struct wlr_box box;
+ bool intersects = output_get_surface_box(&geo, data->output,
+ surface, sx, sy, &box);
+ if (!intersects) {
+ return;
+ }
+
+ data->user_iterator(data->output, surface, &box, data->rotation,
+ data->user_data);
+}
+
+void output_surface_for_each_surface2(struct sway_output *output,
+ struct wlr_surface *surface, double ox, double oy, float rotation,
+ sway_surface_iterator_func_t iterator, void *user_data) {
+ struct surface_iterator_data data = {
+ .user_iterator = iterator,
+ .user_data = user_data,
+ .output = output,
+ .ox = ox,
+ .oy = oy,
+ .width = surface->current.width,
+ .height = surface->current.height,
+ .rotation = rotation,
+ };
+
+ wlr_surface_for_each_surface(surface,
+ output_surface_for_each_surface2_iterator, &data);
+}
+
void output_view_for_each_surface(struct sway_view *view,
struct sway_output *output, struct root_geometry *geo,
wlr_surface_iterator_func_t iterator, void *user_data) {
@@ -129,10 +179,11 @@ void output_layer_for_each_surface(struct wl_list *layer_surfaces,
user_data);
}
}
+
#ifdef HAVE_XWAYLAND
-void output_unmanaged_for_each_surface(struct wl_list *unmanaged,
- struct sway_output *output, struct root_geometry *geo,
- wlr_surface_iterator_func_t iterator, void *user_data) {
+void output_unmanaged_for_each_surface(struct sway_output *output,
+ struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
+ void *user_data) {
struct sway_xwayland_unmanaged *unmanaged_surface;
wl_list_for_each(unmanaged_surface, unmanaged, link) {
struct wlr_xwayland_surface *xsurface =
@@ -140,11 +191,12 @@ void output_unmanaged_for_each_surface(struct wl_list *unmanaged,
double ox = unmanaged_surface->lx - output->swayc->current.swayc_x;
double oy = unmanaged_surface->ly - output->swayc->current.swayc_y;
- output_surface_for_each_surface(xsurface->surface, ox, oy, geo,
+ output_surface_for_each_surface2(output, xsurface->surface, ox, oy, 0,
iterator, user_data);
}
}
#endif
+
void output_drag_icons_for_each_surface(struct wl_list *drag_icons,
struct sway_output *output, struct root_geometry *geo,
wlr_surface_iterator_func_t iterator, void *user_data) {
@@ -228,18 +280,27 @@ static void send_frame_done_iterator(struct wlr_surface *surface,
}
}
+static void send_frame_done_iterator2(struct sway_output *output,
+ struct wlr_surface *surface, struct wlr_box *box, float rotation,
+ void *_data) {
+ struct send_frame_done_data *data = _data;
+ wlr_surface_send_frame_done(surface, data->when);
+}
+
static void send_frame_done_layer(struct send_frame_done_data *data,
struct wl_list *layer_surfaces) {
output_layer_for_each_surface(layer_surfaces, &data->root_geo,
send_frame_done_iterator, data);
}
+
#ifdef HAVE_XWAYLAND
static void send_frame_done_unmanaged(struct send_frame_done_data *data,
struct wl_list *unmanaged) {
- output_unmanaged_for_each_surface(unmanaged, data->output, &data->root_geo,
- send_frame_done_iterator, data);
+ output_unmanaged_for_each_surface(data->output, unmanaged,
+ send_frame_done_iterator2, data);
}
#endif
+
static void send_frame_done_drag_icons(struct send_frame_done_data *data,
struct wl_list *drag_icons) {
output_drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo,
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index c9fdfd95..8eea19e0 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -123,6 +123,31 @@ static void render_surface_iterator(struct wlr_surface *surface, int sx, int sy,
render_texture(wlr_output, output_damage, texture, &box, matrix, alpha);
}
+static void render_surface_iterator2(struct sway_output *output,
+ struct wlr_surface *surface, struct wlr_box *_box, float rotation,
+ void *_data) {
+ struct render_data *data = _data;
+ struct wlr_output *wlr_output = output->wlr_output;
+ pixman_region32_t *output_damage = data->damage;
+ float alpha = data->alpha;
+
+ struct wlr_texture *texture = wlr_surface_get_texture(surface);
+ if (!texture) {
+ return;
+ }
+
+ struct wlr_box box = *_box;
+ scale_box(&box, wlr_output->scale);
+
+ float matrix[9];
+ enum wl_output_transform transform =
+ wlr_output_transform_invert(surface->current.transform);
+ wlr_matrix_project_box(matrix, &box, transform, rotation,
+ wlr_output->transform_matrix);
+
+ render_texture(wlr_output, output_damage, texture, &box, matrix, alpha);
+}
+
static void render_layer(struct sway_output *output,
pixman_region32_t *damage, struct wl_list *layer_surfaces) {
struct render_data data = {
@@ -133,6 +158,7 @@ static void render_layer(struct sway_output *output,
output_layer_for_each_surface(layer_surfaces, &data.root_geo,
render_surface_iterator, &data);
}
+
#ifdef HAVE_XWAYLAND
static void render_unmanaged(struct sway_output *output,
pixman_region32_t *damage, struct wl_list *unmanaged) {
@@ -141,10 +167,11 @@ static void render_unmanaged(struct sway_output *output,
.damage = damage,
.alpha = 1.0f,
};
- output_unmanaged_for_each_surface(unmanaged, output, &data.root_geo,
- render_surface_iterator, &data);
+ output_unmanaged_for_each_surface(output, unmanaged,
+ render_surface_iterator2, &data);
}
#endif
+
static void render_drag_icons(struct sway_output *output,
pixman_region32_t *damage, struct wl_list *drag_icons) {
struct render_data data = {