smart_borders: separate smartness from edge types

master
Ronan Pigott 5 years ago committed by Brian Ashworth
parent 38b37247ff
commit 3975ca28c2

@ -334,8 +334,12 @@ enum edge_border_types {
E_VERTICAL, /**< hide vertical edge borders */ E_VERTICAL, /**< hide vertical edge borders */
E_HORIZONTAL, /**< hide horizontal edge borders */ E_HORIZONTAL, /**< hide horizontal edge borders */
E_BOTH, /**< hide vertical and horizontal edge borders */ E_BOTH, /**< hide vertical and horizontal edge borders */
E_SMART, /**< hide both if precisely one window is present in workspace */ };
E_SMART_NO_GAPS, /**< hide both if one window and gaps to edge is zero */
enum edge_border_smart_types {
ESMART_OFF,
ESMART_ON, /**< hide edges if precisely one window is present in workspace */
ESMART_NO_GAPS, /**< hide edges if one window and gaps to edge is zero */
}; };
enum sway_popup_during_fullscreen { enum sway_popup_during_fullscreen {
@ -510,7 +514,7 @@ struct sway_config {
int border_thickness; int border_thickness;
int floating_border_thickness; int floating_border_thickness;
enum edge_border_types hide_edge_borders; enum edge_border_types hide_edge_borders;
enum edge_border_types saved_edge_borders; enum edge_border_smart_types hide_edge_borders_smart;
bool hide_lone_tab; bool hide_lone_tab;
// border colors // border colors

@ -32,14 +32,15 @@ struct cmd_results *cmd_hide_edge_borders(int argc, char **argv) {
} else if (strcmp(argv[0], "both") == 0) { } else if (strcmp(argv[0], "both") == 0) {
config->hide_edge_borders = E_BOTH; config->hide_edge_borders = E_BOTH;
} else if (strcmp(argv[0], "smart") == 0) { } else if (strcmp(argv[0], "smart") == 0) {
config->hide_edge_borders = E_SMART; config->hide_edge_borders = E_NONE;
config->hide_edge_borders_smart = ESMART_ON;
} else if (strcmp(argv[0], "smart_no_gaps") == 0) { } else if (strcmp(argv[0], "smart_no_gaps") == 0) {
config->hide_edge_borders = E_SMART_NO_GAPS; config->hide_edge_borders = E_NONE;
config->hide_edge_borders_smart = ESMART_NO_GAPS;
} else { } else {
return cmd_results_new(CMD_INVALID, expected_syntax); return cmd_results_new(CMD_INVALID, expected_syntax);
} }
config->hide_lone_tab = hide_lone_tab; config->hide_lone_tab = hide_lone_tab;
config->saved_edge_borders = config->hide_edge_borders;
arrange_root(); arrange_root();

@ -10,14 +10,12 @@ struct cmd_results *cmd_smart_borders(int argc, char **argv) {
return error; return error;
} }
enum edge_border_types saved = config->hide_edge_borders;
if (strcmp(argv[0], "no_gaps") == 0) { if (strcmp(argv[0], "no_gaps") == 0) {
config->hide_edge_borders = E_SMART_NO_GAPS; config->hide_edge_borders_smart = ESMART_NO_GAPS;
} else { } else {
config->hide_edge_borders = parse_boolean(argv[0], true) ? config->hide_edge_borders_smart = parse_boolean(argv[0], true) ?
E_SMART : config->saved_edge_borders; ESMART_ON : ESMART_OFF;
} }
config->saved_edge_borders = saved;
arrange_root(); arrange_root();

@ -296,7 +296,7 @@ static void config_defaults(struct sway_config *config) {
config->border_thickness = 2; config->border_thickness = 2;
config->floating_border_thickness = 2; config->floating_border_thickness = 2;
config->hide_edge_borders = E_NONE; config->hide_edge_borders = E_NONE;
config->saved_edge_borders = E_NONE; config->hide_edge_borders_smart = ESMART_OFF;
config->hide_lone_tab = false; config->hide_lone_tab = false;
// border colors // border colors

@ -603,8 +603,10 @@ The default colors are:
*hide_edge_borders* [--i3] none|vertical|horizontal|both|smart|smart_no_gaps *hide_edge_borders* [--i3] none|vertical|horizontal|both|smart|smart_no_gaps
Hides window borders adjacent to the screen edges. Default is _none_. The Hides window borders adjacent to the screen edges. Default is _none_. The
_--i3_ option enables i3-compatible behavior to hide the title bar on tabbed _--i3_ option enables i3-compatible behavior to hide the title bar on
and stacked containers with one child. tabbed and stacked containers with one child. The _smart_|_smart_no_gaps_
options are equivalent to setting _smart_borders_ smart|no_gaps and
_hide_edge_borders_ none.
*input* <input_device> <input-subcommands...> *input* <input_device> <input-subcommands...>
For details on input subcommands, see *sway-input*(5). For details on input subcommands, see *sway-input*(5).
@ -621,9 +623,9 @@ The default colors are:
*smart_borders* on|no_gaps|off *smart_borders* on|no_gaps|off
If smart_borders are _on_, borders will only be enabled if the workspace If smart_borders are _on_, borders will only be enabled if the workspace
has more than one visible child (identical to _hide_edge_borders_ smart). has more than one visible child. If smart_borders is set to _no_gaps_,
If smart_borders is set to _no_gaps_, borders will only be enabled if the borders will only be enabled if the workspace has more than one visible
workspace has more than one visible child and gaps equal to zero. child and gaps equal to zero.
*smart_gaps* on|off *smart_gaps* on|off
If smart_gaps are _on_ gaps will only be enabled if a workspace has more If smart_gaps are _on_ gaps will only be enabled if a workspace has more

@ -215,8 +215,8 @@ void view_autoconfigure(struct sway_view *view) {
if (!container_is_floating(con) && ws) { if (!container_is_floating(con) && ws) {
bool smart = config->hide_edge_borders == E_SMART || bool smart = config->hide_edge_borders_smart == ESMART_ON ||
(config->hide_edge_borders == E_SMART_NO_GAPS && (config->hide_edge_borders_smart == ESMART_NO_GAPS &&
!gaps_to_edge(view)); !gaps_to_edge(view));
bool hide_smart = smart && view_is_only_visible(view); bool hide_smart = smart && view_is_only_visible(view);

Loading…
Cancel
Save