diff options
author | emersion <contact@emersion.fr> | 2018-07-27 18:17:47 +0100 |
---|---|---|
committer | emersion <contact@emersion.fr> | 2018-07-29 14:33:26 +0100 |
commit | d2172bd331937ab406175a6b4c5a76db6f406fbe (patch) | |
tree | 1fe59e7023589c1c8f0ef0f512e2de8aa6df36fa /sway/desktop/output.c | |
parent | Merge pull request #2380 from mariusor/tap-button-map-man-fix (diff) | |
download | sway-d2172bd331937ab406175a6b4c5a76db6f406fbe.tar.gz sway-d2172bd331937ab406175a6b4c5a76db6f406fbe.tar.zst sway-d2172bd331937ab406175a6b4c5a76db6f406fbe.zip |
wip: redesign output_unmanaged_for_each_surface iterator
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 73 |
1 files changed, 67 insertions, 6 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, | |||
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, |