diff options
author | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-22 08:27:42 +1000 |
---|---|---|
committer | Ryan Dwyer <ryandwyer1@gmail.com> | 2018-05-22 08:27:42 +1000 |
commit | f6c3682c05bce05f00b13b8f469b52923ecd8ddb (patch) | |
tree | 57a109a0bef2b14ecd24a39469d52c70f6933987 /sway/desktop | |
parent | Implement stacked layout (diff) | |
download | sway-f6c3682c05bce05f00b13b8f469b52923ecd8ddb.tar.gz sway-f6c3682c05bce05f00b13b8f469b52923ecd8ddb.tar.zst sway-f6c3682c05bce05f00b13b8f469b52923ecd8ddb.zip |
Use constants for titlebar dimensions
Diffstat (limited to 'sway/desktop')
-rw-r--r-- | sway/desktop/output.c | 64 |
1 files changed, 33 insertions, 31 deletions
diff --git a/sway/desktop/output.c b/sway/desktop/output.c index 3b501a63..765647fd 100644 --- a/sway/desktop/output.c +++ b/sway/desktop/output.c | |||
@@ -404,7 +404,7 @@ static void render_titlebar(struct sway_output *output, | |||
404 | box.x = x; | 404 | box.x = x; |
405 | box.y = y; | 405 | box.y = y; |
406 | box.width = width; | 406 | box.width = width; |
407 | box.height = 1; | 407 | box.height = TITLEBAR_BORDER_THICKNESS; |
408 | scale_box(&box, output_scale); | 408 | scale_box(&box, output_scale); |
409 | render_rect(output->wlr_output, output_damage, &box, color); | 409 | render_rect(output->wlr_output, output_damage, &box, color); |
410 | 410 | ||
@@ -420,27 +420,28 @@ static void render_titlebar(struct sway_output *output, | |||
420 | } | 420 | } |
421 | } | 421 | } |
422 | box.x = x + left_offset; | 422 | box.x = x + left_offset; |
423 | box.y = y + config->font_height + 7; | 423 | box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; |
424 | box.width = width - left_offset - right_offset; | 424 | box.width = width - left_offset - right_offset; |
425 | box.height = 1; | 425 | box.height = TITLEBAR_BORDER_THICKNESS; |
426 | scale_box(&box, output_scale); | 426 | scale_box(&box, output_scale); |
427 | render_rect(output->wlr_output, output_damage, &box, color); | 427 | render_rect(output->wlr_output, output_damage, &box, color); |
428 | 428 | ||
429 | if (layout == L_TABBED) { | 429 | if (layout == L_TABBED) { |
430 | // Single pixel left edge | 430 | // Single pixel left edge |
431 | box.x = x; | 431 | box.x = x; |
432 | box.y = y + 1; | 432 | box.y = y + TITLEBAR_BORDER_THICKNESS; |
433 | box.width = 1; | 433 | box.width = TITLEBAR_BORDER_THICKNESS; |
434 | box.height = config->font_height + 6; | 434 | box.height = |
435 | container_titlebar_height() - TITLEBAR_BORDER_THICKNESS * 2; | ||
435 | scale_box(&box, output_scale); | 436 | scale_box(&box, output_scale); |
436 | render_rect(output->wlr_output, output_damage, &box, color); | 437 | render_rect(output->wlr_output, output_damage, &box, color); |
437 | 438 | ||
438 | // Single pixel right edge | 439 | // Single pixel right edge |
439 | box.x = (x + width - 1) * output_scale; | 440 | box.x = (x + width - TITLEBAR_BORDER_THICKNESS) * output_scale; |
440 | render_rect(output->wlr_output, output_damage, &box, color); | 441 | render_rect(output->wlr_output, output_damage, &box, color); |
441 | } | 442 | } |
442 | 443 | ||
443 | size_t inner_width = width - 6; | 444 | size_t inner_width = width - TITLEBAR_H_PADDING * 2; |
444 | 445 | ||
445 | // Marks | 446 | // Marks |
446 | size_t marks_width = 0; | 447 | size_t marks_width = 0; |
@@ -448,8 +449,9 @@ static void render_titlebar(struct sway_output *output, | |||
448 | struct wlr_box texture_box; | 449 | struct wlr_box texture_box; |
449 | wlr_texture_get_size(marks_texture, | 450 | wlr_texture_get_size(marks_texture, |
450 | &texture_box.width, &texture_box.height); | 451 | &texture_box.width, &texture_box.height); |
451 | texture_box.x = (x + width - 3) * output_scale - texture_box.width; | 452 | texture_box.x = |
452 | texture_box.y = (y + 4) * output_scale; | 453 | (x + width - TITLEBAR_H_PADDING) * output_scale - texture_box.width; |
454 | texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; | ||
453 | 455 | ||
454 | float matrix[9]; | 456 | float matrix[9]; |
455 | wlr_matrix_project_box(matrix, &texture_box, | 457 | wlr_matrix_project_box(matrix, &texture_box, |
@@ -470,8 +472,8 @@ static void render_titlebar(struct sway_output *output, | |||
470 | struct wlr_box texture_box; | 472 | struct wlr_box texture_box; |
471 | wlr_texture_get_size(title_texture, | 473 | wlr_texture_get_size(title_texture, |
472 | &texture_box.width, &texture_box.height); | 474 | &texture_box.width, &texture_box.height); |
473 | texture_box.x = (x + 3) * output_scale; | 475 | texture_box.x = (x + TITLEBAR_H_PADDING) * output_scale; |
474 | texture_box.y = (y + 4) * output_scale; | 476 | texture_box.y = (y + TITLEBAR_V_PADDING) * output_scale; |
475 | 477 | ||
476 | float matrix[9]; | 478 | float matrix[9]; |
477 | wlr_matrix_project_box(matrix, &texture_box, | 479 | wlr_matrix_project_box(matrix, &texture_box, |
@@ -489,40 +491,40 @@ static void render_titlebar(struct sway_output *output, | |||
489 | // Padding above title | 491 | // Padding above title |
490 | memcpy(&color, colors->background, sizeof(float) * 4); | 492 | memcpy(&color, colors->background, sizeof(float) * 4); |
491 | premultiply_alpha(color, con->alpha); | 493 | premultiply_alpha(color, con->alpha); |
492 | box.x = x + (layout == L_TABBED); | 494 | box.x = x + (layout == L_TABBED) * TITLEBAR_BORDER_THICKNESS; |
493 | box.y = y + 1; | 495 | box.y = y + TITLEBAR_BORDER_THICKNESS; |
494 | box.width = width - (layout == L_TABBED) * 2; | 496 | box.width = width - (layout == L_TABBED) * TITLEBAR_BORDER_THICKNESS * 2; |
495 | box.height = 3; | 497 | box.height = TITLEBAR_V_PADDING - TITLEBAR_BORDER_THICKNESS; |
496 | scale_box(&box, output_scale); | 498 | scale_box(&box, output_scale); |
497 | render_rect(output->wlr_output, output_damage, &box, color); | 499 | render_rect(output->wlr_output, output_damage, &box, color); |
498 | 500 | ||
499 | // Padding below title | 501 | // Padding below title |
500 | box.y = (y + 4 + config->font_height) * output_scale; | 502 | box.y = (y + TITLEBAR_V_PADDING + config->font_height) * output_scale; |
501 | render_rect(output->wlr_output, output_damage, &box, color); | 503 | render_rect(output->wlr_output, output_damage, &box, color); |
502 | 504 | ||
503 | // Filler between title and marks | 505 | // Filler between title and marks |
504 | box.width = inner_width * output_scale - title_width - marks_width; | 506 | box.width = inner_width * output_scale - title_width - marks_width; |
505 | if (box.width > 0) { | 507 | if (box.width > 0) { |
506 | box.x = (x + 3) * output_scale + title_width; | 508 | box.x = (x + TITLEBAR_H_PADDING) * output_scale + title_width; |
507 | box.y = (y + 4) * output_scale; | 509 | box.y = (y + TITLEBAR_V_PADDING) * output_scale; |
508 | box.height = config->font_height * output_scale; | 510 | box.height = config->font_height * output_scale; |
509 | render_rect(output->wlr_output, output_damage, &box, color); | 511 | render_rect(output->wlr_output, output_damage, &box, color); |
510 | } | 512 | } |
511 | 513 | ||
512 | // Padding left of title | 514 | // Padding left of title |
513 | left_offset = layout == L_TABBED ? 1 : 0; | 515 | left_offset = (layout == L_TABBED) * TITLEBAR_BORDER_THICKNESS; |
514 | box.x = x + left_offset; | 516 | box.x = x + left_offset; |
515 | box.y = y + 4; | 517 | box.y = y + TITLEBAR_V_PADDING; |
516 | box.width = 3 - left_offset; | 518 | box.width = TITLEBAR_H_PADDING - left_offset; |
517 | box.height = config->font_height; | 519 | box.height = config->font_height; |
518 | scale_box(&box, output_scale); | 520 | scale_box(&box, output_scale); |
519 | render_rect(output->wlr_output, output_damage, &box, color); | 521 | render_rect(output->wlr_output, output_damage, &box, color); |
520 | 522 | ||
521 | // Padding right of marks | 523 | // Padding right of marks |
522 | right_offset = layout == L_TABBED ? 1 : 0; | 524 | right_offset = (layout == L_TABBED) * TITLEBAR_BORDER_THICKNESS; |
523 | box.x = x + width - 3; | 525 | box.x = x + width - TITLEBAR_H_PADDING; |
524 | box.y = y + 4; | 526 | box.y = y + TITLEBAR_V_PADDING; |
525 | box.width = 3 - right_offset; | 527 | box.width = TITLEBAR_H_PADDING - right_offset; |
526 | box.height = config->font_height; | 528 | box.height = config->font_height; |
527 | scale_box(&box, output_scale); | 529 | scale_box(&box, output_scale); |
528 | render_rect(output->wlr_output, output_damage, &box, color); | 530 | render_rect(output->wlr_output, output_damage, &box, color); |
@@ -530,17 +532,17 @@ static void render_titlebar(struct sway_output *output, | |||
530 | if (connects_sides) { | 532 | if (connects_sides) { |
531 | // Left pixel in line with bottom bar | 533 | // Left pixel in line with bottom bar |
532 | box.x = x; | 534 | box.x = x; |
533 | box.y = y + config->font_height + 7; | 535 | box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; |
534 | box.width = view->border_thickness * view->border_left; | 536 | box.width = view->border_thickness * view->border_left; |
535 | box.height = 1; | 537 | box.height = TITLEBAR_BORDER_THICKNESS; |
536 | scale_box(&box, output_scale); | 538 | scale_box(&box, output_scale); |
537 | render_rect(output->wlr_output, output_damage, &box, color); | 539 | render_rect(output->wlr_output, output_damage, &box, color); |
538 | 540 | ||
539 | // Right pixel in line with bottom bar | 541 | // Right pixel in line with bottom bar |
540 | box.x = x + width - view->border_thickness * view->border_right; | 542 | box.x = x + width - view->border_thickness * view->border_right; |
541 | box.y = y + config->font_height + 7; | 543 | box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; |
542 | box.width = view->border_thickness * view->border_right; | 544 | box.width = view->border_thickness * view->border_right; |
543 | box.height = 1; | 545 | box.height = TITLEBAR_BORDER_THICKNESS; |
544 | scale_box(&box, output_scale); | 546 | scale_box(&box, output_scale); |
545 | render_rect(output->wlr_output, output_damage, &box, color); | 547 | render_rect(output->wlr_output, output_damage, &box, color); |
546 | } | 548 | } |
@@ -719,7 +721,7 @@ static void render_container_stacked(struct sway_output *output, | |||
719 | marks_texture = view ? view->marks_unfocused : NULL; | 721 | marks_texture = view ? view->marks_unfocused : NULL; |
720 | } | 722 | } |
721 | 723 | ||
722 | int y = con->y + (config->font_height + 8) * i; | 724 | int y = con->y + container_titlebar_height() * i; |
723 | render_titlebar(output, damage, child, child->x, y, child->width, | 725 | render_titlebar(output, damage, child, child->x, y, child->width, |
724 | colors, title_texture, marks_texture); | 726 | colors, title_texture, marks_texture); |
725 | 727 | ||