mirror of
https://github.com/swaywm/sway.git
synced 2024-11-23 08:21:28 +00:00
Add left/right borders to tabs
This commit is contained in:
parent
5ab4930185
commit
90607dc329
|
@ -605,13 +605,11 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
|
||||||
float output_scale = output->wlr_output->scale;
|
float output_scale = output->wlr_output->scale;
|
||||||
float color[4];
|
float color[4];
|
||||||
struct wlr_box box;
|
struct wlr_box box;
|
||||||
bool is_first = (child_index == 0);
|
|
||||||
bool is_last = (child_index == parent->children->length - 1);
|
|
||||||
|
|
||||||
int tab_width = parent->width / parent->children->length;
|
int tab_width = parent->width / parent->children->length;
|
||||||
int x = parent->x + tab_width * child_index;
|
int x = parent->x + tab_width * child_index;
|
||||||
// Make last tab use the remaining width of the parent
|
// Make last tab use the remaining width of the parent
|
||||||
if (is_last) {
|
if (child_index == parent->children->length - 1) {
|
||||||
tab_width = parent->width - tab_width * child_index;
|
tab_width = parent->width - tab_width * child_index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -625,22 +623,29 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
|
||||||
render_rect(output->wlr_output, damage, &box, color);
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
|
|
||||||
// Single pixel bar below title
|
// Single pixel bar below title
|
||||||
memcpy(&color, colors->border, sizeof(float) * 4);
|
box.y = (parent->y + config->border_thickness * 2 + config->font_height - 1)
|
||||||
box.x = x + config->border_thickness * is_first;
|
* output_scale;
|
||||||
box.y = parent->y + config->border_thickness * 2 + config->font_height - 1;
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
box.width = tab_width - config->border_thickness * is_first
|
|
||||||
- config->border_thickness * is_last;
|
// Single pixel bar on left
|
||||||
box.height = 1;
|
box.x = x;
|
||||||
|
box.y = parent->y + 1;
|
||||||
|
box.width = 1;
|
||||||
|
box.height = config->border_thickness * 2 + config->font_height - 2;
|
||||||
scale_box(&box, output_scale);
|
scale_box(&box, output_scale);
|
||||||
render_rect(output->wlr_output, damage, &box, color);
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
|
|
||||||
|
// Single pixel bar on right
|
||||||
|
box.x = (x + tab_width - 1) * output_scale;
|
||||||
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
|
|
||||||
// Title text
|
// Title text
|
||||||
size_t title_width = 0;
|
size_t title_width = 0;
|
||||||
if (title_texture) {
|
if (title_texture) {
|
||||||
struct wlr_box texture_box;
|
struct wlr_box texture_box;
|
||||||
wlr_texture_get_size(title_texture,
|
wlr_texture_get_size(title_texture,
|
||||||
&texture_box.width, &texture_box.height);
|
&texture_box.width, &texture_box.height);
|
||||||
texture_box.x = (x + config->border_thickness) * output_scale;
|
texture_box.x = (x + 1 + config->border_thickness) * output_scale;
|
||||||
texture_box.y = (parent->y + config->border_thickness) * output_scale;
|
texture_box.y = (parent->y + config->border_thickness) * output_scale;
|
||||||
|
|
||||||
float matrix[9];
|
float matrix[9];
|
||||||
|
@ -648,7 +653,7 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
|
||||||
WL_OUTPUT_TRANSFORM_NORMAL,
|
WL_OUTPUT_TRANSFORM_NORMAL,
|
||||||
0.0, output->wlr_output->transform_matrix);
|
0.0, output->wlr_output->transform_matrix);
|
||||||
|
|
||||||
int available = (tab_width - config->border_thickness * 2)
|
int available = (tab_width - config->border_thickness * 2 - 2)
|
||||||
* output_scale;
|
* output_scale;
|
||||||
if (texture_box.width > available) {
|
if (texture_box.width > available) {
|
||||||
texture_box.width = available;
|
texture_box.width = available;
|
||||||
|
@ -660,9 +665,9 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
|
||||||
|
|
||||||
// Title background - above the text
|
// Title background - above the text
|
||||||
memcpy(&color, colors->background, sizeof(float) * 4);
|
memcpy(&color, colors->background, sizeof(float) * 4);
|
||||||
box.x = x + config->border_thickness;
|
box.x = x + 1;
|
||||||
box.y = parent->y + 1;
|
box.y = parent->y + 1;
|
||||||
box.width = tab_width - config->border_thickness * 2;
|
box.width = tab_width - 2;
|
||||||
box.height = config->border_thickness - 1;
|
box.height = config->border_thickness - 1;
|
||||||
scale_box(&box, output_scale);
|
scale_box(&box, output_scale);
|
||||||
render_rect(output->wlr_output, damage, &box, color);
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
|
@ -672,28 +677,18 @@ static void render_tab(struct sway_output *output, pixman_region32_t *damage,
|
||||||
* output_scale;
|
* output_scale;
|
||||||
render_rect(output->wlr_output, damage, &box, color);
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
|
|
||||||
// Title background - left border
|
// Title background - left of text
|
||||||
box.x = x;
|
box.x = x + 1;
|
||||||
box.y = parent->y + 1;
|
box.y = parent->y + config->border_thickness;
|
||||||
box.width = config->border_thickness;
|
box.width = config->border_thickness;
|
||||||
box.height = config->border_thickness * 2
|
box.height = config->font_height;
|
||||||
+ config->font_height - 1 - !is_first;
|
|
||||||
scale_box(&box, output_scale);
|
|
||||||
render_rect(output->wlr_output, damage, &box, color);
|
|
||||||
|
|
||||||
// Title background - right border
|
|
||||||
box.x = x + tab_width - config->border_thickness;
|
|
||||||
box.y = parent->y + 1;
|
|
||||||
box.width = config->border_thickness;
|
|
||||||
box.height = config->border_thickness * 2
|
|
||||||
+ config->font_height - 1 - !is_last;
|
|
||||||
scale_box(&box, output_scale);
|
scale_box(&box, output_scale);
|
||||||
render_rect(output->wlr_output, damage, &box, color);
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
|
|
||||||
// Title background - right of text
|
// Title background - right of text
|
||||||
box.x = (x + config->border_thickness) * output_scale + title_width;
|
box.x = (x + 1 + config->border_thickness) * output_scale + title_width;
|
||||||
box.y = (parent->y + config->border_thickness) * output_scale;
|
box.y = (parent->y + config->border_thickness) * output_scale;
|
||||||
box.width = (tab_width - config->border_thickness * 2) * output_scale
|
box.width = (tab_width - config->border_thickness - 2) * output_scale
|
||||||
- title_width;
|
- title_width;
|
||||||
box.height = config->font_height * output_scale;
|
box.height = config->font_height * output_scale;
|
||||||
render_rect(output->wlr_output, damage, &box, color);
|
render_rect(output->wlr_output, damage, &box, color);
|
||||||
|
|
Loading…
Reference in a new issue