Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] gaps: fixes for edge cases & better alignment with i3-gaps syntax #2131

Closed
wants to merge 1 commit into from

Conversation

natesymer
Copy link
Contributor

My previous PR (#2047) had a few bugs with edge cases. This PR is designed to fix those bugs, as well as provide more compatibility with the i3-gaps syntax (specifically the longest gaps command's syntax & semantics).

@@ -268,6 +284,10 @@ void arrange_children_of(struct sway_container *parent) {
if (config->reloading) {
return;
}
if (parent->type == C_OUTPUT) {
arrange_output(parent);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The indentation is a bit weird here.

Why do we need that?

@@ -284,9 +304,27 @@ void arrange_children_of(struct sway_container *parent) {
return;
}

if (config->smart_gaps && workspace->current_gaps != (workspace->children->length <= 1 ? 0 : 1)) {
if (workspace->current_gaps == 0) {
container_damage_whole(workspace);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need that?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If smart gaps are on and a second window is added to a workspace, damage gets left in the outer borders. This clears it.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TBH I don't think this is the right fix. We should just damage before and after arranging. We only damage after right now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The problem is that adding a container (by opening a terminal for example) to a workspace with a single container already in it only arranges the new container. If smart_gaps were on in this situation, the workspace would need to apply outer gaps.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keep in mind there's going to be some significant changes once the atomic layout updates PR is completed and merged. The calls to add damage in response to layout changes will all be removed and done in a single place when the layout is applied. For that reason you might not want to try too hard to get it perfect here.

printf("Child %p, %d\n", c->children->items[i], ((struct sway_container *)c->children->items[i])->type);
}
if (!config->edge_gaps || (config->smart_gaps && c->children->length == 1)) {
printf("SKIPPING OUTER GAPS %s\n", c->name ? c->name : "UNKNOWN NAME");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you want to log something, use wlr_log (and don't use caps lock!)

} else if (strcmp(argv[amount_idx], "current") == 0) {
amount_idx++;
scope = GAPS_SCOPE_CURRENT;
} else {
return cmd_results_new(CMD_INVALID, "gaps", "gaps inner|outer all|current|current_container set|plus|minus <amount>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems like there's a typo in here

@@ -104,6 +102,8 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
} else if (strcmp(argv[amount_idx], "minus") == 0) {
amount_idx++;
op = GAPS_OP_SUBTRACT;
} else {
return cmd_results_new(CMD_INVALID, "gaps", "gaps inner|outer all|current|current_container set|plus|minus <amount>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

GAPS_SCOPE_WORKSPACE,
GAPS_SCOPE_CURRENT
GAPS_SCOPE_ALL, // GLOBAL
GAPS_SCOPE_CURRENT // CURRENT WORKSPACE
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think these comments are needed

@@ -120,7 +120,7 @@ struct cmd_results *cmd_gaps(int argc, char **argv) {
"gaps inner|outer <amount>");
}
return cmd_results_new(CMD_INVALID, "gaps",
"gaps inner|outer all|workspace|current set|plus|minus <amount>");
"gaps inner|outer all|current|current_container set|plus|minus <amount>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

if (c->parent) {
arrange_children_of(c->parent);
} else {
arrange_root();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If c doesn't have a parent, maybe we should do nothing (arranging root won't do anything interesting since c is out of the tree)

@natesymer
Copy link
Contributor Author

Let me know what you think now, @emersion @SirCmpwn

@natesymer natesymer force-pushed the gaps_improvements branch 3 times, most recently from e2d6ac9 to e094429 Compare June 13, 2018 20:57
arrange_children_of(c->parent);
} else {
switch (scope) {
case GAPS_SCOPE_ALL: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: don't intend switch labels

switch (scope) {
case GAPS_SCOPE_ALL:
    …

break;
}
default: {
return cmd_results_new(CMD_INVALID, "gaps", "gaps inner|outer all|current set|plus|minus <amount>");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This could probably use one of the #defines?


for (int i = 0; i < ws->children->length; i++) {
struct sway_container *sibling = cont->parent->children->items[i];
if (sibling == cont) continue;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Style: missing brackets

}
gaps = c->has_gaps ? c->gaps_outer : config->gaps_outer;
} else {
if (config->smart_gaps && container_parent(c, C_WORKSPACE)->children->length < 2) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does config->edge_gaps need to be checked here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edge gaps must be enabled to have outer gaps. If disabled, workspaces have no gaps because workspaces only have outer gaps.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ergo edge_gaps must be checked. It's cheap though.

@natesymer
Copy link
Contributor Author

There's currently a bug where a single C_CONTAINER container with multiple children would not get gapped under smart gaps. I've seen your comments, and I'm working on both.

@emersion emersion changed the title gaps: fixes for edge cases & better alignment with i3-gaps syntax [WIP] gaps: fixes for edge cases & better alignment with i3-gaps syntax Jun 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants