From 9e8aa3953098adb6175c26aebd984a32a2beccb0 Mon Sep 17 00:00:00 2001 From: Brian Ashworth Date: Wed, 7 Nov 2018 22:44:11 -0500 Subject: Implement per side and per direction outer gaps This introduces the following command extensions from `i3-gaps`: * `gaps horizontal|vertical|top|right|bottom|left ` * `gaps horizontal|vertical|top|right|bottom|left all|current set|plus|minus ` * `workspace gaps horizontal|vertical|top|right|bottom|left ` `inner` and `outer` are also still available as options for all three of the above commands. `outer` now acts as a shorthand to set/alter all sides. Additionally, this fixes two bugs with the prevention of invalid gap configurations for workspace configs: 1. If outer gaps were not set and inner gaps were, the outer gaps would be snapped to the negation of the inner gaps due to `INT_MIN` being less than the negation. This took precedence over the default outer gaps. 2. Similarly, if inner gaps were not set and outer gaps were, inner gaps would be set to zero, which would take precedence over the default inner gaps. Fixing both of the above items also requires checking the gaps again when creating a workspace since the default outer gaps can be smaller than the negation of the workspace specific inner gaps. --- include/sway/config.h | 14 ++++++++++++-- include/sway/tree/workspace.h | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) (limited to 'include') diff --git a/include/sway/config.h b/include/sway/config.h index 0912bc73..cd56c3dc 100644 --- a/include/sway/config.h +++ b/include/sway/config.h @@ -167,6 +167,16 @@ struct output_config { enum config_dpms dpms_state; }; +/** + * Stores size of gaps for each side + */ +struct side_gaps { + int top; + int right; + int bottom; + int left; +}; + /** * Stores configuration for a workspace, regardless of whether the workspace * exists. @@ -175,7 +185,7 @@ struct workspace_config { char *workspace; char *output; int gaps_inner; - int gaps_outer; + struct side_gaps gaps_outer; }; struct bar_config { @@ -398,7 +408,7 @@ struct sway_config { bool smart_gaps; int gaps_inner; - int gaps_outer; + struct side_gaps gaps_outer; list_t *config_chain; const char *current_config_path; diff --git a/include/sway/tree/workspace.h b/include/sway/tree/workspace.h index b5ae92f3..7abfbff1 100644 --- a/include/sway/tree/workspace.h +++ b/include/sway/tree/workspace.h @@ -32,9 +32,9 @@ struct sway_workspace { enum sway_container_layout layout; enum sway_container_layout prev_split_layout; - int current_gaps; + struct side_gaps current_gaps; int gaps_inner; - int gaps_outer; + struct side_gaps gaps_outer; struct sway_output *output; // NULL if no outputs are connected list_t *floating; // struct sway_container -- cgit v1.2.3