diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-25 09:26:23 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-06-01 23:14:58 +1000 |
commit | aaba7642b3e4e9a63aea49412b10221f399b17af (patch) | |
tree | 7e7c2f6fcd80a6a48e07e07e03c5f2dc0d248240 /sway/tree/container.c | |
parent | Use L_FLOATING instead of reapable boolean (diff) | |
download | sway-aaba7642b3e4e9a63aea49412b10221f399b17af.tar.gz sway-aaba7642b3e4e9a63aea49412b10221f399b17af.tar.zst sway-aaba7642b3e4e9a63aea49412b10221f399b17af.zip |
Replace is_floating boolean with function
Diffstat (limited to 'sway/tree/container.c')
-rw-r--r-- | sway/tree/container.c | 24 |
1 files changed, 16 insertions, 8 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 | } |