diff options
Diffstat (limited to 'sway/tree/view.c')
-rw-r--r-- | sway/tree/view.c | 72 |
1 files changed, 15 insertions, 57 deletions
diff --git a/sway/tree/view.c b/sway/tree/view.c index b77a9bb2..2870d4f5 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -18,7 +18,6 @@ | |||
18 | #include "sway/input/seat.h" | 18 | #include "sway/input/seat.h" |
19 | #include "sway/tree/arrange.h" | 19 | #include "sway/tree/arrange.h" |
20 | #include "sway/tree/container.h" | 20 | #include "sway/tree/container.h" |
21 | #include "sway/tree/layout.h" | ||
22 | #include "sway/tree/view.h" | 21 | #include "sway/tree/view.h" |
23 | #include "sway/tree/workspace.h" | 22 | #include "sway/tree/workspace.h" |
24 | #include "sway/config.h" | 23 | #include "sway/config.h" |
@@ -35,7 +34,7 @@ void view_init(struct sway_view *view, enum sway_view_type type, | |||
35 | wl_signal_init(&view->events.unmap); | 34 | wl_signal_init(&view->events.unmap); |
36 | } | 35 | } |
37 | 36 | ||
38 | void view_free(struct sway_view *view) { | 37 | void view_destroy(struct sway_view *view) { |
39 | if (!sway_assert(view->surface == NULL, "Tried to free mapped view")) { | 38 | if (!sway_assert(view->surface == NULL, "Tried to free mapped view")) { |
40 | return; | 39 | return; |
41 | } | 40 | } |
@@ -75,14 +74,14 @@ void view_free(struct sway_view *view) { | |||
75 | * destroying flag will make the view get freed when the transaction is | 74 | * destroying flag will make the view get freed when the transaction is |
76 | * finished. | 75 | * finished. |
77 | */ | 76 | */ |
78 | void view_destroy(struct sway_view *view) { | 77 | void view_begin_destroy(struct sway_view *view) { |
79 | if (!sway_assert(view->surface == NULL, "Tried to destroy a mapped view")) { | 78 | if (!sway_assert(view->surface == NULL, "Tried to destroy a mapped view")) { |
80 | return; | 79 | return; |
81 | } | 80 | } |
82 | view->destroying = true; | 81 | view->destroying = true; |
83 | 82 | ||
84 | if (!view->swayc) { | 83 | if (!view->swayc) { |
85 | view_free(view); | 84 | view_destroy(view); |
86 | } | 85 | } |
87 | } | 86 | } |
88 | 87 | ||
@@ -236,7 +235,12 @@ void view_autoconfigure(struct sway_view *view) { | |||
236 | view->border_top = false; | 235 | view->border_top = false; |
237 | } | 236 | } |
238 | 237 | ||
239 | switch (view->border) { | 238 | enum sway_container_border border = view->border; |
239 | if (view->using_csd) { | ||
240 | border = B_NONE; | ||
241 | } | ||
242 | |||
243 | switch (border) { | ||
240 | case B_NONE: | 244 | case B_NONE: |
241 | x = con->x; | 245 | x = con->x; |
242 | y = con->y + y_offset; | 246 | y = con->y + y_offset; |
@@ -364,48 +368,6 @@ static void view_handle_surface_new_subsurface(struct wl_listener *listener, | |||
364 | view_subsurface_create(view, subsurface); | 368 | view_subsurface_create(view, subsurface); |
365 | } | 369 | } |
366 | 370 | ||
367 | static void surface_send_enter_iterator(struct wlr_surface *surface, | ||
368 | int x, int y, void *data) { | ||
369 | struct wlr_output *wlr_output = data; | ||
370 | wlr_surface_send_enter(surface, wlr_output); | ||
371 | } | ||
372 | |||
373 | static void surface_send_leave_iterator(struct wlr_surface *surface, | ||
374 | int x, int y, void *data) { | ||
375 | struct wlr_output *wlr_output = data; | ||
376 | wlr_surface_send_leave(surface, wlr_output); | ||
377 | } | ||
378 | |||
379 | static void view_handle_container_reparent(struct wl_listener *listener, | ||
380 | void *data) { | ||
381 | struct sway_view *view = | ||
382 | wl_container_of(listener, view, container_reparent); | ||
383 | struct sway_container *old_parent = data; | ||
384 | |||
385 | struct sway_container *old_output = old_parent; | ||
386 | if (old_output != NULL && old_output->type != C_OUTPUT) { | ||
387 | old_output = container_parent(old_output, C_OUTPUT); | ||
388 | } | ||
389 | |||
390 | struct sway_container *new_output = view->swayc->parent; | ||
391 | if (new_output != NULL && new_output->type != C_OUTPUT) { | ||
392 | new_output = container_parent(new_output, C_OUTPUT); | ||
393 | } | ||
394 | |||
395 | if (old_output == new_output) { | ||
396 | return; | ||
397 | } | ||
398 | |||
399 | if (old_output != NULL) { | ||
400 | view_for_each_surface(view, surface_send_leave_iterator, | ||
401 | old_output->sway_output->wlr_output); | ||
402 | } | ||
403 | if (new_output != NULL) { | ||
404 | view_for_each_surface(view, surface_send_enter_iterator, | ||
405 | new_output->sway_output->wlr_output); | ||
406 | } | ||
407 | } | ||
408 | |||
409 | static bool view_has_executed_criteria(struct sway_view *view, | 371 | static bool view_has_executed_criteria(struct sway_view *view, |
410 | struct criteria *criteria) { | 372 | struct criteria *criteria) { |
411 | for (int i = 0; i < view->executed_criteria->length; ++i) { | 373 | for (int i = 0; i < view->executed_criteria->length; ++i) { |
@@ -567,9 +529,6 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
567 | &view->surface_new_subsurface); | 529 | &view->surface_new_subsurface); |
568 | view->surface_new_subsurface.notify = view_handle_surface_new_subsurface; | 530 | view->surface_new_subsurface.notify = view_handle_surface_new_subsurface; |
569 | 531 | ||
570 | wl_signal_add(&view->swayc->events.reparent, &view->container_reparent); | ||
571 | view->container_reparent.notify = view_handle_container_reparent; | ||
572 | |||
573 | if (view->impl->wants_floating && view->impl->wants_floating(view)) { | 532 | if (view->impl->wants_floating && view->impl->wants_floating(view)) { |
574 | view->border = config->floating_border; | 533 | view->border = config->floating_border; |
575 | view->border_thickness = config->floating_border_thickness; | 534 | view->border_thickness = config->floating_border_thickness; |
@@ -587,15 +546,12 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
587 | view_update_title(view, false); | 546 | view_update_title(view, false); |
588 | container_notify_subtree_changed(view->swayc->parent); | 547 | container_notify_subtree_changed(view->swayc->parent); |
589 | view_execute_criteria(view); | 548 | view_execute_criteria(view); |
590 | |||
591 | view_handle_container_reparent(&view->container_reparent, NULL); | ||
592 | } | 549 | } |
593 | 550 | ||
594 | void view_unmap(struct sway_view *view) { | 551 | void view_unmap(struct sway_view *view) { |
595 | wl_signal_emit(&view->events.unmap, view); | 552 | wl_signal_emit(&view->events.unmap, view); |
596 | 553 | ||
597 | wl_list_remove(&view->surface_new_subsurface.link); | 554 | wl_list_remove(&view->surface_new_subsurface.link); |
598 | wl_list_remove(&view->container_reparent.link); | ||
599 | 555 | ||
600 | if (view->urgent_timer) { | 556 | if (view->urgent_timer) { |
601 | wl_event_source_remove(view->urgent_timer); | 557 | wl_event_source_remove(view->urgent_timer); |
@@ -603,7 +559,9 @@ void view_unmap(struct sway_view *view) { | |||
603 | } | 559 | } |
604 | 560 | ||
605 | bool was_fullscreen = view->swayc->is_fullscreen; | 561 | bool was_fullscreen = view->swayc->is_fullscreen; |
606 | struct sway_container *surviving_ancestor = container_destroy(view->swayc); | 562 | struct sway_container *parent = view->swayc->parent; |
563 | container_begin_destroy(view->swayc); | ||
564 | struct sway_container *surviving_ancestor = container_reap_empty(parent); | ||
607 | 565 | ||
608 | // If the workspace wasn't reaped | 566 | // If the workspace wasn't reaped |
609 | if (surviving_ancestor && surviving_ancestor->type >= C_WORKSPACE) { | 567 | if (surviving_ancestor && surviving_ancestor->type >= C_WORKSPACE) { |
@@ -937,7 +895,7 @@ void view_add_mark(struct sway_view *view, char *mark) { | |||
937 | 895 | ||
938 | static void update_marks_texture(struct sway_view *view, | 896 | static void update_marks_texture(struct sway_view *view, |
939 | struct wlr_texture **texture, struct border_colors *class) { | 897 | struct wlr_texture **texture, struct border_colors *class) { |
940 | struct sway_container *output = container_parent(view->swayc, C_OUTPUT); | 898 | struct sway_output *output = container_get_effective_output(view->swayc); |
941 | if (!output) { | 899 | if (!output) { |
942 | return; | 900 | return; |
943 | } | 901 | } |
@@ -973,7 +931,7 @@ static void update_marks_texture(struct sway_view *view, | |||
973 | } | 931 | } |
974 | free(part); | 932 | free(part); |
975 | 933 | ||
976 | double scale = output->sway_output->wlr_output->scale; | 934 | double scale = output->wlr_output->scale; |
977 | int width = 0; | 935 | int width = 0; |
978 | int height = view->swayc->title_height * scale; | 936 | int height = view->swayc->title_height * scale; |
979 | 937 | ||
@@ -999,7 +957,7 @@ static void update_marks_texture(struct sway_view *view, | |||
999 | unsigned char *data = cairo_image_surface_get_data(surface); | 957 | unsigned char *data = cairo_image_surface_get_data(surface); |
1000 | int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); | 958 | int stride = cairo_format_stride_for_width(CAIRO_FORMAT_ARGB32, width); |
1001 | struct wlr_renderer *renderer = wlr_backend_get_renderer( | 959 | struct wlr_renderer *renderer = wlr_backend_get_renderer( |
1002 | output->sway_output->wlr_output->backend); | 960 | output->wlr_output->backend); |
1003 | *texture = wlr_texture_from_pixels( | 961 | *texture = wlr_texture_from_pixels( |
1004 | renderer, WL_SHM_FORMAT_ARGB8888, stride, width, height, data); | 962 | renderer, WL_SHM_FORMAT_ARGB8888, stride, width, height, data); |
1005 | cairo_surface_destroy(surface); | 963 | cairo_surface_destroy(surface); |