aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPo Lu2022-05-10 09:00:39 +0000
committerPo Lu2022-05-10 09:00:39 +0000
commit773c5c00d23ccb78f491b30e67f77ebe5d38be1a (patch)
treefd42033a4ca9cb726098dcdb9458c64148e6440c /src
parente8d643eb835e2883e12032a7f25e94a8a3335c87 (diff)
downloademacs-773c5c00d23ccb78f491b30e67f77ebe5d38be1a.tar.gz
emacs-773c5c00d23ccb78f491b30e67f77ebe5d38be1a.zip
Improve relief rect handling on Haiku
* haikuterm.c (haiku_calculate_relief_colors): Calculate backgrounds for image glyphs like on X. (haiku_draw_relief_rect): Remove extra parameter. (haiku_draw_string_box, haiku_draw_image_relief): Adjust accordingly.
Diffstat (limited to 'src')
-rw-r--r--src/haikuterm.c49
1 files changed, 30 insertions, 19 deletions
diff --git a/src/haikuterm.c b/src/haikuterm.c
index 802d7d2ac2f..26ea69758b1 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -586,9 +586,9 @@ haiku_defined_color (struct frame *f,
586 586
587/* Adapted from xterm `x_draw_box_rect'. */ 587/* Adapted from xterm `x_draw_box_rect'. */
588static void 588static void
589haiku_draw_box_rect (struct glyph_string *s, 589haiku_draw_box_rect (struct glyph_string *s, int left_x, int top_y,
590 int left_x, int top_y, int right_x, int bottom_y, int hwidth, 590 int right_x, int bottom_y, int hwidth, int vwidth,
591 int vwidth, bool left_p, bool right_p, struct haiku_rect *clip_rect) 591 bool left_p, bool right_p, struct haiku_rect *clip_rect)
592{ 592{
593 void *view = FRAME_HAIKU_VIEW (s->f); 593 void *view = FRAME_HAIKU_VIEW (s->f);
594 struct face *face = s->face; 594 struct face *face = s->face;
@@ -612,13 +612,19 @@ static void
612haiku_calculate_relief_colors (struct glyph_string *s, uint32_t *rgbout_w, 612haiku_calculate_relief_colors (struct glyph_string *s, uint32_t *rgbout_w,
613 uint32_t *rgbout_b) 613 uint32_t *rgbout_b)
614{ 614{
615 struct face *face = s->face;
616 double h, cs, l; 615 double h, cs, l;
617 uint32_t rgbin; 616 uint32_t rgbin;
618 struct haiku_output *di; 617 struct haiku_output *di;
619 618
620 rgbin = (face->use_box_color_for_shadows_p 619 if (s->face->use_box_color_for_shadows_p)
621 ? face->box_color : face->background); 620 rgbin = s->face->box_color;
621 else if (s->first_glyph->type == IMAGE_GLYPH
622 && s->img->pixmap
623 && !IMAGE_BACKGROUND_TRANSPARENT (s->img, s->f, 0))
624 rgbin = IMAGE_BACKGROUND (s->img, s->f, 0);
625 else
626 rgbin = s->face->background;
627
622 di = FRAME_OUTPUT_DATA (s->f); 628 di = FRAME_OUTPUT_DATA (s->f);
623 629
624 if (s->hl == DRAW_CURSOR) 630 if (s->hl == DRAW_CURSOR)
@@ -640,30 +646,35 @@ haiku_calculate_relief_colors (struct glyph_string *s, uint32_t *rgbout_w,
640} 646}
641 647
642static void 648static void
643haiku_draw_relief_rect (struct glyph_string *s, 649haiku_draw_relief_rect (struct glyph_string *s, int left_x, int top_y,
644 int left_x, int top_y, int right_x, int bottom_y, 650 int right_x, int bottom_y, int hwidth, int vwidth,
645 int hwidth, int vwidth, bool raised_p, bool top_p, 651 bool raised_p, bool top_p, bool bot_p, bool left_p,
646 bool bot_p, bool left_p, bool right_p, 652 bool right_p, struct haiku_rect *clip_rect)
647 struct haiku_rect *clip_rect, bool fancy_p)
648{ 653{
649 uint32_t color_white, color_black; 654 uint32_t color_white, color_black;
650 void *view; 655 void *view;
651 656
657 view = FRAME_HAIKU_VIEW (s->f);
652 haiku_calculate_relief_colors (s, &color_white, &color_black); 658 haiku_calculate_relief_colors (s, &color_white, &color_black);
653 659
654 view = FRAME_HAIKU_VIEW (s->f);
655 BView_SetHighColor (view, raised_p ? color_white : color_black); 660 BView_SetHighColor (view, raised_p ? color_white : color_black);
661
656 if (clip_rect) 662 if (clip_rect)
657 { 663 {
658 BView_StartClip (view); 664 BView_StartClip (view);
659 haiku_clip_to_string (s); 665 haiku_clip_to_string (s);
660 BView_ClipToRect (view, clip_rect->x, clip_rect->y, clip_rect->width, 666 BView_ClipToRect (view, clip_rect->x, clip_rect->y,
661 clip_rect->height); 667 clip_rect->width, clip_rect->height);
662 } 668 }
669
663 if (top_p) 670 if (top_p)
664 BView_FillRectangle (view, left_x, top_y, right_x - left_x + 1, hwidth); 671 BView_FillRectangle (view, left_x, top_y,
672 right_x - left_x + 1, hwidth);
673
665 if (left_p) 674 if (left_p)
666 BView_FillRectangle (view, left_x, top_y, vwidth, bottom_y - top_y + 1); 675 BView_FillRectangle (view, left_x, top_y,
676 vwidth, bottom_y - top_y + 1);
677
667 BView_SetHighColor (view, !raised_p ? color_white : color_black); 678 BView_SetHighColor (view, !raised_p ? color_white : color_black);
668 679
669 if (bot_p) 680 if (bot_p)
@@ -707,7 +718,7 @@ haiku_draw_relief_rect (struct glyph_string *s,
707 BView_SetHighColor (view, s->face->background); 718 BView_SetHighColor (view, s->face->background);
708 719
709 /* Omit corner pixels. */ 720 /* Omit corner pixels. */
710 if (hwidth > 1 || vwidth > 1) 721 if (hwidth > 1 && vwidth > 1)
711 { 722 {
712 if (left_p && top_p) 723 if (left_p && top_p)
713 BView_FillRectangle (view, left_x, top_y, 1, 1); 724 BView_FillRectangle (view, left_x, top_y, 1, 1);
@@ -989,7 +1000,7 @@ haiku_draw_string_box (struct glyph_string *s)
989 else 1000 else
990 haiku_draw_relief_rect (s, left_x, top_y, right_x, bottom_y, hwidth, 1001 haiku_draw_relief_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
991 vwidth, raised_p, true, true, left_p, right_p, 1002 vwidth, raised_p, true, true, left_p, right_p,
992 NULL, 1); 1003 NULL);
993} 1004}
994 1005
995static void 1006static void
@@ -1611,7 +1622,7 @@ haiku_draw_image_relief (struct glyph_string *s)
1611 1622
1612 get_glyph_string_clip_rect (s, &r); 1623 get_glyph_string_clip_rect (s, &r);
1613 haiku_draw_relief_rect (s, x, y, x1, y1, thick, thick, raised_p, 1624 haiku_draw_relief_rect (s, x, y, x1, y1, thick, thick, raised_p,
1614 top_p, bot_p, left_p, right_p, &r, 0); 1625 top_p, bot_p, left_p, right_p, &r);
1615} 1626}
1616 1627
1617static void 1628static void