diff options
-rw-r--r-- | include/sway/output.h | 17 | ||||
-rw-r--r-- | sway/desktop/output.c | 73 | ||||
-rw-r--r-- | sway/desktop/render.c | 31 |
3 files changed, 110 insertions, 11 deletions
diff --git a/include/sway/output.h b/include/sway/output.h index c225e541..99b0bcc6 100644 --- a/include/sway/output.h +++ b/include/sway/output.h | |||
@@ -5,6 +5,7 @@ | |||
5 | #include <wayland-server.h> | 5 | #include <wayland-server.h> |
6 | #include <wlr/types/wlr_box.h> | 6 | #include <wlr/types/wlr_box.h> |
7 | #include <wlr/types/wlr_output.h> | 7 | #include <wlr/types/wlr_output.h> |
8 | #include "config.h" | ||
8 | #include "sway/tree/view.h" | 9 | #include "sway/tree/view.h" |
9 | 10 | ||
10 | struct sway_server; | 11 | struct sway_server; |
@@ -48,6 +49,10 @@ struct root_geometry { | |||
48 | float rotation; | 49 | float rotation; |
49 | }; | 50 | }; |
50 | 51 | ||
52 | typedef void (*sway_surface_iterator_func_t)(struct sway_output *output, | ||
53 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | ||
54 | void *user_data); | ||
55 | |||
51 | void output_damage_whole(struct sway_output *output); | 56 | void output_damage_whole(struct sway_output *output); |
52 | 57 | ||
53 | void output_damage_surface(struct sway_output *output, double ox, double oy, | 58 | 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, | |||
80 | double ox, double oy, struct root_geometry *geo, | 85 | double ox, double oy, struct root_geometry *geo, |
81 | wlr_surface_iterator_func_t iterator, void *user_data); | 86 | wlr_surface_iterator_func_t iterator, void *user_data); |
82 | 87 | ||
88 | void output_surface_for_each_surface2(struct sway_output *output, | ||
89 | struct wlr_surface *surface, double ox, double oy, float rotation, | ||
90 | sway_surface_iterator_func_t iterator, void *user_data); | ||
91 | |||
83 | void output_view_for_each_surface(struct sway_view *view, | 92 | void output_view_for_each_surface(struct sway_view *view, |
84 | struct sway_output *output, struct root_geometry *geo, | 93 | struct sway_output *output, struct root_geometry *geo, |
85 | wlr_surface_iterator_func_t iterator, void *user_data); | 94 | wlr_surface_iterator_func_t iterator, void *user_data); |
@@ -88,9 +97,11 @@ void output_layer_for_each_surface(struct wl_list *layer_surfaces, | |||
88 | struct root_geometry *geo, wlr_surface_iterator_func_t iterator, | 97 | struct root_geometry *geo, wlr_surface_iterator_func_t iterator, |
89 | void *user_data); | 98 | void *user_data); |
90 | 99 | ||
91 | void output_unmanaged_for_each_surface(struct wl_list *unmanaged, | 100 | #ifdef HAVE_XWAYLAND |
92 | struct sway_output *output, struct root_geometry *geo, | 101 | void output_unmanaged_for_each_surface(struct sway_output *output, |
93 | wlr_surface_iterator_func_t iterator, void *user_data); | 102 | struct wl_list *unmanaged, sway_surface_iterator_func_t iterator, |
103 | void *user_data); | ||
104 | #endif | ||
94 | 105 | ||
95 | void output_drag_icons_for_each_surface(struct wl_list *drag_icons, | 106 | void output_drag_icons_for_each_surface(struct wl_list *drag_icons, |
96 | struct sway_output *output, struct root_geometry *geo, | 107 | struct sway_output *output, struct root_geometry *geo, |
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, | |||
105 | wlr_surface_for_each_surface(surface, iterator, user_data); | 105 | wlr_surface_for_each_surface(surface, iterator, user_data); |
106 | } | 106 | } |
107 | 107 | ||
108 | struct surface_iterator_data { | ||
109 | sway_surface_iterator_func_t user_iterator; | ||
110 | void *user_data; | ||
111 | |||
112 | struct sway_output *output; | ||
113 | double ox, oy; | ||
114 | int width, height; | ||
115 | float rotation; | ||
116 | }; | ||
117 | |||
118 | void output_surface_for_each_surface2_iterator(struct wlr_surface *surface, | ||
119 | int sx, int sy, void *_data) { | ||
120 | struct surface_iterator_data *data = _data; | ||
121 | |||
122 | struct root_geometry geo = { | ||
123 | .x = data->ox, | ||
124 | .y = data->oy, | ||
125 | .width = data->width, | ||
126 | .height = data->height, | ||
127 | .rotation = data->rotation, | ||
128 | }; | ||
129 | struct wlr_box box; | ||
130 | bool intersects = output_get_surface_box(&geo, data->output, | ||
131 | surface, sx, sy, &box); | ||
132 | if (!intersects) { | ||
133 | return; | ||
134 | } | ||
135 | |||
136 | data->user_iterator(data->output, surface, &box, data->rotation, | ||
137 | data->user_data); | ||
138 | } | ||
139 | |||
140 | void output_surface_for_each_surface2(struct sway_output *output, | ||
141 | struct wlr_surface *surface, double ox, double oy, float rotation, | ||
142 | sway_surface_iterator_func_t iterator, void *user_data) { | ||
143 | struct surface_iterator_data data = { | ||
144 | .user_iterator = iterator, | ||
145 | .user_data = user_data, | ||
146 | .output = output, | ||
147 | .ox = ox, | ||
148 | .oy = oy, | ||
149 | .width = surface->current.width, | ||
150 | .height = surface->current.height, | ||
151 | .rotation = rotation, | ||
152 | }; | ||
153 | |||
154 | wlr_surface_for_each_surface(surface, | ||
155 | output_surface_for_each_surface2_iterator, &data); | ||
156 | } | ||
157 | |||
108 | void output_view_for_each_surface(struct sway_view *view, | 158 | void output_view_for_each_surface(struct sway_view *view, |
109 | struct sway_output *output, struct root_geometry *geo, | 159 | struct sway_output *output, struct root_geometry *geo, |
110 | wlr_surface_iterator_func_t iterator, void *user_data) { | 160 | wlr_surface_iterator_func_t iterator, void *user_data) { |
@@ -129,10 +179,11 @@ void output_layer_for_each_surface(struct wl_list *layer_surfaces, | |||
129 | user_data); | 179 | user_data); |
130 | } | 180 | } |
131 | } | 181 | } |
182 | |||
132 | #ifdef HAVE_XWAYLAND | 183 | #ifdef HAVE_XWAYLAND |
133 | void output_unmanaged_for_each_surface(struct wl_list *unmanaged, | 184 | void output_unmanaged_for_each_surface(struct sway_output *output, |
134 | struct sway_output *output, struct root_geometry *geo, | 185 | struct wl_list *unmanaged, sway_surface_iterator_func_t iterator, |
135 | wlr_surface_iterator_func_t iterator, void *user_data) { | 186 | void *user_data) { |
136 | struct sway_xwayland_unmanaged *unmanaged_surface; | 187 | struct sway_xwayland_unmanaged *unmanaged_surface; |
137 | wl_list_for_each(unmanaged_surface, unmanaged, link) { | 188 | wl_list_for_each(unmanaged_surface, unmanaged, link) { |
138 | struct wlr_xwayland_surface *xsurface = | 189 | struct wlr_xwayland_surface *xsurface = |
@@ -140,11 +191,12 @@ void output_unmanaged_for_each_surface(struct wl_list *unmanaged, | |||
140 | double ox = unmanaged_surface->lx - output->swayc->current.swayc_x; | 191 | double ox = unmanaged_surface->lx - output->swayc->current.swayc_x; |
141 | double oy = unmanaged_surface->ly - output->swayc->current.swayc_y; | 192 | double oy = unmanaged_surface->ly - output->swayc->current.swayc_y; |
142 | 193 | ||
143 | output_surface_for_each_surface(xsurface->surface, ox, oy, geo, | 194 | output_surface_for_each_surface2(output, xsurface->surface, ox, oy, 0, |
144 | iterator, user_data); | 195 | iterator, user_data); |
145 | } | 196 | } |
146 | } | 197 | } |
147 | #endif | 198 | #endif |
199 | |||
148 | void output_drag_icons_for_each_surface(struct wl_list *drag_icons, | 200 | void output_drag_icons_for_each_surface(struct wl_list *drag_icons, |
149 | struct sway_output *output, struct root_geometry *geo, | 201 | struct sway_output *output, struct root_geometry *geo, |
150 | wlr_surface_iterator_func_t iterator, void *user_data) { | 202 | wlr_surface_iterator_func_t iterator, void *user_data) { |
@@ -228,18 +280,27 @@ static void send_frame_done_iterator(struct wlr_surface *surface, | |||
228 | } | 280 | } |
229 | } | 281 | } |
230 | 282 | ||
283 | static void send_frame_done_iterator2(struct sway_output *output, | ||
284 | struct wlr_surface *surface, struct wlr_box *box, float rotation, | ||
285 | void *_data) { | ||
286 | struct send_frame_done_data *data = _data; | ||
287 | wlr_surface_send_frame_done(surface, data->when); | ||
288 | } | ||
289 | |||
231 | static void send_frame_done_layer(struct send_frame_done_data *data, | 290 | static void send_frame_done_layer(struct send_frame_done_data *data, |
232 | struct wl_list *layer_surfaces) { | 291 | struct wl_list *layer_surfaces) { |
233 | output_layer_for_each_surface(layer_surfaces, &data->root_geo, | 292 | output_layer_for_each_surface(layer_surfaces, &data->root_geo, |
234 | send_frame_done_iterator, data); | 293 | send_frame_done_iterator, data); |
235 | } | 294 | } |
295 | |||
236 | #ifdef HAVE_XWAYLAND | 296 | #ifdef HAVE_XWAYLAND |
237 | static void send_frame_done_unmanaged(struct send_frame_done_data *data, | 297 | static void send_frame_done_unmanaged(struct send_frame_done_data *data, |
238 | struct wl_list *unmanaged) { | 298 | struct wl_list *unmanaged) { |
239 | output_unmanaged_for_each_surface(unmanaged, data->output, &data->root_geo, | 299 | output_unmanaged_for_each_surface(data->output, unmanaged, |
240 | send_frame_done_iterator, data); | 300 | send_frame_done_iterator2, data); |
241 | } | 301 | } |
242 | #endif | 302 | #endif |
303 | |||
243 | static void send_frame_done_drag_icons(struct send_frame_done_data *data, | 304 | static void send_frame_done_drag_icons(struct send_frame_done_data *data, |
244 | struct wl_list *drag_icons) { | 305 | struct wl_list *drag_icons) { |
245 | output_drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo, | 306 | 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, | |||
123 | render_texture(wlr_output, output_damage, texture, &box, matrix, alpha); | 123 | render_texture(wlr_output, output_damage, texture, &box, matrix, alpha); |
124 | } | 124 | } |
125 | 125 | ||
126 | static void render_surface_iterator2(struct sway_output *output, | ||
127 | struct wlr_surface *surface, struct wlr_box *_box, float rotation, | ||
128 | void *_data) { | ||
129 | struct render_data *data = _data; | ||
130 | struct wlr_output *wlr_output = output->wlr_output; | ||
131 | pixman_region32_t *output_damage = data->damage; | ||
132 | float alpha = data->alpha; | ||
133 | |||
134 | struct wlr_texture *texture = wlr_surface_get_texture(surface); | ||
135 | if (!texture) { | ||
136 | return; | ||
137 | } | ||
138 | |||
139 | struct wlr_box box = *_box; | ||
140 | scale_box(&box, wlr_output->scale); | ||
141 | |||
142 | float matrix[9]; | ||
143 | enum wl_output_transform transform = | ||
144 | wlr_output_transform_invert(surface->current.transform); | ||
145 | wlr_matrix_project_box(matrix, &box, transform, rotation, | ||
146 | wlr_output->transform_matrix); | ||
147 | |||
148 | render_texture(wlr_output, output_damage, texture, &box, matrix, alpha); | ||
149 | } | ||
150 | |||
126 | static void render_layer(struct sway_output *output, | 151 | static void render_layer(struct sway_output *output, |
127 | pixman_region32_t *damage, struct wl_list *layer_surfaces) { | 152 | pixman_region32_t *damage, struct wl_list *layer_surfaces) { |
128 | struct render_data data = { | 153 | struct render_data data = { |
@@ -133,6 +158,7 @@ static void render_layer(struct sway_output *output, | |||
133 | output_layer_for_each_surface(layer_surfaces, &data.root_geo, | 158 | output_layer_for_each_surface(layer_surfaces, &data.root_geo, |
134 | render_surface_iterator, &data); | 159 | render_surface_iterator, &data); |
135 | } | 160 | } |
161 | |||
136 | #ifdef HAVE_XWAYLAND | 162 | #ifdef HAVE_XWAYLAND |
137 | static void render_unmanaged(struct sway_output *output, | 163 | static void render_unmanaged(struct sway_output *output, |
138 | pixman_region32_t *damage, struct wl_list *unmanaged) { | 164 | pixman_region32_t *damage, struct wl_list *unmanaged) { |
@@ -141,10 +167,11 @@ static void render_unmanaged(struct sway_output *output, | |||
141 | .damage = damage, | 167 | .damage = damage, |
142 | .alpha = 1.0f, | 168 | .alpha = 1.0f, |
143 | }; | 169 | }; |
144 | output_unmanaged_for_each_surface(unmanaged, output, &data.root_geo, | 170 | output_unmanaged_for_each_surface(output, unmanaged, |
145 | render_surface_iterator, &data); | 171 | render_surface_iterator2, &data); |
146 | } | 172 | } |
147 | #endif | 173 | #endif |
174 | |||
148 | static void render_drag_icons(struct sway_output *output, | 175 | static void render_drag_icons(struct sway_output *output, |
149 | pixman_region32_t *damage, struct wl_list *drag_icons) { | 176 | pixman_region32_t *damage, struct wl_list *drag_icons) { |
150 | struct render_data data = { | 177 | struct render_data data = { |