mirror of
https://github.com/swaywm/sway.git
synced 2026-05-03 06:46:26 -04:00
make tabbed layout share all border toggle/thickness settings
This commit is contained in:
parent
7bf11139cf
commit
47c1b0a2bc
2 changed files with 119 additions and 18 deletions
|
|
@ -18,26 +18,53 @@ struct cmd_results *cmd_border(int argc, char **argv) {
|
||||||
return cmd_results_new(CMD_INVALID, "border",
|
return cmd_results_new(CMD_INVALID, "border",
|
||||||
"Only views can have borders");
|
"Only views can have borders");
|
||||||
}
|
}
|
||||||
struct sway_view *view = container->sway_view;
|
|
||||||
|
|
||||||
if (strcmp(argv[0], "none") == 0) {
|
if (container->parent->layout != L_TABBED) {
|
||||||
view->border = B_NONE;
|
struct sway_view *view = container->sway_view;
|
||||||
} else if (strcmp(argv[0], "normal") == 0) {
|
if (strcmp(argv[0], "none") == 0) {
|
||||||
view->border = B_NORMAL;
|
view->border = B_NONE;
|
||||||
} else if (strcmp(argv[0], "pixel") == 0) {
|
} else if (strcmp(argv[0], "normal") == 0) {
|
||||||
view->border = B_PIXEL;
|
view->border = B_NORMAL;
|
||||||
if (argc == 2) {
|
} else if (strcmp(argv[0], "pixel") == 0) {
|
||||||
view->border_thickness = atoi(argv[1]);
|
view->border = B_PIXEL;
|
||||||
|
if (argc == 2) {
|
||||||
|
view->border_thickness = atoi(argv[1]);
|
||||||
|
}
|
||||||
|
} else if (strcmp(argv[0], "toggle") == 0) {
|
||||||
|
view->border = (view->border + 1) % 3;
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "border",
|
||||||
|
"Expected 'border <none|normal|pixel|toggle>' "
|
||||||
|
"or 'border pixel <px>'");
|
||||||
}
|
}
|
||||||
} else if (strcmp(argv[0], "toggle") == 0) {
|
|
||||||
view->border = (view->border + 1) % 3;
|
|
||||||
} else {
|
|
||||||
return cmd_results_new(CMD_INVALID, "border",
|
|
||||||
"Expected 'border <none|normal|pixel|toggle>' "
|
|
||||||
"or 'border pixel <px>'");
|
|
||||||
}
|
|
||||||
|
|
||||||
view_autoconfigure(view);
|
view_autoconfigure(view);
|
||||||
|
} else {
|
||||||
|
int depth;
|
||||||
|
int num_tabs = container->parent->children->length;
|
||||||
|
|
||||||
|
for (depth = 0; depth < num_tabs; ++depth) {
|
||||||
|
struct sway_container *child = container->parent->children->items[depth];
|
||||||
|
if (strcmp(argv[0], "none") == 0) {
|
||||||
|
child->sway_view->border = B_NONE;
|
||||||
|
} else if (strcmp(argv[0], "normal") == 0) {
|
||||||
|
child->sway_view->border = B_NORMAL;
|
||||||
|
} else if (strcmp(argv[0], "pixel") == 0) {
|
||||||
|
child->sway_view->border = B_PIXEL;
|
||||||
|
if (argc == 2) {
|
||||||
|
child->sway_view->border_thickness = atoi(argv[1]);
|
||||||
|
}
|
||||||
|
} else if (strcmp(argv[0], "toggle") == 0) {
|
||||||
|
child->sway_view->border = (child->sway_view->border + 1) % 3;
|
||||||
|
} else {
|
||||||
|
return cmd_results_new(CMD_INVALID, "border",
|
||||||
|
"Expected 'border <none|normal|pixel|toggle>' "
|
||||||
|
"or 'border pixel <px>'");
|
||||||
|
}
|
||||||
|
|
||||||
|
view_autoconfigure(child->sway_view);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
struct sway_seat *seat = input_manager_current_seat(input_manager);
|
||||||
if (seat->cursor) {
|
if (seat->cursor) {
|
||||||
|
|
|
||||||
|
|
@ -571,6 +571,60 @@ static void render_container_top_tabbed_border_normal(struct sway_output *output
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Render decorations for a tabbed view with "border pixel".
|
||||||
|
*/
|
||||||
|
static void render_container_tabbed_border_pixel(struct sway_output *output,
|
||||||
|
pixman_region32_t *output_damage, struct sway_container *con,
|
||||||
|
struct border_colors *colors, size_t depth) {
|
||||||
|
struct wlr_box box;
|
||||||
|
float color[4];
|
||||||
|
double num_tabs = con->parent->children->length;
|
||||||
|
double tab_width = con->width / num_tabs;
|
||||||
|
|
||||||
|
// Child border - left edge
|
||||||
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
|
color[3] *= con->alpha;
|
||||||
|
box.x = con->x;
|
||||||
|
box.y = con->y + (con->sway_view->y - con->y);
|
||||||
|
box.width = con->sway_view->border_thickness;
|
||||||
|
box.height = con->height;
|
||||||
|
render_rect(output->wlr_output, output_damage, &box, color);
|
||||||
|
|
||||||
|
// Child border - right edge
|
||||||
|
if (con->parent->children->length == 1 && con->parent->layout == L_HORIZ) {
|
||||||
|
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||||
|
} else {
|
||||||
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
|
}
|
||||||
|
color[3] *= con->alpha;
|
||||||
|
box.x = con->x + con->width - con->sway_view->border_thickness;
|
||||||
|
box.y = con->y + (con->sway_view->y - con->y);
|
||||||
|
box.width = con->sway_view->border_thickness;
|
||||||
|
box.height = con->height;
|
||||||
|
render_rect(output->wlr_output, output_damage, &box, color);
|
||||||
|
|
||||||
|
// Child border - top edge
|
||||||
|
box.x = con->x + depth * tab_width;
|
||||||
|
box.y = con->y;
|
||||||
|
box.width = con->width / num_tabs;
|
||||||
|
box.height = con->sway_view->border_thickness;
|
||||||
|
render_rect(output->wlr_output, output_damage, &box, color);
|
||||||
|
|
||||||
|
// Child border - bottom edge
|
||||||
|
if (con->parent->children->length == 1 && con->parent->layout == L_VERT) {
|
||||||
|
memcpy(&color, colors->indicator, sizeof(float) * 4);
|
||||||
|
} else {
|
||||||
|
memcpy(&color, colors->child_border, sizeof(float) * 4);
|
||||||
|
}
|
||||||
|
color[3] *= con->alpha;
|
||||||
|
box.x = con->x;
|
||||||
|
box.y = con->y + con->height - con->sway_view->border_thickness;
|
||||||
|
box.width = con->width;
|
||||||
|
box.height = con->sway_view->border_thickness;
|
||||||
|
render_rect(output->wlr_output, output_damage, &box, color);
|
||||||
|
}
|
||||||
|
|
||||||
static void render_container(struct sway_output *output,
|
static void render_container(struct sway_output *output,
|
||||||
pixman_region32_t *damage, struct sway_container *con, bool parent_focused);
|
pixman_region32_t *damage, struct sway_container *con, bool parent_focused);
|
||||||
|
|
||||||
|
|
@ -633,6 +687,8 @@ static void render_container_tabbed(struct sway_output *output,
|
||||||
struct border_colors *focused_colors = &config->border_colors.focused;
|
struct border_colors *focused_colors = &config->border_colors.focused;
|
||||||
for (int i = 0; i < con->children->length; ++i) {
|
for (int i = 0; i < con->children->length; ++i) {
|
||||||
struct sway_container *child = con->children->items[i];
|
struct sway_container *child = con->children->items[i];
|
||||||
|
enum sway_container_border border_type;
|
||||||
|
int border_thickness;
|
||||||
|
|
||||||
if (child->type == C_VIEW) {
|
if (child->type == C_VIEW) {
|
||||||
struct border_colors *colors;
|
struct border_colors *colors;
|
||||||
|
|
@ -650,9 +706,27 @@ static void render_container_tabbed(struct sway_output *output,
|
||||||
title_texture = child->title_unfocused;
|
title_texture = child->title_unfocused;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (child->sway_view->border != B_NONE) {
|
if (i == 0) {
|
||||||
|
border_type = child->sway_view->border;
|
||||||
|
border_thickness = child->sway_view->border_thickness;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (border_type == B_NORMAL) {
|
||||||
render_container_top_tabbed_border_normal(output, damage,
|
render_container_top_tabbed_border_normal(output, damage,
|
||||||
child, colors, title_texture, i);
|
child, colors, title_texture, i);
|
||||||
|
child->sway_view->border = border_type;
|
||||||
|
child->sway_view->border_thickness = border_thickness;
|
||||||
|
view_autoconfigure(child->sway_view);
|
||||||
|
} else if (border_type == B_PIXEL) {
|
||||||
|
render_container_tabbed_border_pixel(output, damage,
|
||||||
|
child, colors, i);
|
||||||
|
child->sway_view->border = border_type;
|
||||||
|
child->sway_view->border_thickness = border_thickness;
|
||||||
|
view_autoconfigure(child->sway_view);
|
||||||
|
} else {
|
||||||
|
child->sway_view->border = border_type;
|
||||||
|
child->sway_view->border_thickness = border_thickness;
|
||||||
|
view_autoconfigure(child->sway_view);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
render_container(output, damage, child,
|
render_container(output, damage, child,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue