mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 00:11:28 +00:00
Merge pull request #2511 from RyanDwyer/refactor-arrange
Prepare arrange code for type safe arguments
This commit is contained in:
commit
83230435f7
|
@ -1,12 +1,16 @@
|
||||||
#ifndef _SWAY_ARRANGE_H
|
#ifndef _SWAY_ARRANGE_H
|
||||||
#define _SWAY_ARRANGE_H
|
#define _SWAY_ARRANGE_H
|
||||||
#include "sway/desktop/transaction.h"
|
|
||||||
|
|
||||||
struct sway_container;
|
struct sway_container;
|
||||||
|
|
||||||
/**
|
void arrange_container(struct sway_container *container);
|
||||||
* Arrange layout for all the children of the given container.
|
|
||||||
*/
|
void arrange_workspace(struct sway_container *workspace);
|
||||||
|
|
||||||
|
void arrange_output(struct sway_container *output);
|
||||||
|
|
||||||
|
void arrange_root(void);
|
||||||
|
|
||||||
void arrange_windows(struct sway_container *container);
|
void arrange_windows(struct sway_container *container);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -103,7 +103,7 @@ struct cmd_results *cmd_layout(int argc, char **argv) {
|
||||||
parent->prev_split_layout = prev;
|
parent->prev_split_layout = prev;
|
||||||
}
|
}
|
||||||
container_notify_subtree_changed(parent);
|
container_notify_subtree_changed(parent);
|
||||||
arrange_windows(parent);
|
arrange_windows(parent->parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
return cmd_results_new(CMD_SUCCESS, NULL, NULL);
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "sway/config.h"
|
#include "sway/config.h"
|
||||||
|
#include "sway/desktop/transaction.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
#include "sway/layers.h"
|
#include "sway/layers.h"
|
||||||
|
|
|
@ -619,9 +619,7 @@ static void render_container_tabbed(struct sway_output *output,
|
||||||
struct sway_container *current = pstate->focused_inactive_child;
|
struct sway_container *current = pstate->focused_inactive_child;
|
||||||
struct border_colors *current_colors = &config->border_colors.unfocused;
|
struct border_colors *current_colors = &config->border_colors.unfocused;
|
||||||
|
|
||||||
double width_gap_adjustment = 2 * pstate->current_gaps;
|
int tab_width = (pstate->swayc_width) / pstate->children->length;
|
||||||
int tab_width =
|
|
||||||
(pstate->swayc_width - width_gap_adjustment) / pstate->children->length;
|
|
||||||
|
|
||||||
// Render tabs
|
// Render tabs
|
||||||
for (int i = 0; i < pstate->children->length; ++i) {
|
for (int i = 0; i < pstate->children->length; ++i) {
|
||||||
|
@ -656,11 +654,10 @@ static void render_container_tabbed(struct sway_output *output,
|
||||||
|
|
||||||
// Make last tab use the remaining width of the parent
|
// Make last tab use the remaining width of the parent
|
||||||
if (i == pstate->children->length - 1) {
|
if (i == pstate->children->length - 1) {
|
||||||
tab_width =
|
tab_width = pstate->swayc_width - tab_width * i;
|
||||||
pstate->swayc_width - width_gap_adjustment - tab_width * i;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
render_titlebar(output, damage, child, x, cstate->swayc_y, tab_width,
|
render_titlebar(output, damage, child, x, pstate->swayc_y, tab_width,
|
||||||
colors, title_texture, marks_texture);
|
colors, title_texture, marks_texture);
|
||||||
|
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
|
@ -721,9 +718,9 @@ static void render_container_stacked(struct sway_output *output,
|
||||||
marks_texture = view ? view->marks_unfocused : NULL;
|
marks_texture = view ? view->marks_unfocused : NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int y = cstate->swayc_y + titlebar_height * i;
|
int y = pstate->swayc_y + titlebar_height * i;
|
||||||
render_titlebar(output, damage, child, cstate->swayc_x, y,
|
render_titlebar(output, damage, child, pstate->swayc_x, y,
|
||||||
cstate->swayc_width, colors, title_texture, marks_texture);
|
pstate->swayc_width, colors, title_texture, marks_texture);
|
||||||
|
|
||||||
if (child == current) {
|
if (child == current) {
|
||||||
current_colors = colors;
|
current_colors = colors;
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sway/decoration.h"
|
#include "sway/decoration.h"
|
||||||
#include "sway/desktop.h"
|
#include "sway/desktop.h"
|
||||||
|
#include "sway/desktop/transaction.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
#include "sway/server.h"
|
#include "sway/server.h"
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sway/decoration.h"
|
#include "sway/decoration.h"
|
||||||
#include "sway/desktop.h"
|
#include "sway/desktop.h"
|
||||||
|
#include "sway/desktop/transaction.h"
|
||||||
#include "sway/input/input-manager.h"
|
#include "sway/input/input-manager.h"
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
#include "sway/server.h"
|
#include "sway/server.h"
|
||||||
|
|
|
@ -13,27 +13,18 @@
|
||||||
#include "list.h"
|
#include "list.h"
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
|
|
||||||
static void apply_horiz_layout(struct sway_container *parent) {
|
static void apply_horiz_layout(list_t *children, struct wlr_box *parent) {
|
||||||
size_t num_children = parent->children->length;
|
if (!children->length) {
|
||||||
if (!num_children) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = 0;
|
|
||||||
if (parent->parent->layout == L_TABBED) {
|
|
||||||
parent_offset = container_titlebar_height();
|
|
||||||
} else if (parent->parent->layout == L_STACKED) {
|
|
||||||
parent_offset = container_titlebar_height() *
|
|
||||||
parent->parent->children->length;
|
|
||||||
}
|
|
||||||
size_t parent_height = parent->height - parent_offset;
|
|
||||||
|
|
||||||
// Calculate total width of children
|
// Calculate total width of children
|
||||||
double total_width = 0;
|
double total_width = 0;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
if (child->width <= 0) {
|
if (child->width <= 0) {
|
||||||
if (num_children > 1) {
|
if (children->length > 1) {
|
||||||
child->width = parent->width / (num_children - 1);
|
child->width = parent->width / (children->length - 1);
|
||||||
} else {
|
} else {
|
||||||
child->width = parent->width;
|
child->width = parent->width;
|
||||||
}
|
}
|
||||||
|
@ -46,63 +37,48 @@ static void apply_horiz_layout(struct sway_container *parent) {
|
||||||
// Resize windows
|
// Resize windows
|
||||||
wlr_log(WLR_DEBUG, "Arranging %p horizontally", parent);
|
wlr_log(WLR_DEBUG, "Arranging %p horizontally", parent);
|
||||||
double child_x = parent->x;
|
double child_x = parent->x;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
wlr_log(WLR_DEBUG,
|
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
|
||||||
child, child->type, child->width, scale);
|
|
||||||
child->x = child_x;
|
child->x = child_x;
|
||||||
child->y = parent->y + parent_offset;
|
child->y = parent->y;
|
||||||
child->width = floor(child->width * scale);
|
child->width = floor(child->width * scale);
|
||||||
child->height = parent_height;
|
child->height = parent->height;
|
||||||
child_x += child->width;
|
child_x += child->width;
|
||||||
|
|
||||||
// Make last child use remaining width of parent
|
// Make last child use remaining width of parent
|
||||||
if (i == num_children - 1) {
|
if (i == children->length - 1) {
|
||||||
child->width = parent->x + parent->width - child->x;
|
child->width = parent->x + parent->width - child->x;
|
||||||
}
|
}
|
||||||
container_add_gaps(child);
|
container_add_gaps(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apply_vert_layout(struct sway_container *parent) {
|
static void apply_vert_layout(list_t *children, struct wlr_box *parent) {
|
||||||
size_t num_children = parent->children->length;
|
if (!children->length) {
|
||||||
if (!num_children) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = 0;
|
|
||||||
if (parent->parent->layout == L_TABBED) {
|
|
||||||
parent_offset = container_titlebar_height();
|
|
||||||
} else if (parent->parent->layout == L_STACKED) {
|
|
||||||
parent_offset =
|
|
||||||
container_titlebar_height() * parent->parent->children->length;
|
|
||||||
}
|
|
||||||
size_t parent_height = parent->height + parent_offset;
|
|
||||||
|
|
||||||
// Calculate total height of children
|
// Calculate total height of children
|
||||||
double total_height = 0;
|
double total_height = 0;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
if (child->height <= 0) {
|
if (child->height <= 0) {
|
||||||
if (num_children > 1) {
|
if (children->length > 1) {
|
||||||
child->height = parent_height / (num_children - 1);
|
child->height = parent->height / (children->length - 1);
|
||||||
} else {
|
} else {
|
||||||
child->height = parent_height;
|
child->height = parent->height;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
container_remove_gaps(child);
|
container_remove_gaps(child);
|
||||||
total_height += child->height;
|
total_height += child->height;
|
||||||
}
|
}
|
||||||
double scale = parent_height / total_height;
|
double scale = parent->height / total_height;
|
||||||
|
|
||||||
// Resize
|
// Resize
|
||||||
wlr_log(WLR_DEBUG, "Arranging %p vertically", parent);
|
wlr_log(WLR_DEBUG, "Arranging %p vertically", parent);
|
||||||
double child_y = parent->y + parent_offset;
|
double child_y = parent->y;
|
||||||
for (size_t i = 0; i < num_children; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
wlr_log(WLR_DEBUG,
|
|
||||||
"Calculating arrangement for %p:%d (will scale %f by %f)",
|
|
||||||
child, child->type, child->height, scale);
|
|
||||||
child->x = parent->x;
|
child->x = parent->x;
|
||||||
child->y = child_y;
|
child->y = child_y;
|
||||||
child->width = parent->width;
|
child->width = parent->width;
|
||||||
|
@ -110,28 +86,21 @@ static void apply_vert_layout(struct sway_container *parent) {
|
||||||
child_y += child->height;
|
child_y += child->height;
|
||||||
|
|
||||||
// Make last child use remaining height of parent
|
// Make last child use remaining height of parent
|
||||||
if (i == num_children - 1) {
|
if (i == children->length - 1) {
|
||||||
child->height =
|
child->height = parent->y + parent->height - child->y;
|
||||||
parent->y + parent_offset + parent_height - child->y;
|
|
||||||
}
|
}
|
||||||
container_add_gaps(child);
|
container_add_gaps(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
|
static void apply_tabbed_layout(list_t *children, struct wlr_box *parent) {
|
||||||
if (!parent->children->length) {
|
if (!children->length) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
size_t parent_offset = 0;
|
size_t parent_offset = container_titlebar_height();
|
||||||
if (parent->parent->layout == L_TABBED) {
|
|
||||||
parent_offset = container_titlebar_height();
|
|
||||||
} else if (parent->parent->layout == L_STACKED) {
|
|
||||||
parent_offset =
|
|
||||||
container_titlebar_height() * parent->parent->children->length;
|
|
||||||
}
|
|
||||||
size_t parent_height = parent->height - parent_offset;
|
size_t parent_height = parent->height - parent_offset;
|
||||||
for (int i = 0; i < parent->children->length; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
container_remove_gaps(child);
|
container_remove_gaps(child);
|
||||||
child->x = parent->x;
|
child->x = parent->x;
|
||||||
child->y = parent->y + parent_offset;
|
child->y = parent->y + parent_offset;
|
||||||
|
@ -141,65 +110,83 @@ static void apply_tabbed_or_stacked_layout(struct sway_container *parent) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arrange_children_of(struct sway_container *parent);
|
static void apply_stacked_layout(list_t *children, struct wlr_box *parent) {
|
||||||
|
if (!children->length) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
size_t parent_offset = container_titlebar_height() * children->length;
|
||||||
|
size_t parent_height = parent->height - parent_offset;
|
||||||
|
for (int i = 0; i < children->length; ++i) {
|
||||||
|
struct sway_container *child = children->items[i];
|
||||||
|
container_remove_gaps(child);
|
||||||
|
child->x = parent->x;
|
||||||
|
child->y = parent->y + parent_offset;
|
||||||
|
child->width = parent->width;
|
||||||
|
child->height = parent_height;
|
||||||
|
container_add_gaps(child);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
static void arrange_floating(list_t *floating) {
|
static void arrange_floating(list_t *floating) {
|
||||||
for (int i = 0; i < floating->length; ++i) {
|
for (int i = 0; i < floating->length; ++i) {
|
||||||
struct sway_container *floater = floating->items[i];
|
struct sway_container *floater = floating->items[i];
|
||||||
if (floater->type == C_VIEW) {
|
arrange_container(floater);
|
||||||
view_autoconfigure(floater->sway_view);
|
|
||||||
} else {
|
|
||||||
arrange_children_of(floater);
|
|
||||||
}
|
|
||||||
container_set_dirty(floater);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arrange_children_of(struct sway_container *parent) {
|
static void arrange_children(list_t *children,
|
||||||
if (config->reloading) {
|
enum sway_container_layout layout, struct wlr_box *parent) {
|
||||||
return;
|
|
||||||
}
|
|
||||||
wlr_log(WLR_DEBUG, "Arranging layout for %p %s %fx%f+%f,%f", parent,
|
|
||||||
parent->name, parent->width, parent->height, parent->x, parent->y);
|
|
||||||
|
|
||||||
// Calculate x, y, width and height of children
|
// Calculate x, y, width and height of children
|
||||||
switch (parent->layout) {
|
switch (layout) {
|
||||||
case L_HORIZ:
|
case L_HORIZ:
|
||||||
apply_horiz_layout(parent);
|
apply_horiz_layout(children, parent);
|
||||||
break;
|
break;
|
||||||
case L_VERT:
|
case L_VERT:
|
||||||
apply_vert_layout(parent);
|
apply_vert_layout(children, parent);
|
||||||
break;
|
break;
|
||||||
case L_TABBED:
|
case L_TABBED:
|
||||||
|
apply_tabbed_layout(children, parent);
|
||||||
|
break;
|
||||||
case L_STACKED:
|
case L_STACKED:
|
||||||
apply_tabbed_or_stacked_layout(parent);
|
apply_stacked_layout(children, parent);
|
||||||
break;
|
break;
|
||||||
case L_NONE:
|
case L_NONE:
|
||||||
apply_horiz_layout(parent);
|
apply_horiz_layout(children, parent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Recurse into child containers
|
// Recurse into child containers
|
||||||
for (int i = 0; i < parent->children->length; ++i) {
|
for (int i = 0; i < children->length; ++i) {
|
||||||
struct sway_container *child = parent->children->items[i];
|
struct sway_container *child = children->items[i];
|
||||||
if (parent->has_gaps && !child->has_gaps) {
|
arrange_container(child);
|
||||||
child->has_gaps = true;
|
|
||||||
child->gaps_inner = parent->gaps_inner;
|
|
||||||
child->gaps_outer = parent->gaps_outer;
|
|
||||||
}
|
|
||||||
if (child->type == C_VIEW) {
|
|
||||||
view_autoconfigure(child->sway_view);
|
|
||||||
} else {
|
|
||||||
arrange_children_of(child);
|
|
||||||
}
|
|
||||||
container_set_dirty(child);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arrange_workspace(struct sway_container *workspace) {
|
void arrange_container(struct sway_container *container) {
|
||||||
if (config->reloading) {
|
if (config->reloading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (container->type == C_VIEW) {
|
||||||
|
view_autoconfigure(container->sway_view);
|
||||||
|
container_set_dirty(container);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!sway_assert(container->type == C_CONTAINER, "Expected a container")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
struct wlr_box box;
|
||||||
|
container_get_box(container, &box);
|
||||||
|
arrange_children(container->children, container->layout, &box);
|
||||||
|
container_set_dirty(container);
|
||||||
|
}
|
||||||
|
|
||||||
|
void arrange_workspace(struct sway_container *workspace) {
|
||||||
|
if (config->reloading) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!sway_assert(workspace->type == C_WORKSPACE, "Expected a workspace")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
struct sway_container *output = workspace->parent;
|
struct sway_container *output = workspace->parent;
|
||||||
struct wlr_box *area = &output->sway_output->usable_area;
|
struct wlr_box *area = &output->sway_output->usable_area;
|
||||||
wlr_log(WLR_DEBUG, "Usable area for ws: %dx%d@%d,%d",
|
wlr_log(WLR_DEBUG, "Usable area for ws: %dx%d@%d,%d",
|
||||||
|
@ -241,22 +228,22 @@ static void arrange_workspace(struct sway_container *workspace) {
|
||||||
fs->y = workspace->parent->y;
|
fs->y = workspace->parent->y;
|
||||||
fs->width = workspace->parent->width;
|
fs->width = workspace->parent->width;
|
||||||
fs->height = workspace->parent->height;
|
fs->height = workspace->parent->height;
|
||||||
if (fs->type == C_VIEW) {
|
arrange_container(fs);
|
||||||
view_autoconfigure(fs->sway_view);
|
|
||||||
} else {
|
|
||||||
arrange_children_of(fs);
|
|
||||||
}
|
|
||||||
container_set_dirty(fs);
|
|
||||||
} else {
|
} else {
|
||||||
|
struct wlr_box box;
|
||||||
|
container_get_box(workspace, &box);
|
||||||
|
arrange_children(workspace->children, workspace->layout, &box);
|
||||||
arrange_floating(workspace->sway_workspace->floating);
|
arrange_floating(workspace->sway_workspace->floating);
|
||||||
arrange_children_of(workspace);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arrange_output(struct sway_container *output) {
|
void arrange_output(struct sway_container *output) {
|
||||||
if (config->reloading) {
|
if (config->reloading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (!sway_assert(output->type == C_OUTPUT, "Expected an output")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const struct wlr_box *output_box = wlr_output_layout_get_box(
|
const struct wlr_box *output_box = wlr_output_layout_get_box(
|
||||||
root_container.sway_root->output_layout,
|
root_container.sway_root->output_layout,
|
||||||
output->sway_output->wlr_output);
|
output->sway_output->wlr_output);
|
||||||
|
@ -273,7 +260,7 @@ static void arrange_output(struct sway_container *output) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void arrange_root() {
|
void arrange_root(void) {
|
||||||
if (config->reloading) {
|
if (config->reloading) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -304,12 +291,8 @@ void arrange_windows(struct sway_container *container) {
|
||||||
arrange_workspace(container);
|
arrange_workspace(container);
|
||||||
break;
|
break;
|
||||||
case C_CONTAINER:
|
case C_CONTAINER:
|
||||||
arrange_children_of(container);
|
|
||||||
container_set_dirty(container);
|
|
||||||
break;
|
|
||||||
case C_VIEW:
|
case C_VIEW:
|
||||||
view_autoconfigure(container->sway_view);
|
arrange_container(container);
|
||||||
container_set_dirty(container);
|
|
||||||
break;
|
break;
|
||||||
case C_TYPES:
|
case C_TYPES:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -1159,11 +1159,23 @@ void container_add_gaps(struct sway_container *c) {
|
||||||
"Expected a container or view")) {
|
"Expected a container or view")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (c->current_gaps > 0 || c->type != C_VIEW) {
|
if (c->current_gaps > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Linear containers don't have gaps because it'd create double gaps
|
||||||
|
if (c->type == C_CONTAINER &&
|
||||||
|
c->layout != L_TABBED && c->layout != L_STACKED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Children of tabbed/stacked containers re-use the gaps of the container
|
||||||
|
enum sway_container_layout layout = c->parent->layout;
|
||||||
|
if (layout == L_TABBED || layout == L_STACKED) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
c->current_gaps = c->has_gaps ? c->gaps_inner : config->gaps_inner;
|
struct sway_container *ws = container_parent(c, C_WORKSPACE);
|
||||||
|
|
||||||
|
c->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
|
||||||
c->x += c->current_gaps;
|
c->x += c->current_gaps;
|
||||||
c->y += c->current_gaps;
|
c->y += c->current_gaps;
|
||||||
c->width -= 2 * c->current_gaps;
|
c->width -= 2 * c->current_gaps;
|
||||||
|
@ -1353,20 +1365,16 @@ struct sway_container *container_split(struct sway_container *child,
|
||||||
|
|
||||||
wlr_log(WLR_DEBUG, "creating container %p around %p", cont, child);
|
wlr_log(WLR_DEBUG, "creating container %p around %p", cont, child);
|
||||||
|
|
||||||
child->type == C_WORKSPACE ? workspace_remove_gaps(child)
|
|
||||||
: container_remove_gaps(child);
|
|
||||||
|
|
||||||
cont->prev_split_layout = L_NONE;
|
cont->prev_split_layout = L_NONE;
|
||||||
cont->width = child->width;
|
cont->width = child->width;
|
||||||
cont->height = child->height;
|
cont->height = child->height;
|
||||||
cont->x = child->x;
|
cont->x = child->x;
|
||||||
cont->y = child->y;
|
cont->y = child->y;
|
||||||
|
cont->current_gaps = child->current_gaps;
|
||||||
|
|
||||||
struct sway_seat *seat = input_manager_get_default_seat(input_manager);
|
struct sway_seat *seat = input_manager_get_default_seat(input_manager);
|
||||||
bool set_focus = (seat_get_focus(seat) == child);
|
bool set_focus = (seat_get_focus(seat) == child);
|
||||||
|
|
||||||
container_add_gaps(cont);
|
|
||||||
|
|
||||||
if (child->type == C_WORKSPACE) {
|
if (child->type == C_WORKSPACE) {
|
||||||
struct sway_container *workspace = child;
|
struct sway_container *workspace = child;
|
||||||
while (workspace->children->length) {
|
while (workspace->children->length) {
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <wlr/types/wlr_output_layout.h>
|
#include <wlr/types/wlr_output_layout.h>
|
||||||
|
#include "sway/desktop/transaction.h"
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
#include "sway/output.h"
|
#include "sway/output.h"
|
||||||
#include "sway/tree/arrange.h"
|
#include "sway/tree/arrange.h"
|
||||||
|
|
|
@ -13,6 +13,7 @@
|
||||||
#include "log.h"
|
#include "log.h"
|
||||||
#include "sway/criteria.h"
|
#include "sway/criteria.h"
|
||||||
#include "sway/commands.h"
|
#include "sway/commands.h"
|
||||||
|
#include "sway/desktop/transaction.h"
|
||||||
#include "sway/ipc-server.h"
|
#include "sway/ipc-server.h"
|
||||||
#include "sway/output.h"
|
#include "sway/output.h"
|
||||||
#include "sway/input/seat.h"
|
#include "sway/input/seat.h"
|
||||||
|
@ -224,15 +225,13 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
x = y = width = height = 0;
|
x = y = width = height = 0;
|
||||||
double y_offset = 0;
|
double y_offset = 0;
|
||||||
|
|
||||||
// In a tabbed or stacked container, the swayc's y is the top of the title
|
// In a tabbed or stacked container, the swayc's y is the bottom of the
|
||||||
// area. We have to offset the surface y by the height of the title bar, and
|
// title area. We have to disable any top border because the title bar is
|
||||||
// disable any top border because we'll always have the title bar.
|
// rendered by the parent.
|
||||||
if (con->parent->layout == L_TABBED) {
|
if (con->parent->layout == L_TABBED || con->parent->layout == L_STACKED) {
|
||||||
|
view->border_top = false;
|
||||||
|
} else {
|
||||||
y_offset = container_titlebar_height();
|
y_offset = container_titlebar_height();
|
||||||
view->border_top = false;
|
|
||||||
} else if (con->parent->layout == L_STACKED) {
|
|
||||||
y_offset = container_titlebar_height() * con->parent->children->length;
|
|
||||||
view->border_top = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enum sway_container_border border = view->border;
|
enum sway_container_border border = view->border;
|
||||||
|
@ -243,17 +242,17 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
switch (border) {
|
switch (border) {
|
||||||
case B_NONE:
|
case B_NONE:
|
||||||
x = con->x;
|
x = con->x;
|
||||||
y = con->y + y_offset;
|
y = con->y;
|
||||||
width = con->width;
|
width = con->width;
|
||||||
height = con->height - y_offset;
|
height = con->height;
|
||||||
break;
|
break;
|
||||||
case B_PIXEL:
|
case B_PIXEL:
|
||||||
x = con->x + view->border_thickness * view->border_left;
|
x = con->x + view->border_thickness * view->border_left;
|
||||||
y = con->y + view->border_thickness * view->border_top + y_offset;
|
y = con->y + view->border_thickness * view->border_top;
|
||||||
width = con->width
|
width = con->width
|
||||||
- view->border_thickness * view->border_left
|
- view->border_thickness * view->border_left
|
||||||
- view->border_thickness * view->border_right;
|
- view->border_thickness * view->border_right;
|
||||||
height = con->height - y_offset
|
height = con->height
|
||||||
- view->border_thickness * view->border_top
|
- view->border_thickness * view->border_top
|
||||||
- view->border_thickness * view->border_bottom;
|
- view->border_thickness * view->border_bottom;
|
||||||
break;
|
break;
|
||||||
|
@ -263,15 +262,9 @@ void view_autoconfigure(struct sway_view *view) {
|
||||||
width = con->width
|
width = con->width
|
||||||
- view->border_thickness * view->border_left
|
- view->border_thickness * view->border_left
|
||||||
- view->border_thickness * view->border_right;
|
- view->border_thickness * view->border_right;
|
||||||
if (y_offset) {
|
y = con->y + y_offset;
|
||||||
y = con->y + y_offset;
|
height = con->height - y_offset
|
||||||
height = con->height - y_offset
|
- view->border_thickness * view->border_bottom;
|
||||||
- view->border_thickness * view->border_bottom;
|
|
||||||
} else {
|
|
||||||
y = con->y + container_titlebar_height();
|
|
||||||
height = con->height - container_titlebar_height()
|
|
||||||
- view->border_thickness * view->border_bottom;
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -694,7 +694,15 @@ void workspace_add_gaps(struct sway_container *ws) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ws->current_gaps = ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
|
ws->current_gaps = ws->has_gaps ? ws->gaps_outer : config->gaps_outer;
|
||||||
|
|
||||||
|
if (ws->layout == L_TABBED || ws->layout == L_STACKED) {
|
||||||
|
// We have to add inner gaps for this, because children of tabbed and
|
||||||
|
// stacked containers don't apply their own gaps - they assume the
|
||||||
|
// tabbed/stacked container is using gaps.
|
||||||
|
ws->current_gaps += ws->has_gaps ? ws->gaps_inner : config->gaps_inner;
|
||||||
|
}
|
||||||
|
|
||||||
ws->x += ws->current_gaps;
|
ws->x += ws->current_gaps;
|
||||||
ws->y += ws->current_gaps;
|
ws->y += ws->current_gaps;
|
||||||
ws->width -= 2 * ws->current_gaps;
|
ws->width -= 2 * ws->current_gaps;
|
||||||
|
|
Loading…
Reference in a new issue