aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLibravatar Dark <dark@volatile.bz>2019-08-23 22:44:53 -0400
committerLibravatar Drew DeVault <sir@cmpwn.com>2019-08-27 09:37:10 +0900
commit8c75c5b46d5aad8c8f9fce431bf205931e79b1bd (patch)
tree8a131f717da77103f26b4d66a37bf0aee28d9d3f
parentcmd_move: fix move to scratchpad hidden container (diff)
downloadsway-8c75c5b46d5aad8c8f9fce431bf205931e79b1bd.tar.gz
sway-8c75c5b46d5aad8c8f9fce431bf205931e79b1bd.tar.zst
sway-8c75c5b46d5aad8c8f9fce431bf205931e79b1bd.zip
Update titlebar borders to match i3's current behavior.
-rw-r--r--sway/desktop/render.c80
1 files changed, 20 insertions, 60 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 9d7b89af..86d40d3e 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -343,8 +343,7 @@ static void render_view(struct sway_output *output, pixman_region32_t *damage,
343 * otherwise the colors will be incorrect when using opacity. 343 * otherwise the colors will be incorrect when using opacity.
344 * 344 *
345 * The height is: 1px border, 3px padding, font height, 3px padding, 1px border 345 * The height is: 1px border, 3px padding, font height, 3px padding, 1px border
346 * The left side for L_TABBED is: 1px border, 2px padding, title 346 * The left side is: 1px border, 2px padding, title
347 * The left side for other layouts is: 3px padding, title
348 */ 347 */
349static void render_titlebar(struct sway_output *output, 348static void render_titlebar(struct sway_output *output,
350 pixman_region32_t *output_damage, struct sway_container *con, 349 pixman_region32_t *output_damage, struct sway_container *con,
@@ -353,12 +352,7 @@ static void render_titlebar(struct sway_output *output,
353 struct wlr_texture *marks_texture) { 352 struct wlr_texture *marks_texture) {
354 struct wlr_box box; 353 struct wlr_box box;
355 float color[4]; 354 float color[4];
356 struct sway_container_state *state = &con->current;
357 float output_scale = output->wlr_output->scale; 355 float output_scale = output->wlr_output->scale;
358 enum sway_container_layout layout = container_current_parent_layout(con);
359 list_t *children = container_get_current_siblings(con);
360 bool is_last_child = children->length == 0 ||
361 children->items[children->length - 1] == con;
362 double output_x = output->lx; 356 double output_x = output->lx;
363 double output_y = output->ly; 357 double output_y = output->ly;
364 int titlebar_border_thickness = config->titlebar_border_thickness; 358 int titlebar_border_thickness = config->titlebar_border_thickness;
@@ -377,42 +371,28 @@ static void render_titlebar(struct sway_output *output,
377 render_rect(output, output_damage, &box, color); 371 render_rect(output, output_damage, &box, color);
378 372
379 // Single pixel bar below title 373 // Single pixel bar below title
380 size_t left_offset = 0, right_offset = 0; 374 box.x = x;
381 bool connects_sides = false;
382 if (layout == L_HORIZ || layout == L_VERT ||
383 (layout == L_STACKED && is_last_child)) {
384 if (con->view) {
385 left_offset = state->border_left * state->border_thickness;
386 right_offset = state->border_right * state->border_thickness;
387 connects_sides = true;
388 }
389 }
390 box.x = x + left_offset;
391 box.y = y + container_titlebar_height() - titlebar_border_thickness; 375 box.y = y + container_titlebar_height() - titlebar_border_thickness;
392 box.width = width - left_offset - right_offset; 376 box.width = width;
393 box.height = titlebar_border_thickness; 377 box.height = titlebar_border_thickness;
394 scale_box(&box, output_scale); 378 scale_box(&box, output_scale);
395 render_rect(output, output_damage, &box, color); 379 render_rect(output, output_damage, &box, color);
396 380
397 if (layout == L_TABBED) { 381 // Single pixel left edge
398 // Single pixel left edge 382 box.x = x;
399 box.x = x; 383 box.y = y + titlebar_border_thickness;
400 box.y = y + titlebar_border_thickness; 384 box.width = titlebar_border_thickness;
401 box.width = titlebar_border_thickness; 385 box.height = container_titlebar_height() - titlebar_border_thickness * 2;
402 box.height = 386 scale_box(&box, output_scale);
403 container_titlebar_height() - titlebar_border_thickness * 2; 387 render_rect(output, output_damage, &box, color);
404 scale_box(&box, output_scale);
405 render_rect(output, output_damage, &box, color);
406 388
407 // Single pixel right edge 389 // Single pixel right edge
408 box.x = x + width - titlebar_border_thickness; 390 box.x = x + width - titlebar_border_thickness;
409 box.y = y + titlebar_border_thickness; 391 box.y = y + titlebar_border_thickness;
410 box.width = titlebar_border_thickness; 392 box.width = titlebar_border_thickness;
411 box.height = 393 box.height = container_titlebar_height() - titlebar_border_thickness * 2;
412 container_titlebar_height() - titlebar_border_thickness * 2; 394 scale_box(&box, output_scale);
413 scale_box(&box, output_scale); 395 render_rect(output, output_damage, &box, color);
414 render_rect(output, output_damage, &box, color);
415 }
416 396
417 int inner_x = x - output_x + titlebar_h_padding; 397 int inner_x = x - output_x + titlebar_h_padding;
418 int bg_y = y + titlebar_border_thickness; 398 int bg_y = y + titlebar_border_thickness;
@@ -581,10 +561,9 @@ static void render_titlebar(struct sway_output *output,
581 } 561 }
582 562
583 // Padding on left side 563 // Padding on left side
584 left_offset = (layout == L_TABBED) * titlebar_border_thickness; 564 box.x = x + titlebar_border_thickness;
585 box.x = x + left_offset;
586 box.y = y + titlebar_border_thickness; 565 box.y = y + titlebar_border_thickness;
587 box.width = titlebar_h_padding - left_offset; 566 box.width = titlebar_h_padding - titlebar_border_thickness;
588 box.height = (titlebar_v_padding - titlebar_border_thickness) * 2 + 567 box.height = (titlebar_v_padding - titlebar_border_thickness) * 2 +
589 config->font_height; 568 config->font_height;
590 scale_box(&box, output_scale); 569 scale_box(&box, output_scale);
@@ -595,10 +574,9 @@ static void render_titlebar(struct sway_output *output,
595 render_rect(output, output_damage, &box, color); 574 render_rect(output, output_damage, &box, color);
596 575
597 // Padding on right side 576 // Padding on right side
598 right_offset = (layout == L_TABBED) * titlebar_border_thickness;
599 box.x = x + width - titlebar_h_padding; 577 box.x = x + width - titlebar_h_padding;
600 box.y = y + titlebar_border_thickness; 578 box.y = y + titlebar_border_thickness;
601 box.width = titlebar_h_padding - right_offset; 579 box.width = titlebar_h_padding - titlebar_border_thickness;
602 box.height = (titlebar_v_padding - titlebar_border_thickness) * 2 + 580 box.height = (titlebar_v_padding - titlebar_border_thickness) * 2 +
603 config->font_height; 581 config->font_height;
604 scale_box(&box, output_scale); 582 scale_box(&box, output_scale);
@@ -608,24 +586,6 @@ static void render_titlebar(struct sway_output *output,
608 box.x = right_rx; 586 box.x = right_rx;
609 } 587 }
610 render_rect(output, output_damage, &box, color); 588 render_rect(output, output_damage, &box, color);
611
612 if (connects_sides) {
613 // Left pixel in line with bottom bar
614 box.x = x;
615 box.y = y + container_titlebar_height() - titlebar_border_thickness;
616 box.width = state->border_thickness * state->border_left;
617 box.height = titlebar_border_thickness;
618 scale_box(&box, output_scale);
619 render_rect(output, output_damage, &box, color);
620
621 // Right pixel in line with bottom bar
622 box.x = x + width - state->border_thickness * state->border_right;
623 box.y = y + container_titlebar_height() - titlebar_border_thickness;
624 box.width = state->border_thickness * state->border_right;
625 box.height = titlebar_border_thickness;
626 scale_box(&box, output_scale);
627 render_rect(output, output_damage, &box, color);
628 }
629} 589}
630 590
631/** 591/**