diff options
| author | Po Lu | 2022-02-05 03:17:58 +0000 |
|---|---|---|
| committer | Po Lu | 2022-02-05 03:17:58 +0000 |
| commit | c274bd5c52fd64c888b1c713060da881bf72caa7 (patch) | |
| tree | 5471cc3c01428d184566fb584028fc87953014d1 /src | |
| parent | 686f7f8f628c04e9d574186173165b2b5a9f92e2 (diff) | |
| download | emacs-c274bd5c52fd64c888b1c713060da881bf72caa7.tar.gz emacs-c274bd5c52fd64c888b1c713060da881bf72caa7.zip | |
Implement face cursor color merging on Haiku
* src/ftcrfont.c (ftcrfont_draw):
* src/haikufont.c (haikufont_draw): Use
`haiku_merge_cursor_foreground' to calculate cursor HL colors.
* src/haikuterm.c (haiku_merge_cursor_foreground): New function.
* src/haikuterm.h: Update prototypes.
Diffstat (limited to 'src')
| -rw-r--r-- | src/ftcrfont.c | 19 | ||||
| -rw-r--r-- | src/haikufont.c | 19 | ||||
| -rw-r--r-- | src/haikuterm.c | 26 | ||||
| -rw-r--r-- | src/haikuterm.h | 3 |
4 files changed, 54 insertions, 13 deletions
diff --git a/src/ftcrfont.c b/src/ftcrfont.c index 7d192697ca1..87a8692a3b8 100644 --- a/src/ftcrfont.c +++ b/src/ftcrfont.c | |||
| @@ -522,12 +522,23 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 522 | int from, int to, int x, int y, bool with_background) | 522 | int from, int to, int x, int y, bool with_background) |
| 523 | { | 523 | { |
| 524 | struct frame *f = s->f; | 524 | struct frame *f = s->f; |
| 525 | struct face *face = s->face; | ||
| 526 | struct font_info *ftcrfont_info = (struct font_info *) s->font; | 525 | struct font_info *ftcrfont_info = (struct font_info *) s->font; |
| 527 | cairo_t *cr; | 526 | cairo_t *cr; |
| 528 | cairo_glyph_t *glyphs; | 527 | cairo_glyph_t *glyphs; |
| 529 | int len = to - from; | 528 | int len = to - from; |
| 530 | int i; | 529 | int i; |
| 530 | #ifdef USE_BE_CAIRO | ||
| 531 | unsigned long be_foreground, be_background; | ||
| 532 | |||
| 533 | if (s->hl != DRAW_CURSOR) | ||
| 534 | { | ||
| 535 | be_foreground = s->face->foreground; | ||
| 536 | be_background = s->face->background; | ||
| 537 | } | ||
| 538 | else | ||
| 539 | haiku_merge_cursor_foreground (s, &be_foreground, | ||
| 540 | &be_background); | ||
| 541 | #endif | ||
| 531 | 542 | ||
| 532 | block_input (); | 543 | block_input (); |
| 533 | 544 | ||
| @@ -562,8 +573,7 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 562 | #else | 573 | #else |
| 563 | struct face *face = s->face; | 574 | struct face *face = s->face; |
| 564 | 575 | ||
| 565 | uint32_t col = s->hl == DRAW_CURSOR ? | 576 | uint32_t col = be_background; |
| 566 | FRAME_CURSOR_COLOR (s->f).pixel : face->background; | ||
| 567 | 577 | ||
| 568 | cairo_set_source_rgb (cr, RED_FROM_ULONG (col) / 255.0, | 578 | cairo_set_source_rgb (cr, RED_FROM_ULONG (col) / 255.0, |
| 569 | GREEN_FROM_ULONG (col) / 255.0, | 579 | GREEN_FROM_ULONG (col) / 255.0, |
| @@ -592,8 +602,7 @@ ftcrfont_draw (struct glyph_string *s, | |||
| 592 | pgtk_set_cr_source_with_color (f, s->xgcv.foreground, false); | 602 | pgtk_set_cr_source_with_color (f, s->xgcv.foreground, false); |
| 593 | #endif | 603 | #endif |
| 594 | #else | 604 | #else |
| 595 | uint32_t col = s->hl == DRAW_CURSOR ? | 605 | uint32_t col = be_foreground; |
| 596 | FRAME_OUTPUT_DATA (s->f)->cursor_fg : face->foreground; | ||
| 597 | 606 | ||
| 598 | cairo_set_source_rgb (cr, RED_FROM_ULONG (col) / 255.0, | 607 | cairo_set_source_rgb (cr, RED_FROM_ULONG (col) / 255.0, |
| 599 | GREEN_FROM_ULONG (col) / 255.0, | 608 | GREEN_FROM_ULONG (col) / 255.0, |
diff --git a/src/haikufont.c b/src/haikufont.c index 1ef5f54c9aa..6cc984f3165 100644 --- a/src/haikufont.c +++ b/src/haikufont.c | |||
| @@ -951,10 +951,19 @@ haikufont_draw (struct glyph_string *s, int from, int to, | |||
| 951 | struct font_info *info = (struct font_info *) s->font; | 951 | struct font_info *info = (struct font_info *) s->font; |
| 952 | unsigned char mb[MAX_MULTIBYTE_LENGTH]; | 952 | unsigned char mb[MAX_MULTIBYTE_LENGTH]; |
| 953 | void *view = FRAME_HAIKU_VIEW (f); | 953 | void *view = FRAME_HAIKU_VIEW (f); |
| 954 | unsigned long foreground, background; | ||
| 954 | 955 | ||
| 955 | block_input (); | 956 | block_input (); |
| 956 | prepare_face_for_display (s->f, face); | 957 | prepare_face_for_display (s->f, face); |
| 957 | 958 | ||
| 959 | if (s->hl != DRAW_CURSOR) | ||
| 960 | { | ||
| 961 | foreground = s->face->foreground; | ||
| 962 | background = s->face->background; | ||
| 963 | } | ||
| 964 | else | ||
| 965 | haiku_merge_cursor_foreground (s, &foreground, &background); | ||
| 966 | |||
| 958 | /* Presumably the draw lock is already held by | 967 | /* Presumably the draw lock is already held by |
| 959 | haiku_draw_glyph_string; */ | 968 | haiku_draw_glyph_string; */ |
| 960 | if (with_background) | 969 | if (with_background) |
| @@ -977,18 +986,12 @@ haikufont_draw (struct glyph_string *s, int from, int to, | |||
| 977 | s->first_glyph->slice.glyphless.lower_yoff | 986 | s->first_glyph->slice.glyphless.lower_yoff |
| 978 | - s->first_glyph->slice.glyphless.upper_yoff; | 987 | - s->first_glyph->slice.glyphless.upper_yoff; |
| 979 | 988 | ||
| 980 | BView_SetHighColor (view, s->hl == DRAW_CURSOR ? | 989 | BView_SetHighColor (view, background); |
| 981 | FRAME_CURSOR_COLOR (s->f).pixel : face->background); | ||
| 982 | |||
| 983 | BView_FillRectangle (view, x, y - ascent, s->width, height); | 990 | BView_FillRectangle (view, x, y - ascent, s->width, height); |
| 984 | s->background_filled_p = 1; | 991 | s->background_filled_p = 1; |
| 985 | } | 992 | } |
| 986 | 993 | ||
| 987 | if (s->hl == DRAW_CURSOR) | 994 | BView_SetHighColor (view, foreground); |
| 988 | BView_SetHighColor (view, FRAME_OUTPUT_DATA (s->f)->cursor_fg); | ||
| 989 | else | ||
| 990 | BView_SetHighColor (view, face->foreground); | ||
| 991 | |||
| 992 | BView_MovePenTo (view, x, y); | 995 | BView_MovePenTo (view, x, y); |
| 993 | BView_SetFont (view, ((struct haikufont_info *) info)->be_font); | 996 | BView_SetFont (view, ((struct haikufont_info *) info)->be_font); |
| 994 | 997 | ||
diff --git a/src/haikuterm.c b/src/haikuterm.c index aac9582e6ef..6707340ca05 100644 --- a/src/haikuterm.c +++ b/src/haikuterm.c | |||
| @@ -3644,6 +3644,32 @@ haiku_end_cr_clip (cairo_t *cr) | |||
| 3644 | #endif | 3644 | #endif |
| 3645 | 3645 | ||
| 3646 | void | 3646 | void |
| 3647 | haiku_merge_cursor_foreground (struct glyph_string *s, | ||
| 3648 | unsigned long *foreground_out, | ||
| 3649 | unsigned long *background_out) | ||
| 3650 | { | ||
| 3651 | unsigned long background = FRAME_CURSOR_COLOR (s->f).pixel; | ||
| 3652 | unsigned long foreground = s->face->background; | ||
| 3653 | |||
| 3654 | if (background == foreground) | ||
| 3655 | foreground = s->face->background; | ||
| 3656 | if (background == foreground) | ||
| 3657 | foreground = FRAME_OUTPUT_DATA (s->f)->cursor_fg; | ||
| 3658 | if (background == foreground) | ||
| 3659 | foreground = s->face->foreground; | ||
| 3660 | |||
| 3661 | if (background == s->face->background | ||
| 3662 | || foreground == s->face->foreground) | ||
| 3663 | { | ||
| 3664 | background = s->face->foreground; | ||
| 3665 | foreground = s->face->background; | ||
| 3666 | } | ||
| 3667 | |||
| 3668 | *foreground_out = foreground; | ||
| 3669 | *background_out = background; | ||
| 3670 | } | ||
| 3671 | |||
| 3672 | void | ||
| 3647 | syms_of_haikuterm (void) | 3673 | syms_of_haikuterm (void) |
| 3648 | { | 3674 | { |
| 3649 | DEFVAR_BOOL ("haiku-initialized", haiku_initialized, | 3675 | DEFVAR_BOOL ("haiku-initialized", haiku_initialized, |
diff --git a/src/haikuterm.h b/src/haikuterm.h index 2dbdb6aafcb..a2520858f54 100644 --- a/src/haikuterm.h +++ b/src/haikuterm.h | |||
| @@ -294,4 +294,7 @@ haiku_begin_cr_clip (struct frame *f, struct glyph_string *s); | |||
| 294 | extern void | 294 | extern void |
| 295 | haiku_end_cr_clip (cairo_t *cr); | 295 | haiku_end_cr_clip (cairo_t *cr); |
| 296 | #endif | 296 | #endif |
| 297 | |||
| 298 | extern void haiku_merge_cursor_foreground (struct glyph_string *, unsigned long *, | ||
| 299 | unsigned long *); | ||
| 297 | #endif /* _HAIKU_TERM_H_ */ | 300 | #endif /* _HAIKU_TERM_H_ */ |