Smart option added to hide_edge_borders config param (#2191) (#2191)

Use case:

* When managing multiple terminals in a workspace, the borders makes it easier
to know where the focus is, but when there is only one it's obvious where the
focus is.

* When there's only a web browser for example, the borders are actually counter-
productive since it makes clicking a side scrollbar or a tab a bit harder (if I
smash my cursor to the side or the top of the workspace, I have to move it in
the other direction by just a few pixels to be able to grab it)

Behaviour:

* No borders when there's a single window in a workspace
* Borders when there are multiple windows in a workspace

fixes #2188
This commit is contained in:
Julien Lequertier
2016-05-10 20:27:20 +02:00
committed by Michael Stapelberg
parent 47562b4143
commit 4bec3b9d24
9 changed files with 220 additions and 13 deletions

View File

@ -727,6 +727,29 @@ int con_num_children(Con *con) {
return children;
}
/**
* Returns the number of visible non-floating children of this container.
* For example, if the container contains a hsplit which has two children,
* this will return 2 instead of 1.
*/
int con_num_visible_children(Con *con) {
if (con == NULL)
return 0;
int children = 0;
Con *current = NULL;
TAILQ_FOREACH(current, &(con->nodes_head), nodes) {
/* Visible leaf nodes are a child. */
if (!con_is_hidden(current) && con_is_leaf(current))
children++;
/* All other containers need to be recursed. */
else
children += con_num_visible_children(current);
}
return children;
}
/*
* Count the number of windows (i.e., leaf containers).
*
@ -1444,6 +1467,12 @@ Con *con_descend_direction(Con *con, direction_t direction) {
*
*/
Rect con_border_style_rect(Con *con) {
if (config.hide_edge_borders == HEBM_SMART && con_num_visible_children(con_get_workspace(con)) <= 1) {
if (!con_is_floating(con)) {
return (Rect){0, 0, 0, 0};
}
}
adjacent_t borders_to_hide = ADJ_NONE;
int border_width = con->current_border_width;
DLOG("The border width for con is set to: %d\n", con->current_border_width);