diff options
author | Drew DeVault <sir@cmpwn.com> | 2016-04-25 11:34:27 -0400 |
---|---|---|
committer | Drew DeVault <sir@cmpwn.com> | 2016-04-25 11:34:27 -0400 |
commit | dba1195b4452dd7497d780b5d8c0b43f361f5aab (patch) | |
tree | 0b329d72536a75e5d960b25b4414b9d1fe4a5018 /sway/container.c | |
parent | 7efa9ab34ae1dabcc7c87d22bfba0b1312c8c662 (diff) | |
parent | 05b4965a99417b74df13e9138b14347e7dc47685 (diff) |
Merge pull request #566 from mikkeloscar/tabbed-stacking-layout
Tabbed and stacked layout
Diffstat (limited to 'sway/container.c')
-rw-r--r-- | sway/container.c | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/sway/container.c b/sway/container.c index 95a46632..b49b32ee 100644 --- a/sway/container.c +++ b/sway/container.c @@ -8,6 +8,7 @@ #include "container.h" #include "workspace.h" #include "focus.h" +#include "border.h" #include "layout.h" #include "input_state.h" #include "log.h" @@ -64,7 +65,12 @@ static void free_swayc(swayc_t *cont) { if (cont->bg_pid != 0) { terminate_swaybg(cont->bg_pid); } - free(cont->border); + if (cont->border) { + if (cont->border->buffer) { + free(cont->border->buffer); + } + free(cont->border); + } free(cont); } @@ -163,16 +169,9 @@ swayc_t *new_workspace(swayc_t *output, const char *name) { sway_log(L_DEBUG, "Added workspace %s for output %u", name, (unsigned int)output->handle); swayc_t *workspace = new_swayc(C_WORKSPACE); - // TODO: default_layout - if (config->default_layout != L_NONE) { - workspace->layout = config->default_layout; - } else if (config->default_orientation != L_NONE) { - workspace->layout = config->default_orientation; - } else if (output->width >= output->height) { - workspace->layout = L_HORIZ; - } else { - workspace->layout = L_VERT; - } + workspace->prev_layout = L_NONE; + workspace->layout = default_layout(output); + workspace->x = output->x; workspace->y = output->y; workspace->width = output->width; @@ -211,12 +210,15 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) { sway_log(L_DEBUG, "creating container %p around %p", cont, child); + cont->prev_layout = L_NONE; cont->layout = layout; cont->width = child->width; cont->height = child->height; cont->x = child->x; cont->y = child->y; cont->visible = child->visible; + cont->cached_geometry = child->cached_geometry; + cont->gaps = child->gaps; /* Container inherits all of workspaces children, layout and whatnot */ if (child->type == C_WORKSPACE) { @@ -237,7 +239,8 @@ swayc_t *new_container(swayc_t *child, enum swayc_layouts layout) { add_child(workspace, cont); // give them proper layouts cont->layout = workspace->layout; - workspace->layout = layout; + cont->prev_layout = workspace->prev_layout; + /* TODO: might break shit in move_container!!! workspace->layout = layout; */ set_focused_container_for(workspace, get_focused_view(workspace)); } else { // Or is built around container swayc_t *parent = replace_child(child, cont); @@ -678,7 +681,7 @@ bool swayc_is_child_of(swayc_t *child, swayc_t *parent) { } int swayc_gap(swayc_t *container) { - if (container->type == C_VIEW) { + if (container->type == C_VIEW || container->type == C_CONTAINER) { return container->gaps >= 0 ? container->gaps : config->gaps_inner; } else if (container->type == C_WORKSPACE) { int base = container->gaps >= 0 ? container->gaps : config->gaps_outer; @@ -722,18 +725,14 @@ void update_visibility_output(swayc_t *container, wlc_handle output) { swayc_t *parent = container->parent; container->visible = parent->visible; // special cases where visibility depends on focus - if (parent->type == C_OUTPUT - || parent->layout == L_TABBED - || parent->layout == L_STACKED) { - container->visible = parent->focused == container; + if (parent->type == C_OUTPUT || parent->layout == L_TABBED || + parent->layout == L_STACKED) { + container->visible = parent->focused == container && parent->visible; } // Set visibility and output for view if (container->type == C_VIEW) { wlc_view_set_output(container->handle, output); wlc_view_set_mask(container->handle, container->visible ? VISIBLE : 0); - if (!container->visible) { - wlc_view_send_to_back(container->handle); - } } // Update visibility for children else { @@ -814,3 +813,18 @@ static void close_view(swayc_t *container, void *data) { void close_views(swayc_t *container) { container_map(container, close_view, NULL); } + +swayc_t *swayc_tabbed_stacked_parent(swayc_t *view) { + swayc_t *parent = NULL; + if (!ASSERT_NONNULL(view)) { + return NULL; + } + do { + view = view->parent; + if (view->layout == L_TABBED || view->layout == L_STACKED) { + parent = view; + } + } while (view && view->type != C_WORKSPACE); + + return parent; +} |