diff options
Diffstat (limited to 'sway/tree')
-rw-r--r-- | sway/tree/container.c | 24 | ||||
-rw-r--r-- | sway/tree/layout.c | 4 | ||||
-rw-r--r-- | sway/tree/view.c | 12 |
3 files changed, 24 insertions, 16 deletions
diff --git a/sway/tree/container.c b/sway/tree/container.c index 17d29d92..c16f1748 100644 --- a/sway/tree/container.c +++ b/sway/tree/container.c | |||
@@ -924,7 +924,7 @@ static void configure_floating_view(struct sway_view *view) { | |||
924 | } | 924 | } |
925 | 925 | ||
926 | void container_set_floating(struct sway_container *container, bool enable) { | 926 | void container_set_floating(struct sway_container *container, bool enable) { |
927 | if (container->is_floating == enable) { | 927 | if (container_is_floating(container) == enable) { |
928 | return; | 928 | return; |
929 | } | 929 | } |
930 | 930 | ||
@@ -935,7 +935,6 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
935 | if (enable) { | 935 | if (enable) { |
936 | container_remove_child(container); | 936 | container_remove_child(container); |
937 | container_add_child(workspace->sway_workspace->floating, container); | 937 | container_add_child(workspace->sway_workspace->floating, container); |
938 | container->is_floating = true; | ||
939 | if (container->type == C_VIEW) { | 938 | if (container->type == C_VIEW) { |
940 | configure_floating_view(container->sway_view); | 939 | configure_floating_view(container->sway_view); |
941 | } | 940 | } |
@@ -950,7 +949,6 @@ void container_set_floating(struct sway_container *container, bool enable) { | |||
950 | if (container->type == C_VIEW) { | 949 | if (container->type == C_VIEW) { |
951 | view_set_maximized(container->sway_view, true); | 950 | view_set_maximized(container->sway_view, true); |
952 | } | 951 | } |
953 | container->is_floating = false; | ||
954 | container->is_sticky = false; | 952 | container->is_sticky = false; |
955 | container_reap_empty_recursive(workspace->sway_workspace->floating); | 953 | container_reap_empty_recursive(workspace->sway_workspace->floating); |
956 | } | 954 | } |
@@ -962,7 +960,8 @@ void container_set_geometry_from_view(struct sway_container *container) { | |||
962 | if (!sway_assert(container->type == C_VIEW, "Expected a view")) { | 960 | if (!sway_assert(container->type == C_VIEW, "Expected a view")) { |
963 | return; | 961 | return; |
964 | } | 962 | } |
965 | if (!sway_assert(container->is_floating, "Expected a floating view")) { | 963 | if (!sway_assert(container_is_floating(container), |
964 | "Expected a floating view")) { | ||
966 | return; | 965 | return; |
967 | } | 966 | } |
968 | struct sway_view *view = container->sway_view; | 967 | struct sway_view *view = container->sway_view; |
@@ -977,9 +976,18 @@ void container_set_geometry_from_view(struct sway_container *container) { | |||
977 | } | 976 | } |
978 | 977 | ||
979 | bool container_self_or_parent_floating(struct sway_container *container) { | 978 | bool container_self_or_parent_floating(struct sway_container *container) { |
980 | while (container->parent->type != C_WORKSPACE | 979 | struct sway_container *workspace = container_parent(container, C_WORKSPACE); |
981 | && container->parent->parent->type != C_WORKSPACE) { | 980 | if (!workspace) { |
982 | container = container->parent; | 981 | return false; |
982 | } | ||
983 | return container_has_anscestor(container, | ||
984 | workspace->sway_workspace->floating); | ||
985 | } | ||
986 | |||
987 | bool container_is_floating(struct sway_container *container) { | ||
988 | struct sway_container *workspace = container_parent(container, C_WORKSPACE); | ||
989 | if (!workspace) { | ||
990 | return false; | ||
983 | } | 991 | } |
984 | return container->is_floating; | 992 | return container->parent == workspace->sway_workspace->floating; |
985 | } | 993 | } |
diff --git a/sway/tree/layout.c b/sway/tree/layout.c index 59ad0b53..28775253 100644 --- a/sway/tree/layout.c +++ b/sway/tree/layout.c | |||
@@ -154,7 +154,7 @@ void container_move_to(struct sway_container *container, | |||
154 | || container_has_ancestor(container, destination)) { | 154 | || container_has_ancestor(container, destination)) { |
155 | return; | 155 | return; |
156 | } | 156 | } |
157 | if (container->is_floating) { | 157 | if (container_is_floating(container)) { |
158 | // TODO | 158 | // TODO |
159 | return; | 159 | return; |
160 | } | 160 | } |
@@ -718,7 +718,7 @@ struct sway_container *container_get_in_direction( | |||
718 | enum movement_direction dir) { | 718 | enum movement_direction dir) { |
719 | struct sway_container *parent = container->parent; | 719 | struct sway_container *parent = container->parent; |
720 | 720 | ||
721 | if (container->is_floating) { | 721 | if (container_is_floating(container)) { |
722 | return NULL; | 722 | return NULL; |
723 | } | 723 | } |
724 | 724 | ||
diff --git a/sway/tree/view.c b/sway/tree/view.c index 651a2be6..8548d9b8 100644 --- a/sway/tree/view.c +++ b/sway/tree/view.c | |||
@@ -458,7 +458,7 @@ void view_map(struct sway_view *view, struct wlr_surface *wlr_surface) { | |||
458 | } | 458 | } |
459 | // If we're about to launch the view into the floating container, then | 459 | // If we're about to launch the view into the floating container, then |
460 | // launch it as a tiled view in the root of the workspace instead. | 460 | // launch it as a tiled view in the root of the workspace instead. |
461 | if (focus->is_floating) { | 461 | if (container_is_floating(focus)) { |
462 | focus = focus->parent->parent; | 462 | focus = focus->parent->parent; |
463 | } | 463 | } |
464 | free(criterias); | 464 | free(criterias); |
@@ -531,7 +531,7 @@ void view_unmap(struct sway_view *view) { | |||
531 | } | 531 | } |
532 | 532 | ||
533 | void view_update_position(struct sway_view *view, double lx, double ly) { | 533 | void view_update_position(struct sway_view *view, double lx, double ly) { |
534 | if (!view->swayc->is_floating) { | 534 | if (!container_is_floating(view->swayc)) { |
535 | return; | 535 | return; |
536 | } | 536 | } |
537 | container_damage_whole(view->swayc); | 537 | container_damage_whole(view->swayc); |
@@ -548,7 +548,7 @@ void view_update_size(struct sway_view *view, int width, int height) { | |||
548 | container_damage_whole(view->swayc); | 548 | container_damage_whole(view->swayc); |
549 | view->width = width; | 549 | view->width = width; |
550 | view->height = height; | 550 | view->height = height; |
551 | if (view->swayc->is_floating) { | 551 | if (container_is_floating(view->swayc)) { |
552 | container_set_geometry_from_view(view->swayc); | 552 | container_set_geometry_from_view(view->swayc); |
553 | } | 553 | } |
554 | container_damage_whole(view->swayc); | 554 | container_damage_whole(view->swayc); |
@@ -904,15 +904,15 @@ bool view_is_visible(struct sway_view *view) { | |||
904 | container_parent(view->swayc, C_WORKSPACE); | 904 | container_parent(view->swayc, C_WORKSPACE); |
905 | // Determine if view is nested inside a floating container which is sticky. | 905 | // Determine if view is nested inside a floating container which is sticky. |
906 | // A simple floating view will have this ancestry: | 906 | // A simple floating view will have this ancestry: |
907 | // C_VIEW (is_floating=true) -> floating -> workspace | 907 | // C_VIEW -> floating -> workspace |
908 | // A more complex ancestry could be: | 908 | // A more complex ancestry could be: |
909 | // C_VIEW -> C_CONTAINER (tabbed and is_floating) -> floating -> workspace | 909 | // C_VIEW -> C_CONTAINER (tabbed) -> floating -> workspace |
910 | struct sway_container *floater = view->swayc; | 910 | struct sway_container *floater = view->swayc; |
911 | while (floater->parent->type != C_WORKSPACE | 911 | while (floater->parent->type != C_WORKSPACE |
912 | && floater->parent->parent->type != C_WORKSPACE) { | 912 | && floater->parent->parent->type != C_WORKSPACE) { |
913 | floater = floater->parent; | 913 | floater = floater->parent; |
914 | } | 914 | } |
915 | bool is_sticky = floater->is_floating && floater->is_sticky; | 915 | bool is_sticky = container_is_floating(floater) && floater->is_sticky; |
916 | // Check view isn't in a tabbed or stacked container on an inactive tab | 916 | // Check view isn't in a tabbed or stacked container on an inactive tab |
917 | struct sway_seat *seat = input_manager_current_seat(input_manager); | 917 | struct sway_seat *seat = input_manager_current_seat(input_manager); |
918 | struct sway_container *container = view->swayc; | 918 | struct sway_container *container = view->swayc; |