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_HORIZONTAL, /**< hide 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 {
@ -510,7 +514,7 @@ struct sway_config {
int border_thickness;
int floating_border_thickness;
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;
// border colors

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

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

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

@ -603,8 +603,10 @@ The default colors are:
*hide_edge_borders* [--i3] none|vertical|horizontal|both|smart|smart_no_gaps
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
and stacked containers with one child.
_--i3_ option enables i3-compatible behavior to hide the title bar on
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...>
For details on input subcommands, see *sway-input*(5).
@ -621,9 +623,9 @@ The default colors are:
*smart_borders* on|no_gaps|off
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).
If smart_borders is set to _no_gaps_, borders will only be enabled if the
workspace has more than one visible child and gaps equal to zero.
has more than one visible child. If smart_borders is set to _no_gaps_,
borders will only be enabled if the workspace has more than one visible
child and gaps equal to zero.
*smart_gaps* on|off
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) {
bool smart = config->hide_edge_borders == E_SMART ||
(config->hide_edge_borders == E_SMART_NO_GAPS &&
bool smart = config->hide_edge_borders_smart == ESMART_ON ||
(config->hide_edge_borders_smart == ESMART_NO_GAPS &&
!gaps_to_edge(view));
bool hide_smart = smart && view_is_only_visible(view);

Loading…
Cancel
Save