diff options
author | bR3iN <bR3iN@posteo.de> | 2021-10-28 15:31:23 +0200 |
---|---|---|
committer | Simon Ser <contact@emersion.fr> | 2021-10-29 13:37:58 +0200 |
commit | 9969de9e00a1ca89ded85d418a72c4ebbce91331 (patch) | |
tree | 28cf0f1d6e77e7e99a0df51c165e769a262b6920 /sway/tree/workspace.c | |
parent | fix cursor input for layer-shell surfaces (diff) | |
download | sway-9969de9e00a1ca89ded85d418a72c4ebbce91331.tar.gz sway-9969de9e00a1ca89ded85d418a72c4ebbce91331.tar.zst sway-9969de9e00a1ca89ded85d418a72c4ebbce91331.zip |
Add smart_gaps inverse_outer command
Add a subcommand for `smart_gaps` that enables outer gaps only
on workspaces with exactly one visible child.
Also add documentation for `smart_gaps toggle`.
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); |