diff options
Diffstat (limited to 'sway/desktop/output.c')
-rw-r--r-- | sway/desktop/output.c | 57 |
1 files changed, 47 insertions, 10 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 29efdd50..5c26ac52 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -194,6 +194,21 @@ static void unmanaged_for_each_surface(struct wl_list *unmanaged, | |||
194 | } | 194 | } |
195 | } | 195 | } |
196 | 196 | ||
197 | static void drag_icons_for_each_surface(struct wl_list *drag_icons, | ||
198 | struct sway_output *output, struct root_geometry *geo, | ||
199 | wlr_surface_iterator_func_t iterator, void *user_data) { | ||
200 | struct sway_drag_icon *drag_icon; | ||
201 | wl_list_for_each(drag_icon, drag_icons, link) { | ||
202 | double ox = drag_icon->x - output->swayc->x; | ||
203 | double oy = drag_icon->y - output->swayc->y; | ||
204 | |||
205 | if (drag_icon->wlr_drag_icon->mapped) { | ||
206 | surface_for_each_surface(drag_icon->wlr_drag_icon->surface, | ||
207 | ox, oy, geo, iterator, user_data); | ||
208 | } | ||
209 | } | ||
210 | } | ||
211 | |||
197 | static void scale_box(struct wlr_box *box, float scale) { | 212 | static void scale_box(struct wlr_box *box, float scale) { |
198 | box->x *= scale; | 213 | box->x *= scale; |
199 | box->y *= scale; | 214 | box->y *= scale; |
@@ -315,6 +330,17 @@ static void render_unmanaged(struct sway_output *output, | |||
315 | render_surface_iterator, &data); | 330 | render_surface_iterator, &data); |
316 | } | 331 | } |
317 | 332 | ||
333 | static void render_drag_icons(struct sway_output *output, | ||
334 | pixman_region32_t *damage, struct wl_list *drag_icons) { | ||
335 | struct render_data data = { | ||
336 | .output = output, | ||
337 | .damage = damage, | ||
338 | .alpha = 1.0f, | ||
339 | }; | ||
340 | drag_icons_for_each_surface(drag_icons, output, &data.root_geo, | ||
341 | render_surface_iterator, &data); | ||
342 | } | ||
343 | |||
318 | static void render_rect(struct wlr_output *wlr_output, | 344 | static void render_rect(struct wlr_output *wlr_output, |
319 | pixman_region32_t *output_damage, const struct wlr_box *_box, | 345 | pixman_region32_t *output_damage, const struct wlr_box *_box, |
320 | float color[static 4]) { | 346 | float color[static 4]) { |
@@ -959,6 +985,7 @@ static void render_output(struct sway_output *output, struct timespec *when, | |||
959 | } | 985 | } |
960 | render_layer(output, damage, | 986 | render_layer(output, damage, |
961 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 987 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
988 | render_drag_icons(output, damage, &root_container.sway_root->drag_icons); | ||
962 | 989 | ||
963 | renderer_end: | 990 | renderer_end: |
964 | if (root_container.sway_root->debug_tree) { | 991 | if (root_container.sway_root->debug_tree) { |
@@ -1009,6 +1036,12 @@ static void send_frame_done_unmanaged(struct send_frame_done_data *data, | |||
1009 | send_frame_done_iterator, data); | 1036 | send_frame_done_iterator, data); |
1010 | } | 1037 | } |
1011 | 1038 | ||
1039 | static void send_frame_done_drag_icons(struct send_frame_done_data *data, | ||
1040 | struct wl_list *drag_icons) { | ||
1041 | drag_icons_for_each_surface(drag_icons, data->output, &data->root_geo, | ||
1042 | send_frame_done_iterator, data); | ||
1043 | } | ||
1044 | |||
1012 | static void send_frame_done_container_iterator(struct sway_container *con, | 1045 | static void send_frame_done_container_iterator(struct sway_container *con, |
1013 | void *_data) { | 1046 | void *_data) { |
1014 | struct send_frame_done_data *data = _data; | 1047 | struct send_frame_done_data *data = _data; |
@@ -1062,6 +1095,7 @@ static void send_frame_done(struct sway_output *output, struct timespec *when) { | |||
1062 | 1095 | ||
1063 | send_frame_done_layer(&data, | 1096 | send_frame_done_layer(&data, |
1064 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); | 1097 | &output->layers[ZWLR_LAYER_SHELL_V1_LAYER_OVERLAY]); |
1098 | send_frame_done_drag_icons(&data, &root_container.sway_root->drag_icons); | ||
1065 | } | 1099 | } |
1066 | 1100 | ||
1067 | static void damage_handle_frame(struct wl_listener *listener, void *data) { | 1101 | static void damage_handle_frame(struct wl_listener *listener, void *data) { |
@@ -1227,12 +1261,10 @@ static void handle_destroy(struct wl_listener *listener, void *data) { | |||
1227 | container_destroy(output->swayc); | 1261 | container_destroy(output->swayc); |
1228 | } | 1262 | } |
1229 | 1263 | ||
1230 | if (&output->link) { | 1264 | wl_list_remove(&output->link); |
1231 | wl_list_remove(&output->link); | 1265 | wl_list_remove(&output->destroy.link); |
1232 | wl_list_remove(&output->destroy.link); | 1266 | output->wlr_output->data = NULL; |
1233 | output->wlr_output = NULL; | 1267 | free(output); |
1234 | free(output); | ||
1235 | } | ||
1236 | } | 1268 | } |
1237 | 1269 | ||
1238 | static void handle_mode(struct wl_listener *listener, void *data) { | 1270 | static void handle_mode(struct wl_listener *listener, void *data) { |
@@ -1270,10 +1302,13 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
1270 | output->wlr_output = wlr_output; | 1302 | output->wlr_output = wlr_output; |
1271 | wlr_output->data = output; | 1303 | wlr_output->data = output; |
1272 | output->server = server; | 1304 | output->server = server; |
1273 | wl_list_insert(&root_container.sway_root->outputs, &output->link); | ||
1274 | |||
1275 | output->damage = wlr_output_damage_create(wlr_output); | 1305 | output->damage = wlr_output_damage_create(wlr_output); |
1276 | 1306 | ||
1307 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); | ||
1308 | output->destroy.notify = handle_destroy; | ||
1309 | |||
1310 | wl_list_insert(&root_container.sway_root->outputs, &output->link); | ||
1311 | |||
1277 | if (!wl_list_empty(&wlr_output->modes)) { | 1312 | if (!wl_list_empty(&wlr_output->modes)) { |
1278 | struct wlr_output_mode *mode = | 1313 | struct wlr_output_mode *mode = |
1279 | wl_container_of(wlr_output->modes.prev, mode, link); | 1314 | wl_container_of(wlr_output->modes.prev, mode, link); |
@@ -1286,6 +1321,10 @@ void handle_new_output(struct wl_listener *listener, void *data) { | |||
1286 | void output_enable(struct sway_output *output) { | 1321 | void output_enable(struct sway_output *output) { |
1287 | struct wlr_output *wlr_output = output->wlr_output; | 1322 | struct wlr_output *wlr_output = output->wlr_output; |
1288 | 1323 | ||
1324 | if (!sway_assert(output->swayc == NULL, "output is already enabled")) { | ||
1325 | return; | ||
1326 | } | ||
1327 | |||
1289 | output->swayc = output_create(output); | 1328 | output->swayc = output_create(output); |
1290 | if (!output->swayc) { | 1329 | if (!output->swayc) { |
1291 | // Output is disabled | 1330 | // Output is disabled |
@@ -1299,8 +1338,6 @@ void output_enable(struct sway_output *output) { | |||
1299 | 1338 | ||
1300 | input_manager_configure_xcursor(input_manager); | 1339 | input_manager_configure_xcursor(input_manager); |
1301 | 1340 | ||
1302 | wl_signal_add(&wlr_output->events.destroy, &output->destroy); | ||
1303 | output->destroy.notify = handle_destroy; | ||
1304 | wl_signal_add(&wlr_output->events.mode, &output->mode); | 1341 | wl_signal_add(&wlr_output->events.mode, &output->mode); |
1305 | output->mode.notify = handle_mode; | 1342 | output->mode.notify = handle_mode; |
1306 | wl_signal_add(&wlr_output->events.transform, &output->transform); | 1343 | wl_signal_add(&wlr_output->events.transform, &output->transform); |