Merge pull request #3086 from RedSoxFan/fix-dup-inner-gaps

gaps: remove duplicate inner gaps
This commit is contained in:
Drew DeVault 2018-11-08 07:06:41 -05:00 committed by GitHub
commit e53b4813fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 34 additions and 18 deletions

View File

@ -104,7 +104,12 @@ struct sway_container {
bool border_right; bool border_right;
// The gaps currently applied to the container. // The gaps currently applied to the container.
double current_gaps; struct {
int top;
int right;
int bottom;
int left;
} current_gaps;
struct sway_workspace *workspace; // NULL when hidden in the scratchpad struct sway_workspace *workspace; // NULL when hidden in the scratchpad
struct sway_container *parent; // NULL if container in root of workspace struct sway_container *parent; // NULL if container in root of workspace

View File

@ -1009,19 +1009,25 @@ void container_discover_outputs(struct sway_container *con) {
} }
void container_remove_gaps(struct sway_container *c) { void container_remove_gaps(struct sway_container *c) {
if (c->current_gaps == 0) { if (c->current_gaps.top == 0 && c->current_gaps.right == 0 &&
c->current_gaps.bottom == 0 && c->current_gaps.left == 0) {
return; return;
} }
c->width += c->current_gaps * 2; c->width += c->current_gaps.left + c->current_gaps.right;
c->height += c->current_gaps * 2; c->height += c->current_gaps.top + c->current_gaps.bottom;
c->x -= c->current_gaps; c->x -= c->current_gaps.left;
c->y -= c->current_gaps; c->y -= c->current_gaps.top;
c->current_gaps = 0;
c->current_gaps.top = 0;
c->current_gaps.right = 0;
c->current_gaps.bottom = 0;
c->current_gaps.left = 0;
} }
void container_add_gaps(struct sway_container *c) { void container_add_gaps(struct sway_container *c) {
if (c->current_gaps > 0) { if (c->current_gaps.top > 0 || c->current_gaps.right > 0 ||
c->current_gaps.bottom > 0 || c->current_gaps.left > 0) {
return; return;
} }
// Linear containers don't have gaps because it'd create double gaps // Linear containers don't have gaps because it'd create double gaps
@ -1054,11 +1060,15 @@ void container_add_gaps(struct sway_container *c) {
struct sway_workspace *ws = c->workspace; struct sway_workspace *ws = c->workspace;
c->current_gaps = ws->gaps_inner; c->current_gaps.top = c->y == ws->y ? ws->gaps_inner : 0;
c->x += c->current_gaps; c->current_gaps.right = ws->gaps_inner;
c->y += c->current_gaps; c->current_gaps.bottom = ws->gaps_inner;
c->width -= 2 * c->current_gaps; c->current_gaps.left = c->x == ws->x ? ws->gaps_inner : 0;
c->height -= 2 * c->current_gaps;
c->x += c->current_gaps.left;
c->y += c->current_gaps.top;
c->width -= c->current_gaps.left + c->current_gaps.right;
c->height -= c->current_gaps.top + c->current_gaps.bottom;
} }
enum sway_container_layout container_parent_layout(struct sway_container *con) { enum sway_container_layout container_parent_layout(struct sway_container *con) {

View File

@ -185,7 +185,8 @@ bool view_is_only_visible(struct sway_view *view) {
static bool gaps_to_edge(struct sway_view *view) { static bool gaps_to_edge(struct sway_view *view) {
struct sway_container *con = view->container; struct sway_container *con = view->container;
while (con) { while (con) {
if (con->current_gaps > 0) { if (con->current_gaps.top > 0 || con->current_gaps.right > 0 ||
con->current_gaps.bottom > 0 || con->current_gaps.left > 0) {
return true; return true;
} }
con = con->parent; con = con->parent;
@ -222,15 +223,15 @@ void view_autoconfigure(struct sway_view *view) {
if (config->hide_edge_borders == E_BOTH if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_VERTICAL || config->hide_edge_borders == E_VERTICAL
|| (smart && !other_views && no_gaps)) { || (smart && !other_views && no_gaps)) {
con->border_left = con->x - con->current_gaps != ws->x; con->border_left = con->x - con->current_gaps.left != ws->x;
int right_x = con->x + con->width + con->current_gaps; int right_x = con->x + con->width + con->current_gaps.right;
con->border_right = right_x != ws->x + ws->width; con->border_right = right_x != ws->x + ws->width;
} }
if (config->hide_edge_borders == E_BOTH if (config->hide_edge_borders == E_BOTH
|| config->hide_edge_borders == E_HORIZONTAL || config->hide_edge_borders == E_HORIZONTAL
|| (smart && !other_views && no_gaps)) { || (smart && !other_views && no_gaps)) {
con->border_top = con->y - con->current_gaps != ws->y; con->border_top = con->y - con->current_gaps.top != ws->y;
int bottom_y = con->y + con->height + con->current_gaps; int bottom_y = con->y + con->height + con->current_gaps.bottom;
con->border_bottom = bottom_y != ws->y + ws->height; con->border_bottom = bottom_y != ws->y + ws->height;
} }