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) { } void container_set_floating(struct sway_container *container, bool enable) { - if (container->is_floating == enable) { + if (container_is_floating(container) == enable) { return; } @@ -935,7 +935,6 @@ void container_set_floating(struct sway_container *container, bool enable) { if (enable) { container_remove_child(container); container_add_child(workspace->sway_workspace->floating, container); - container->is_floating = true; if (container->type == C_VIEW) { configure_floating_view(container->sway_view); } @@ -950,7 +949,6 @@ void container_set_floating(struct sway_container *container, bool enable) { if (container->type == C_VIEW) { view_set_maximized(container->sway_view, true); } - container->is_floating = false; container->is_sticky = false; container_reap_empty_recursive(workspace->sway_workspace->floating); } @@ -962,7 +960,8 @@ void container_set_geometry_from_view(struct sway_container *container) { if (!sway_assert(container->type == C_VIEW, "Expected a view")) { return; } - if (!sway_assert(container->is_floating, "Expected a floating view")) { + if (!sway_assert(container_is_floating(container), + "Expected a floating view")) { return; } struct sway_view *view = container->sway_view; @@ -977,9 +976,18 @@ void container_set_geometry_from_view(struct sway_container *container) { } bool container_self_or_parent_floating(struct sway_container *container) { - while (container->parent->type != C_WORKSPACE - && container->parent->parent->type != C_WORKSPACE) { - container = container->parent; + struct sway_container *workspace = container_parent(container, C_WORKSPACE); + if (!workspace) { + return false; + } + return container_has_anscestor(container, + workspace->sway_workspace->floating); +} + +bool container_is_floating(struct sway_container *container) { + struct sway_container *workspace = container_parent(container, C_WORKSPACE); + if (!workspace) { + return false; } - return container->is_floating; + return container->parent == workspace->sway_workspace->floating; } 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, || container_has_ancestor(container, destination)) { return; } - if (container->is_floating) { + if (container_is_floating(container)) { // TODO return; } @@ -718,7 +718,7 @@ struct sway_container *container_get_in_direction( enum movement_direction dir) { struct sway_container *parent = container->parent; - if (container->is_floating) { + if (container_is_floating(container)) { return NULL; } 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) { } // If we're about to launch the view into the floating container, then // launch it as a tiled view in the root of the workspace instead. - if (focus->is_floating) { + if (container_is_floating(focus)) { focus = focus->parent->parent; } free(criterias); @@ -531,7 +531,7 @@ void view_unmap(struct sway_view *view) { } void view_update_position(struct sway_view *view, double lx, double ly) { - if (!view->swayc->is_floating) { + if (!container_is_floating(view->swayc)) { return; } container_damage_whole(view->swayc); @@ -548,7 +548,7 @@ void view_update_size(struct sway_view *view, int width, int height) { container_damage_whole(view->swayc); view->width = width; view->height = height; - if (view->swayc->is_floating) { + if (container_is_floating(view->swayc)) { container_set_geometry_from_view(view->swayc); } container_damage_whole(view->swayc); @@ -904,15 +904,15 @@ bool view_is_visible(struct sway_view *view) { container_parent(view->swayc, C_WORKSPACE); // Determine if view is nested inside a floating container which is sticky. // A simple floating view will have this ancestry: - // C_VIEW (is_floating=true) -> floating -> workspace + // C_VIEW -> floating -> workspace // A more complex ancestry could be: - // C_VIEW -> C_CONTAINER (tabbed and is_floating) -> floating -> workspace + // C_VIEW -> C_CONTAINER (tabbed) -> floating -> workspace struct sway_container *floater = view->swayc; while (floater->parent->type != C_WORKSPACE && floater->parent->parent->type != C_WORKSPACE) { floater = floater->parent; } - bool is_sticky = floater->is_floating && floater->is_sticky; + bool is_sticky = container_is_floating(floater) && floater->is_sticky; // Check view isn't in a tabbed or stacked container on an inactive tab struct sway_seat *seat = input_manager_current_seat(input_manager); struct sway_container *container = view->swayc; |