Improvements to gaps

master
Drew DeVault 9 years ago
parent 446d593b4c
commit cf916bbf6f

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

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

@ -168,7 +168,11 @@ static bool handle_view_created(wlc_handle handle) {
} }
if (newview) { if (newview) {
set_focused_container(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; return true;
} }

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

Loading…
Cancel
Save