mirror of
https://github.com/swaywm/sway.git
synced 2024-11-26 01:41:30 +00:00
wip: redesign output_unmanaged_for_each_surface iterator
This commit is contained in:
parent
8fcf0505d0
commit
d2172bd331
|
@ -5,6 +5,7 @@
|
||||||
#include <wayland-server.h>
|
#include <wayland-server.h>
|
||||||
#include <wlr/types/wlr_box.h>
|
#include <wlr/types/wlr_box.h>
|
||||||
#include <wlr/types/wlr_output.h>
|
#include <wlr/types/wlr_output.h>
|
||||||
|
#include "config.h"
|
||||||
#include "sway/tree/view.h"
|
#include "sway/tree/view.h"
|
||||||
|
|
||||||
struct sway_server;
|
struct sway_server;
|
||||||
|
@ -48,6 +49,10 @@ struct root_geometry {
|
||||||
float rotation;
|
float rotation;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
typedef void (*sway_surface_iterator_func_t)(struct sway_output *output,
|
||||||
|
struct wlr_surface *surface, struct wlr_box *box, float rotation,
|
||||||
|
void *user_data);
|
||||||
|
|
||||||
void output_damage_whole(struct sway_output *output);
|
void output_damage_whole(struct sway_output *output);
|
||||||
|
|
||||||
void output_damage_surface(struct sway_output *output, double ox, double oy,
|
void output_damage_surface(struct sway_output *output, double ox, double oy,
|
||||||
|
@ -80,6 +85,10 @@ void output_surface_for_each_surface(struct wlr_surface *surface,
|
||||||
double ox, double oy, struct root_geometry *geo,
|
double ox, double oy, struct root_geometry *geo,
|
||||||
wlr_surface_iterator_func_t iterator, void *user_data);
|
wlr_surface_iterator_func_t iterator, void *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);
|
||||||
|
|
||||||
void output_view_for_each_surface(struct sway_view *view,
|
void output_view_for_each_surface(struct sway_view *view,
|
||||||
struct sway_output *output, struct root_geometry *geo,
|
struct sway_output *output, struct root_geometry *geo,
|
||||||
wlr_surface_iterator_func_t iterator, void *user_data);
|
wlr_surface_iterator_func_t iterator, void *user_data);
|
||||||
|
@ -88,9 +97,11 @@ void output_layer_for_each_surface(struct wl_list *layer_surfaces,
|
||||||
struct root_geometry *geo, wlr_surface_iterator_func_t iterator,
|
struct root_geometry *geo, wlr_surface_iterator_func_t iterator,
|
||||||
void *user_data);
|
void *user_data);
|
||||||
|
|
||||||
void output_unmanaged_for_each_surface(struct wl_list *unmanaged,
|
#ifdef HAVE_XWAYLAND
|
||||||
struct sway_output *output, struct root_geometry *geo,
|
void output_unmanaged_for_each_surface(struct sway_output *output,
|
||||||
wlr_surface_iterator_func_t iterator, void *user_data);
|
struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
|
||||||
|
void *user_data);
|
||||||
|
#endif
|
||||||
|
|
||||||
void output_drag_icons_for_each_surface(struct wl_list *drag_icons,
|
void output_drag_icons_for_each_surface(struct wl_list *drag_icons,
|
||||||
struct sway_output *output, struct root_geometry *geo,
|
struct sway_output *output, struct root_geometry *geo,
|
||||||
|
|
|
@ -105,6 +105,56 @@ void output_surface_for_each_surface(struct wlr_surface *surface,
|
||||||
wlr_surface_for_each_surface(surface, iterator, user_data);
|
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,
|
void output_view_for_each_surface(struct sway_view *view,
|
||||||
struct sway_output *output, struct root_geometry *geo,
|
struct sway_output *output, struct root_geometry *geo,
|
||||||
wlr_surface_iterator_func_t iterator, void *user_data) {
|
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);
|
user_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XWAYLAND
|
#ifdef HAVE_XWAYLAND
|
||||||
void output_unmanaged_for_each_surface(struct wl_list *unmanaged,
|
void output_unmanaged_for_each_surface(struct sway_output *output,
|
||||||
struct sway_output *output, struct root_geometry *geo,
|
struct wl_list *unmanaged, sway_surface_iterator_func_t iterator,
|
||||||
wlr_surface_iterator_func_t iterator, void *user_data) {
|
void *user_data) {
|
||||||
struct sway_xwayland_unmanaged *unmanaged_surface;
|
struct sway_xwayland_unmanaged *unmanaged_surface;
|
||||||
wl_list_for_each(unmanaged_surface, unmanaged, link) {
|
wl_list_for_each(unmanaged_surface, unmanaged, link) {
|
||||||
struct wlr_xwayland_surface *xsurface =
|
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 ox = unmanaged_surface->lx - output->swayc->current.swayc_x;
|
||||||
double oy = unmanaged_surface->ly - output->swayc->current.swayc_y;
|
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);
|
iterator, user_data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void output_drag_icons_for_each_surface(struct wl_list *drag_icons,
|
void output_drag_icons_for_each_surface(struct wl_list *drag_icons,
|
||||||
struct sway_output *output, struct root_geometry *geo,
|
struct sway_output *output, struct root_geometry *geo,
|
||||||
wlr_surface_iterator_func_t iterator, void *user_data) {
|
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,
|
static void send_frame_done_layer(struct send_frame_done_data *data,
|
||||||
struct wl_list *layer_surfaces) {
|
struct wl_list *layer_surfaces) {
|
||||||
output_layer_for_each_surface(layer_surfaces, &data->root_geo,
|
output_layer_for_each_surface(layer_surfaces, &data->root_geo,
|
||||||
send_frame_done_iterator, data);
|
send_frame_done_iterator, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XWAYLAND
|
#ifdef HAVE_XWAYLAND
|
||||||
static void send_frame_done_unmanaged(struct send_frame_done_data *data,
|
static void send_frame_done_unmanaged(struct send_frame_done_data *data,
|
||||||
struct wl_list *unmanaged) {
|
struct wl_list *unmanaged) {
|
||||||
output_unmanaged_for_each_surface(unmanaged, data->output, &data->root_geo,
|
output_unmanaged_for_each_surface(data->output, unmanaged,
|
||||||
send_frame_done_iterator, data);
|
send_frame_done_iterator2, data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void send_frame_done_drag_icons(struct send_frame_done_data *data,
|
static void send_frame_done_drag_icons(struct send_frame_done_data *data,
|
||||||
struct wl_list *drag_icons) {
|
struct wl_list *drag_icons) {
|
||||||
output_drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo,
|
output_drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo,
|
||||||
|
|
|
@ -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);
|
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,
|
static void render_layer(struct sway_output *output,
|
||||||
pixman_region32_t *damage, struct wl_list *layer_surfaces) {
|
pixman_region32_t *damage, struct wl_list *layer_surfaces) {
|
||||||
struct render_data data = {
|
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,
|
output_layer_for_each_surface(layer_surfaces, &data.root_geo,
|
||||||
render_surface_iterator, &data);
|
render_surface_iterator, &data);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_XWAYLAND
|
#ifdef HAVE_XWAYLAND
|
||||||
static void render_unmanaged(struct sway_output *output,
|
static void render_unmanaged(struct sway_output *output,
|
||||||
pixman_region32_t *damage, struct wl_list *unmanaged) {
|
pixman_region32_t *damage, struct wl_list *unmanaged) {
|
||||||
|
@ -141,10 +167,11 @@ static void render_unmanaged(struct sway_output *output,
|
||||||
.damage = damage,
|
.damage = damage,
|
||||||
.alpha = 1.0f,
|
.alpha = 1.0f,
|
||||||
};
|
};
|
||||||
output_unmanaged_for_each_surface(unmanaged, output, &data.root_geo,
|
output_unmanaged_for_each_surface(output, unmanaged,
|
||||||
render_surface_iterator, &data);
|
render_surface_iterator2, &data);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void render_drag_icons(struct sway_output *output,
|
static void render_drag_icons(struct sway_output *output,
|
||||||
pixman_region32_t *damage, struct wl_list *drag_icons) {
|
pixman_region32_t *damage, struct wl_list *drag_icons) {
|
||||||
struct render_data data = {
|
struct render_data data = {
|
||||||
|
|
Loading…
Reference in a new issue