summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sway/desktop/render.c90
1 files changed, 68 insertions, 22 deletions
diff --git a/sway/desktop/render.c b/sway/desktop/render.c
index d72d72bf..ecac262e 100644
--- a/sway/desktop/render.c
+++ b/sway/desktop/render.c
@@ -146,6 +146,8 @@ static void render_drag_icons(struct sway_output *output,
146 render_surface_iterator, &data); 146 render_surface_iterator, &data);
147} 147}
148 148
149// _box.x and .y are expected to be layout-local
150// _box.width and .height are expected to be output-buffer-local
149static void render_rect(struct wlr_output *wlr_output, 151static void render_rect(struct wlr_output *wlr_output,
150 pixman_region32_t *output_damage, const struct wlr_box *_box, 152 pixman_region32_t *output_damage, const struct wlr_box *_box,
151 float color[static 4]) { 153 float color[static 4]) {
@@ -404,9 +406,20 @@ static void render_titlebar(struct sway_output *output,
404 struct wlr_box texture_box; 406 struct wlr_box texture_box;
405 wlr_texture_get_size(marks_texture, 407 wlr_texture_get_size(marks_texture,
406 &texture_box.width, &texture_box.height); 408 &texture_box.width, &texture_box.height);
409 marks_ob_width = texture_box.width;
410
411 // The marks texture might be shorter than the config->font_height, in
412 // which case we need to pad it as evenly as possible above and below.
413 int ob_padding_total = config->font_height * output_scale -
414 texture_box.height;
415 int ob_padding_above = floor(ob_padding_total / 2);
416 int ob_padding_below = ceil(ob_padding_total / 2);
417
418 // Render texture
407 texture_box.x = (x - output_x + width - TITLEBAR_H_PADDING) 419 texture_box.x = (x - output_x + width - TITLEBAR_H_PADDING)
408 * output_scale - texture_box.width; 420 * output_scale - texture_box.width;
409 texture_box.y = (y - output_y + TITLEBAR_V_PADDING) * output_scale; 421 texture_box.y = (y - output_y + TITLEBAR_V_PADDING) * output_scale +
422 ob_padding_above;
410 423
411 float matrix[9]; 424 float matrix[9];
412 wlr_matrix_project_box(matrix, &texture_box, 425 wlr_matrix_project_box(matrix, &texture_box,
@@ -418,17 +431,29 @@ static void render_titlebar(struct sway_output *output,
418 } 431 }
419 render_texture(output->wlr_output, output_damage, marks_texture, 432 render_texture(output->wlr_output, output_damage, marks_texture,
420 &texture_box, matrix, con->alpha); 433 &texture_box, matrix, con->alpha);
421 marks_ob_width = texture_box.width;
422 434
423 // Gap between the marks and bottom padding, for when the marks texture 435 // Padding above
424 // height is smaller than the config's font height 436 if (ob_padding_above > 0) {
425 memcpy(&color, colors->background, sizeof(float) * 4); 437 memcpy(&color, colors->background, sizeof(float) * 4);
426 premultiply_alpha(color, con->alpha); 438 premultiply_alpha(color, con->alpha);
427 box.x = texture_box.x; 439 box.x = (x + width - TITLEBAR_H_PADDING) * output_scale -
428 box.y = texture_box.y + texture_box.height; 440 texture_box.width;
429 box.width = texture_box.width; 441 box.y = (y + TITLEBAR_V_PADDING) * output_scale;
430 box.height = config->font_height * output_scale - texture_box.height; 442 box.width = texture_box.width;
431 if (box.height > 0) { 443 box.height = ob_padding_above;
444 render_rect(output->wlr_output, output_damage, &box, color);
445 }
446
447 // Padding below
448 if (ob_padding_below > 0) {
449 memcpy(&color, colors->background, sizeof(float) * 4);
450 premultiply_alpha(color, con->alpha);
451 box.x = (x + width - TITLEBAR_H_PADDING) * output_scale -
452 texture_box.width;
453 box.y = (y + TITLEBAR_V_PADDING) * output_scale +
454 ob_padding_above + texture_box.height;
455 box.width = texture_box.width;
456 box.height = ob_padding_below;
432 render_rect(output->wlr_output, output_damage, &box, color); 457 render_rect(output->wlr_output, output_damage, &box, color);
433 } 458 }
434 } 459 }
@@ -439,8 +464,19 @@ static void render_titlebar(struct sway_output *output,
439 struct wlr_box texture_box; 464 struct wlr_box texture_box;
440 wlr_texture_get_size(title_texture, 465 wlr_texture_get_size(title_texture,
441 &texture_box.width, &texture_box.height); 466 &texture_box.width, &texture_box.height);
467 title_ob_width = texture_box.width;
468
469 // The title texture might be shorter than the config->font_height, in
470 // which case we need to pad it as evenly as possible above and below.
471 int ob_padding_total = config->font_height * output_scale -
472 texture_box.height;
473 int ob_padding_above = floor(ob_padding_total / 2);
474 int ob_padding_below = ceil(ob_padding_total / 2);
475
476 // Render texture
442 texture_box.x = (x - output_x + TITLEBAR_H_PADDING) * output_scale; 477 texture_box.x = (x - output_x + TITLEBAR_H_PADDING) * output_scale;
443 texture_box.y = (y - output_y + TITLEBAR_V_PADDING) * output_scale; 478 texture_box.y = (y - output_y + TITLEBAR_V_PADDING) * output_scale +
479 ob_padding_above;
444 480
445 float matrix[9]; 481 float matrix[9];
446 wlr_matrix_project_box(matrix, &texture_box, 482 wlr_matrix_project_box(matrix, &texture_box,
@@ -452,17 +488,27 @@ static void render_titlebar(struct sway_output *output,
452 } 488 }
453 render_texture(output->wlr_output, output_damage, title_texture, 489 render_texture(output->wlr_output, output_damage, title_texture,
454 &texture_box, matrix, con->alpha); 490 &texture_box, matrix, con->alpha);
455 title_ob_width = texture_box.width;
456 491
457 // Gap between the title and bottom padding, for when the title texture 492 // Padding above
458 // height is smaller than the config's font height 493 if (ob_padding_above > 0) {
459 memcpy(&color, colors->background, sizeof(float) * 4); 494 memcpy(&color, colors->background, sizeof(float) * 4);
460 premultiply_alpha(color, con->alpha); 495 premultiply_alpha(color, con->alpha);
461 box.x = texture_box.x; 496 box.x = (x + TITLEBAR_H_PADDING) * output_scale;
462 box.y = texture_box.y + texture_box.height; 497 box.y = (y + TITLEBAR_V_PADDING) * output_scale;
463 box.width = texture_box.width; 498 box.width = texture_box.width;
464 box.height = config->font_height * output_scale - texture_box.height; 499 box.height = ob_padding_above;
465 if (box.height > 0) { 500 render_rect(output->wlr_output, output_damage, &box, color);
501 }
502
503 // Padding below
504 if (ob_padding_below > 0) {
505 memcpy(&color, colors->background, sizeof(float) * 4);
506 premultiply_alpha(color, con->alpha);
507 box.x = (x + TITLEBAR_H_PADDING) * output_scale;
508 box.y = (y + TITLEBAR_V_PADDING) * output_scale +
509 ob_padding_above + texture_box.height;
510 box.width = texture_box.width;
511 box.height = ob_padding_below;
466 render_rect(output->wlr_output, output_damage, &box, color); 512 render_rect(output->wlr_output, output_damage, &box, color);
467 } 513 }
468 } 514 }