diff options
Diffstat (limited to 'sway/tree/workspace.c')
-rw-r--r-- | sway/tree/workspace.c | 42 |
1 files changed, 27 insertions, 15 deletions
diff --git a/sway/tree/workspace.c b/sway/tree/workspace.c index 8dd7789d..e3ff1513 100644 --- a/sway/tree/workspace.c +++ b/sway/tree/workspace.c | |||
@@ -844,24 +844,36 @@ struct sway_container *workspace_insert_tiling(struct sway_workspace *workspace, | |||
844 | return con; | 844 | return con; |
845 | } | 845 | } |
846 | 846 | ||
847 | bool workspace_has_single_visible_container(struct sway_workspace *ws) { | ||
848 | struct sway_seat *seat = input_manager_get_default_seat(); | ||
849 | struct sway_container *focus = | ||
850 | seat_get_focus_inactive_tiling(seat, ws); | ||
851 | if (focus && !focus->view) { | ||
852 | focus = seat_get_focus_inactive_view(seat, &focus->node); | ||
853 | } | ||
854 | return (focus && focus->view && view_ancestor_is_only_visible(focus->view)); | ||
855 | } | ||
856 | |||
847 | void workspace_add_gaps(struct sway_workspace *ws) { | 857 | void workspace_add_gaps(struct sway_workspace *ws) { |
848 | if (config->smart_gaps) { | 858 | if (config->smart_gaps == SMART_GAPS_ON |
849 | struct sway_seat *seat = input_manager_get_default_seat(); | 859 | && workspace_has_single_visible_container(ws)) { |
850 | struct sway_container *focus = | 860 | ws->current_gaps.top = 0; |
851 | seat_get_focus_inactive_tiling(seat, ws); | 861 | ws->current_gaps.right = 0; |
852 | if (focus && !focus->view) { | 862 | ws->current_gaps.bottom = 0; |
853 | focus = seat_get_focus_inactive_view(seat, &focus->node); | 863 | ws->current_gaps.left = 0; |
854 | } | 864 | return; |
855 | if (focus && focus->view && view_ancestor_is_only_visible(focus->view)) { | 865 | } |
856 | ws->current_gaps.top = 0; | 866 | |
857 | ws->current_gaps.right = 0; | 867 | if (config->smart_gaps == SMART_GAPS_INVERSE_OUTER |
858 | ws->current_gaps.bottom = 0; | 868 | && !workspace_has_single_visible_container(ws)) { |
859 | ws->current_gaps.left = 0; | 869 | ws->current_gaps.top = 0; |
860 | return; | 870 | ws->current_gaps.right = 0; |
861 | } | 871 | ws->current_gaps.bottom = 0; |
872 | ws->current_gaps.left = 0; | ||
873 | } else { | ||
874 | ws->current_gaps = ws->gaps_outer; | ||
862 | } | 875 | } |
863 | 876 | ||
864 | ws->current_gaps = ws->gaps_outer; | ||
865 | // Add inner gaps and make sure we don't turn out negative | 877 | // Add inner gaps and make sure we don't turn out negative |
866 | ws->current_gaps.top = fmax(0, ws->current_gaps.top + ws->gaps_inner); | 878 | ws->current_gaps.top = fmax(0, ws->current_gaps.top + ws->gaps_inner); |
867 | ws->current_gaps.right = fmax(0, ws->current_gaps.right + ws->gaps_inner); | 879 | ws->current_gaps.right = fmax(0, ws->current_gaps.right + ws->gaps_inner); |