aboutsummaryrefslogtreecommitdiffstats
path: root/sway/desktop/render.c
diff options
context:
space:
mode:
authorLibravatar Florent de Lamotte <florent.lamotte@gmail.com>2018-11-17 20:06:48 +0100
committerLibravatar Florent de Lamotte <florent.lamotte@gmail.com>2018-11-22 10:30:04 +0100
commit7555c7efdce66c7de7a5320879c501e901a5aab7 (patch)
treed9acff5cb9d0a5e420067602aca11f79fc1aabb7 /sway/desktop/render.c
parentMerge pull request #3158 from emersion/get-outputs-focused (diff)
downloadsway-7555c7efdce66c7de7a5320879c501e901a5aab7.tar.gz
sway-7555c7efdce66c7de7a5320879c501e901a5aab7.tar.zst
sway-7555c7efdce66c7de7a5320879c501e901a5aab7.zip
Adding commands for configuring titlebar borders and padding
Diffstat (limited to 'sway/desktop/render.c')
-rw-r--r--sway/desktop/render.c71
1 files changed, 37 insertions, 34 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index 8d4a701b..51cb8980 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -368,6 +368,9 @@ static void render_titlebar(struct sway_output *output,
368 children->items[children->length - 1] == con; 368 children->items[children->length - 1] == con;
369 double output_x = output->wlr_output->lx; 369 double output_x = output->wlr_output->lx;
370 double output_y = output->wlr_output->ly; 370 double output_y = output->wlr_output->ly;
371 int titlebar_border_thickness = config->titlebar_border_thickness;
372 int titlebar_h_padding = config->titlebar_h_padding;
373 int titlebar_v_padding = config->titlebar_v_padding;
371 374
372 // Single pixel bar above title 375 // Single pixel bar above title
373 memcpy(&color, colors->border, sizeof(float) * 4); 376 memcpy(&color, colors->border, sizeof(float) * 4);
@@ -375,7 +378,7 @@ static void render_titlebar(struct sway_output *output,
375 box.x = x; 378 box.x = x;
376 box.y = y; 379 box.y = y;
377 box.width = width; 380 box.width = width;
378 box.height = TITLEBAR_BORDER_THICKNESS; 381 box.height = titlebar_border_thickness;
379 scale_box(&box, output_scale); 382 scale_box(&box, output_scale);
380 render_rect(output->wlr_output, output_damage, &box, color); 383 render_rect(output->wlr_output, output_damage, &box, color);
381 384
@@ -391,36 +394,36 @@ static void render_titlebar(struct sway_output *output,
391 } 394 }
392 } 395 }
393 box.x = x + left_offset; 396 box.x = x + left_offset;
394 box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; 397 box.y = y + container_titlebar_height() - titlebar_border_thickness;
395 box.width = width - left_offset - right_offset; 398 box.width = width - left_offset - right_offset;
396 box.height = TITLEBAR_BORDER_THICKNESS; 399 box.height = titlebar_border_thickness;
397 scale_box(&box, output_scale); 400 scale_box(&box, output_scale);
398 render_rect(output->wlr_output, output_damage, &box, color); 401 render_rect(output->wlr_output, output_damage, &box, color);
399 402
400 if (layout == L_TABBED) { 403 if (layout == L_TABBED) {
401 // Single pixel left edge 404 // Single pixel left edge
402 box.x = x; 405 box.x = x;
403 box.y = y + TITLEBAR_BORDER_THICKNESS; 406 box.y = y + titlebar_border_thickness;
404 box.width = TITLEBAR_BORDER_THICKNESS; 407 box.width = titlebar_border_thickness;
405 box.height = 408 box.height =
406 container_titlebar_height() - TITLEBAR_BORDER_THICKNESS * 2; 409 container_titlebar_height() - titlebar_border_thickness * 2;
407 scale_box(&box, output_scale); 410 scale_box(&box, output_scale);
408 render_rect(output->wlr_output, output_damage, &box, color); 411 render_rect(output->wlr_output, output_damage, &box, color);
409 412
410 // Single pixel right edge 413 // Single pixel right edge
411 box.x = x + width - TITLEBAR_BORDER_THICKNESS; 414 box.x = x + width - titlebar_border_thickness;
412 box.y = y + TITLEBAR_BORDER_THICKNESS; 415 box.y = y + titlebar_border_thickness;
413 box.width = TITLEBAR_BORDER_THICKNESS; 416 box.width = titlebar_border_thickness;
414 box.height = 417 box.height =
415 container_titlebar_height() - TITLEBAR_BORDER_THICKNESS * 2; 418 container_titlebar_height() - titlebar_border_thickness * 2;
416 scale_box(&box, output_scale); 419 scale_box(&box, output_scale);
417 render_rect(output->wlr_output, output_damage, &box, color); 420 render_rect(output->wlr_output, output_damage, &box, color);
418 } 421 }
419 422
420 size_t inner_width = width - TITLEBAR_H_PADDING * 2; 423 size_t inner_width = width - titlebar_h_padding * 2;
421 int bg_y = y + TITLEBAR_BORDER_THICKNESS; 424 int bg_y = y + titlebar_border_thickness;
422 int ob_bg_height = scale_length( 425 int ob_bg_height = scale_length(
423 (TITLEBAR_V_PADDING - TITLEBAR_BORDER_THICKNESS) * 2 + 426 (titlebar_v_padding - titlebar_border_thickness) * 2 +
424 config->font_height, bg_y, output_scale); 427 config->font_height, bg_y, output_scale);
425 428
426 // Marks 429 // Marks
@@ -438,7 +441,7 @@ static void render_titlebar(struct sway_output *output,
438 int ob_padding_below = ceil(ob_padding_total / 2.0); 441 int ob_padding_below = ceil(ob_padding_total / 2.0);
439 442
440 // Render texture 443 // Render texture
441 texture_box.x = round((x - output_x + width - TITLEBAR_H_PADDING) 444 texture_box.x = round((x - output_x + width - titlebar_h_padding)
442 * output_scale) - texture_box.width; 445 * output_scale) - texture_box.width;
443 texture_box.y = round((bg_y - output_y) * output_scale) + 446 texture_box.y = round((bg_y - output_y) * output_scale) +
444 ob_padding_above; 447 ob_padding_above;
@@ -458,7 +461,7 @@ static void render_titlebar(struct sway_output *output,
458 memcpy(&color, colors->background, sizeof(float) * 4); 461 memcpy(&color, colors->background, sizeof(float) * 4);
459 premultiply_alpha(color, con->alpha); 462 premultiply_alpha(color, con->alpha);
460 box.x = texture_box.x + round(output_x * output_scale); 463 box.x = texture_box.x + round(output_x * output_scale);
461 box.y = round((y + TITLEBAR_BORDER_THICKNESS) * output_scale); 464 box.y = round((y + titlebar_border_thickness) * output_scale);
462 box.width = texture_box.width; 465 box.width = texture_box.width;
463 box.height = ob_padding_above; 466 box.height = ob_padding_above;
464 render_rect(output->wlr_output, output_damage, &box, color); 467 render_rect(output->wlr_output, output_damage, &box, color);
@@ -480,14 +483,14 @@ static void render_titlebar(struct sway_output *output,
480 // The title texture might be shorter than the config->font_height, 483 // The title texture might be shorter than the config->font_height,
481 // in which case we need to pad it above and below. 484 // in which case we need to pad it above and below.
482 int ob_padding_above = round((config->font_baseline - 485 int ob_padding_above = round((config->font_baseline -
483 con->title_baseline + TITLEBAR_V_PADDING - 486 con->title_baseline + titlebar_v_padding -
484 TITLEBAR_BORDER_THICKNESS) * output_scale); 487 titlebar_border_thickness) * output_scale);
485 int ob_padding_below = ob_bg_height - ob_padding_above - 488 int ob_padding_below = ob_bg_height - ob_padding_above -
486 texture_box.height; 489 texture_box.height;
487 490
488 // Render texture 491 // Render texture
489 texture_box.x = 492 texture_box.x =
490 round((x - output_x + TITLEBAR_H_PADDING) * output_scale); 493 round((x - output_x + titlebar_h_padding) * output_scale);
491 texture_box.y = 494 texture_box.y =
492 round((bg_y - output_y) * output_scale) + ob_padding_above; 495 round((bg_y - output_y) * output_scale) + ob_padding_above;
493 496
@@ -496,7 +499,7 @@ static void render_titlebar(struct sway_output *output,
496 WL_OUTPUT_TRANSFORM_NORMAL, 499 WL_OUTPUT_TRANSFORM_NORMAL,
497 0.0, output->wlr_output->transform_matrix); 500 0.0, output->wlr_output->transform_matrix);
498 501
499 int inner_x = x - output_x + TITLEBAR_H_PADDING; 502 int inner_x = x - output_x + titlebar_h_padding;
500 int ob_inner_width = scale_length(inner_width, inner_x, output_scale); 503 int ob_inner_width = scale_length(inner_width, inner_x, output_scale);
501 if (ob_inner_width - marks_ob_width < texture_box.width) { 504 if (ob_inner_width - marks_ob_width < texture_box.width) {
502 texture_box.width = ob_inner_width - marks_ob_width; 505 texture_box.width = ob_inner_width - marks_ob_width;
@@ -508,7 +511,7 @@ static void render_titlebar(struct sway_output *output,
508 memcpy(&color, colors->background, sizeof(float) * 4); 511 memcpy(&color, colors->background, sizeof(float) * 4);
509 premultiply_alpha(color, con->alpha); 512 premultiply_alpha(color, con->alpha);
510 box.x = texture_box.x + round(output_x * output_scale); 513 box.x = texture_box.x + round(output_x * output_scale);
511 box.y = round((y + TITLEBAR_BORDER_THICKNESS) * output_scale); 514 box.y = round((y + titlebar_border_thickness) * output_scale);
512 box.width = texture_box.width; 515 box.width = texture_box.width;
513 box.height = ob_padding_above; 516 box.height = ob_padding_above;
514 render_rect(output->wlr_output, output_damage, &box, color); 517 render_rect(output->wlr_output, output_damage, &box, color);
@@ -523,28 +526,28 @@ static void render_titlebar(struct sway_output *output,
523 box.width = 526 box.width =
524 round(inner_width * output_scale) - title_ob_width - marks_ob_width; 527 round(inner_width * output_scale) - title_ob_width - marks_ob_width;
525 if (box.width > 0) { 528 if (box.width > 0) {
526 box.x = round((x + TITLEBAR_H_PADDING) * output_scale) + title_ob_width; 529 box.x = round((x + titlebar_h_padding) * output_scale) + title_ob_width;
527 box.y = round(bg_y * output_scale); 530 box.y = round(bg_y * output_scale);
528 box.height = ob_bg_height; 531 box.height = ob_bg_height;
529 render_rect(output->wlr_output, output_damage, &box, color); 532 render_rect(output->wlr_output, output_damage, &box, color);
530 } 533 }
531 534
532 // Padding left of title 535 // Padding left of title
533 left_offset = (layout == L_TABBED) * TITLEBAR_BORDER_THICKNESS; 536 left_offset = (layout == L_TABBED) * titlebar_border_thickness;
534 box.x = x + left_offset; 537 box.x = x + left_offset;
535 box.y = y + TITLEBAR_BORDER_THICKNESS; 538 box.y = y + titlebar_border_thickness;
536 box.width = TITLEBAR_H_PADDING - left_offset; 539 box.width = titlebar_h_padding - left_offset;
537 box.height = (TITLEBAR_V_PADDING - TITLEBAR_BORDER_THICKNESS) * 2 + 540 box.height = (titlebar_v_padding - titlebar_border_thickness) * 2 +
538 config->font_height; 541 config->font_height;
539 scale_box(&box, output_scale); 542 scale_box(&box, output_scale);
540 render_rect(output->wlr_output, output_damage, &box, color); 543 render_rect(output->wlr_output, output_damage, &box, color);
541 544
542 // Padding right of marks 545 // Padding right of marks
543 right_offset = (layout == L_TABBED) * TITLEBAR_BORDER_THICKNESS; 546 right_offset = (layout == L_TABBED) * titlebar_border_thickness;
544 box.x = x + width - TITLEBAR_H_PADDING; 547 box.x = x + width - titlebar_h_padding;
545 box.y = y + TITLEBAR_BORDER_THICKNESS; 548 box.y = y + titlebar_border_thickness;
546 box.width = TITLEBAR_H_PADDING - right_offset; 549 box.width = titlebar_h_padding - right_offset;
547 box.height = (TITLEBAR_V_PADDING - TITLEBAR_BORDER_THICKNESS) * 2 + 550 box.height = (titlebar_v_padding - titlebar_border_thickness) * 2 +
548 config->font_height; 551 config->font_height;
549 scale_box(&box, output_scale); 552 scale_box(&box, output_scale);
550 render_rect(output->wlr_output, output_damage, &box, color); 553 render_rect(output->wlr_output, output_damage, &box, color);
@@ -552,17 +555,17 @@ static void render_titlebar(struct sway_output *output,
552 if (connects_sides) { 555 if (connects_sides) {
553 // Left pixel in line with bottom bar 556 // Left pixel in line with bottom bar
554 box.x = x; 557 box.x = x;
555 box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; 558 box.y = y + container_titlebar_height() - titlebar_border_thickness;
556 box.width = state->border_thickness * state->border_left; 559 box.width = state->border_thickness * state->border_left;
557 box.height = TITLEBAR_BORDER_THICKNESS; 560 box.height = titlebar_border_thickness;
558 scale_box(&box, output_scale); 561 scale_box(&box, output_scale);
559 render_rect(output->wlr_output, output_damage, &box, color); 562 render_rect(output->wlr_output, output_damage, &box, color);
560 563
561 // Right pixel in line with bottom bar 564 // Right pixel in line with bottom bar
562 box.x = x + width - state->border_thickness * state->border_right; 565 box.x = x + width - state->border_thickness * state->border_right;
563 box.y = y + container_titlebar_height() - TITLEBAR_BORDER_THICKNESS; 566 box.y = y + container_titlebar_height() - titlebar_border_thickness;
564 box.width = state->border_thickness * state->border_right; 567 box.width = state->border_thickness * state->border_right;
565 box.height = TITLEBAR_BORDER_THICKNESS; 568 box.height = titlebar_border_thickness;
566 scale_box(&box, output_scale); 569 scale_box(&box, output_scale);
567 render_rect(output->wlr_output, output_damage, &box, color); 570 render_rect(output->wlr_output, output_damage, &box, color);
568 } 571 }