Improvements to gaps

This commit is contained in:
Drew DeVault 2015-08-18 18:44:50 -04:00
parent 446d593b4c
commit cf916bbf6f
4 changed files with 24 additions and 21 deletions

View File

@ -307,9 +307,9 @@ static bool cmd_gaps(struct sway_config *config, int argc, char **argv) {
errno = 0;
return false;
}
if (strcmp(argv[0], "inner") == 0) {
if (strcasecmp(argv[0], "inner") == 0) {
config->gaps_inner = amount;
} else if (strcmp(argv[0], "outer") == 0) {
} else if (strcasecmp(argv[0], "outer") == 0) {
config->gaps_outer = amount;
} else {
return false;

View File

@ -63,12 +63,11 @@ swayc_t *new_output(wlc_handle handle) {
sway_log(L_DEBUG, "Added output %lu:%s", handle, name);
swayc_t *output = new_swayc(C_OUTPUT);
output->x = (config->gaps_outer + config->gaps_inner) / 2;
output->y = (config->gaps_outer + config->gaps_inner) / 2;
output->width = size->w - (config->gaps_outer + config->gaps_inner);
output->height = size->h - (config->gaps_outer + config->gaps_inner);
output->width = size->w;
output->height = size->h;
output->handle = handle;
output->name = name ? strdup(name) : NULL;
output->gaps = config->gaps_outer;
add_child(&root_container, output);
@ -176,7 +175,6 @@ swayc_t *new_view(swayc_t *sibling, wlc_handle handle) {
view->desired_width = -1;
view->desired_height = -1;
// TODO: properly set this
view->is_floating = false;
if (sibling->type == C_WORKSPACE) {

View File

@ -168,7 +168,11 @@ static bool handle_view_created(wlc_handle handle) {
}
if (newview) {
set_focused_container(newview);
arrange_windows(newview->parent, -1, -1);
swayc_t *output = newview->parent;
while (output && output->type != C_OUTPUT) {
output = output->parent;
}
arrange_windows(output, -1, -1);
}
return true;
}

View File

@ -4,6 +4,7 @@
#include "layout.h"
#include "log.h"
#include "list.h"
#include "config.h"
#include "container.h"
#include "workspace.h"
#include "focus.h"
@ -123,11 +124,11 @@ void arrange_windows(swayc_t *container, int width, int height) {
// y -= container->y;
for (i = 0; i < container->children->length; ++i) {
swayc_t *child = container->children->items[i];
sway_log(L_DEBUG, "Arranging workspace #%d", i);
child->x = x;
child->y = y;
child->width = width;
child->height = height;
child->x = x + container->gaps;
child->y = y + container->gaps;
child->width = width - container->gaps * 2;
child->height = height - container->gaps * 2;
sway_log(L_DEBUG, "Arranging workspace #%d at %d, %d", i, child->x, child->y);
arrange_windows(child, -1, -1);
}
return;
@ -135,12 +136,12 @@ void arrange_windows(swayc_t *container, int width, int height) {
{
struct wlc_geometry geometry = {
.origin = {
.x = container->x + container->gaps / 2,
.y = container->y + container->gaps / 2
.x = container->x + container->gaps,
.y = container->y + container->gaps
},
.size = {
.w = width - container->gaps,
.h = height - container->gaps
.w = width - container->gaps * 2,
.h = height - container->gaps * 2
}
};
if (wlc_view_get_state(container->handle) & WLC_BIT_FULLSCREEN) {
@ -148,10 +149,10 @@ void arrange_windows(swayc_t *container, int width, int height) {
while (parent->type != C_OUTPUT) {
parent = parent->parent;
}
geometry.origin.x = container->gaps / 2;
geometry.origin.y = container->gaps / 2;
geometry.size.w = parent->width - container->gaps;
geometry.size.h = parent->height - container->gaps;
geometry.origin.x = 0;
geometry.origin.y = 0;
geometry.size.w = parent->width;
geometry.size.h = parent->height;
wlc_view_set_geometry(container->handle, 0, &geometry);
wlc_view_bring_to_front(container->handle);
} else {