aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/haikuterm.c321
-rw-r--r--src/w32.c28
-rw-r--r--src/w32.h1
-rw-r--r--src/w32proc.c21
4 files changed, 199 insertions, 172 deletions
diff --git a/src/haikuterm.c b/src/haikuterm.c
index f3c37b0258e..f95a013867f 100644
--- a/src/haikuterm.c
+++ b/src/haikuterm.c
@@ -536,162 +536,6 @@ haiku_draw_relief_rect (struct glyph_string *s,
536} 536}
537 537
538static void 538static void
539haiku_draw_string_box (struct glyph_string *s, int clip_p)
540{
541 int hwidth, vwidth, left_x, right_x, top_y, bottom_y, last_x;
542 bool raised_p, left_p, right_p;
543 struct glyph *last_glyph;
544 struct haiku_rect clip_rect;
545
546 struct face *face = s->face;
547
548 last_x = ((s->row->full_width_p && !s->w->pseudo_window_p)
549 ? WINDOW_RIGHT_EDGE_X (s->w)
550 : window_box_right (s->w, s->area));
551
552 /* The glyph that may have a right box line. For static
553 compositions and images, the right-box flag is on the first glyph
554 of the glyph string; for other types it's on the last glyph. */
555 if (s->cmp || s->img)
556 last_glyph = s->first_glyph;
557 else if (s->first_glyph->type == COMPOSITE_GLYPH
558 && s->first_glyph->u.cmp.automatic)
559 {
560 /* For automatic compositions, we need to look up the last glyph
561 in the composition. */
562 struct glyph *end = s->row->glyphs[s->area] + s->row->used[s->area];
563 struct glyph *g = s->first_glyph;
564 for (last_glyph = g++;
565 g < end && g->u.cmp.automatic && g->u.cmp.id == s->cmp_id
566 && g->slice.cmp.to < s->cmp_to;
567 last_glyph = g++)
568 ;
569 }
570 else
571 last_glyph = s->first_glyph + s->nchars - 1;
572
573 vwidth = eabs (face->box_vertical_line_width);
574 hwidth = eabs (face->box_horizontal_line_width);
575 raised_p = face->box == FACE_RAISED_BOX;
576 left_x = s->x;
577 right_x = (s->row->full_width_p && s->extends_to_end_of_line_p
578 ? last_x - 1
579 : min (last_x, s->x + s->background_width) - 1);
580
581 top_y = s->y;
582 bottom_y = top_y + s->height - 1;
583
584 left_p = (s->first_glyph->left_box_line_p
585 || (s->hl == DRAW_MOUSE_FACE
586 && (s->prev == NULL
587 || s->prev->hl != s->hl)));
588 right_p = (last_glyph->right_box_line_p
589 || (s->hl == DRAW_MOUSE_FACE
590 && (s->next == NULL
591 || s->next->hl != s->hl)));
592
593 get_glyph_string_clip_rect (s, &clip_rect);
594
595 if (face->box == FACE_SIMPLE_BOX)
596 haiku_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
597 vwidth, left_p, right_p, &clip_rect);
598 else
599 haiku_draw_relief_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
600 vwidth, raised_p, true, true, left_p, right_p,
601 &clip_rect, 1);
602
603 if (clip_p)
604 {
605 void *view = FRAME_HAIKU_VIEW (s->f);
606 BView_ClipToInverseRect (view, left_x, top_y, right_x - left_x + 1, hwidth);
607 if (left_p)
608 BView_ClipToInverseRect (view, left_x, top_y, vwidth, bottom_y - top_y + 1);
609 BView_ClipToInverseRect (view, left_x, bottom_y - hwidth + 1,
610 right_x - left_x + 1, hwidth);
611 if (right_p)
612 BView_ClipToInverseRect (view, right_x - vwidth + 1,
613 top_y, vwidth, bottom_y - top_y + 1);
614 }
615}
616
617static void
618haiku_draw_plain_background (struct glyph_string *s, struct face *face,
619 int box_line_hwidth, int box_line_vwidth)
620{
621 void *view = FRAME_HAIKU_VIEW (s->f);
622 BView_StartClip (view);
623 if (s->hl == DRAW_CURSOR)
624 BView_SetHighColor (view, FRAME_CURSOR_COLOR (s->f).pixel);
625 else
626 BView_SetHighColor (view, face->background_defaulted_p ?
627 FRAME_BACKGROUND_PIXEL (s->f) :
628 face->background);
629
630 BView_FillRectangle (view, s->x,
631 s->y + box_line_hwidth,
632 s->background_width,
633 s->height - 2 * box_line_hwidth);
634 BView_EndClip (view);
635}
636
637static void
638haiku_draw_stipple_background (struct glyph_string *s, struct face *face,
639 int box_line_hwidth, int box_line_vwidth)
640{
641}
642
643static void
644haiku_maybe_draw_background (struct glyph_string *s, int force_p)
645{
646 if ((s->first_glyph->type != IMAGE_GLYPH) && !s->background_filled_p)
647 {
648 struct face *face = s->face;
649 int box_line_width = max (face->box_horizontal_line_width, 0);
650 int box_vline_width = max (face->box_vertical_line_width, 0);
651
652 if (FONT_HEIGHT (s->font) < s->height - 2 * box_vline_width
653 || FONT_TOO_HIGH (s->font)
654 || s->font_not_found_p || s->extends_to_end_of_line_p || force_p)
655 {
656 if (!face->stipple)
657 haiku_draw_plain_background (s, face, box_line_width,
658 box_vline_width);
659 else
660 haiku_draw_stipple_background (s, face, box_line_width,
661 box_vline_width);
662 s->background_filled_p = 1;
663 }
664 }
665}
666
667static void
668haiku_mouse_face_colors (struct glyph_string *s, uint32_t *fg,
669 uint32_t *bg)
670{
671 int face_id;
672 struct face *face;
673
674 /* What face has to be used last for the mouse face? */
675 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
676 face = FACE_FROM_ID_OR_NULL (s->f, face_id);
677 if (face == NULL)
678 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
679
680 if (s->first_glyph->type == CHAR_GLYPH)
681 face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch, -1, Qnil);
682 else
683 face_id = FACE_FOR_CHAR (s->f, face, 0, -1, Qnil);
684
685 face = FACE_FROM_ID (s->f, face_id);
686 prepare_face_for_display (s->f, s->face);
687
688 if (fg)
689 *fg = face->foreground;
690 if (bg)
691 *bg = face->background;
692}
693
694static void
695haiku_draw_underwave (struct glyph_string *s, int width, int x) 539haiku_draw_underwave (struct glyph_string *s, int width, int x)
696{ 540{
697 int wave_height = 3, wave_length = 2; 541 int wave_height = 3, wave_length = 2;
@@ -876,6 +720,164 @@ haiku_draw_text_decoration (struct glyph_string *s, struct face *face,
876} 720}
877 721
878static void 722static void
723haiku_draw_string_box (struct glyph_string *s, int clip_p)
724{
725 int hwidth, vwidth, left_x, right_x, top_y, bottom_y, last_x;
726 bool raised_p, left_p, right_p;
727 struct glyph *last_glyph;
728 struct haiku_rect clip_rect;
729
730 struct face *face = s->face;
731
732 last_x = ((s->row->full_width_p && !s->w->pseudo_window_p)
733 ? WINDOW_RIGHT_EDGE_X (s->w)
734 : window_box_right (s->w, s->area));
735
736 /* The glyph that may have a right box line. For static
737 compositions and images, the right-box flag is on the first glyph
738 of the glyph string; for other types it's on the last glyph. */
739 if (s->cmp || s->img)
740 last_glyph = s->first_glyph;
741 else if (s->first_glyph->type == COMPOSITE_GLYPH
742 && s->first_glyph->u.cmp.automatic)
743 {
744 /* For automatic compositions, we need to look up the last glyph
745 in the composition. */
746 struct glyph *end = s->row->glyphs[s->area] + s->row->used[s->area];
747 struct glyph *g = s->first_glyph;
748 for (last_glyph = g++;
749 g < end && g->u.cmp.automatic && g->u.cmp.id == s->cmp_id
750 && g->slice.cmp.to < s->cmp_to;
751 last_glyph = g++)
752 ;
753 }
754 else
755 last_glyph = s->first_glyph + s->nchars - 1;
756
757 vwidth = eabs (face->box_vertical_line_width);
758 hwidth = eabs (face->box_horizontal_line_width);
759 raised_p = face->box == FACE_RAISED_BOX;
760 left_x = s->x;
761 right_x = (s->row->full_width_p && s->extends_to_end_of_line_p
762 ? last_x - 1
763 : min (last_x, s->x + s->background_width) - 1);
764
765 top_y = s->y;
766 bottom_y = top_y + s->height - 1;
767
768 left_p = (s->first_glyph->left_box_line_p
769 || (s->hl == DRAW_MOUSE_FACE
770 && (s->prev == NULL
771 || s->prev->hl != s->hl)));
772 right_p = (last_glyph->right_box_line_p
773 || (s->hl == DRAW_MOUSE_FACE
774 && (s->next == NULL
775 || s->next->hl != s->hl)));
776
777 get_glyph_string_clip_rect (s, &clip_rect);
778
779 if (face->box == FACE_SIMPLE_BOX)
780 haiku_draw_box_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
781 vwidth, left_p, right_p, &clip_rect);
782 else
783 haiku_draw_relief_rect (s, left_x, top_y, right_x, bottom_y, hwidth,
784 vwidth, raised_p, true, true, left_p, right_p,
785 &clip_rect, 1);
786
787 if (clip_p)
788 {
789 void *view = FRAME_HAIKU_VIEW (s->f);
790
791 haiku_draw_text_decoration (s, face, face->foreground, s->width, s->x);
792 BView_ClipToInverseRect (view, left_x, top_y, right_x - left_x + 1, hwidth);
793 if (left_p)
794 BView_ClipToInverseRect (view, left_x, top_y, vwidth, bottom_y - top_y + 1);
795 BView_ClipToInverseRect (view, left_x, bottom_y - hwidth + 1,
796 right_x - left_x + 1, hwidth);
797 if (right_p)
798 BView_ClipToInverseRect (view, right_x - vwidth + 1,
799 top_y, vwidth, bottom_y - top_y + 1);
800 }
801}
802
803static void
804haiku_draw_plain_background (struct glyph_string *s, struct face *face,
805 int box_line_hwidth, int box_line_vwidth)
806{
807 void *view = FRAME_HAIKU_VIEW (s->f);
808 BView_StartClip (view);
809 if (s->hl == DRAW_CURSOR)
810 BView_SetHighColor (view, FRAME_CURSOR_COLOR (s->f).pixel);
811 else
812 BView_SetHighColor (view, face->background_defaulted_p ?
813 FRAME_BACKGROUND_PIXEL (s->f) :
814 face->background);
815
816 BView_FillRectangle (view, s->x,
817 s->y + box_line_hwidth,
818 s->background_width,
819 s->height - 2 * box_line_hwidth);
820 BView_EndClip (view);
821}
822
823static void
824haiku_draw_stipple_background (struct glyph_string *s, struct face *face,
825 int box_line_hwidth, int box_line_vwidth)
826{
827}
828
829static void
830haiku_maybe_draw_background (struct glyph_string *s, int force_p)
831{
832 if ((s->first_glyph->type != IMAGE_GLYPH) && !s->background_filled_p)
833 {
834 struct face *face = s->face;
835 int box_line_width = max (face->box_horizontal_line_width, 0);
836 int box_vline_width = max (face->box_vertical_line_width, 0);
837
838 if (FONT_HEIGHT (s->font) < s->height - 2 * box_vline_width
839 || FONT_TOO_HIGH (s->font)
840 || s->font_not_found_p || s->extends_to_end_of_line_p || force_p)
841 {
842 if (!face->stipple)
843 haiku_draw_plain_background (s, face, box_line_width,
844 box_vline_width);
845 else
846 haiku_draw_stipple_background (s, face, box_line_width,
847 box_vline_width);
848 s->background_filled_p = 1;
849 }
850 }
851}
852
853static void
854haiku_mouse_face_colors (struct glyph_string *s, uint32_t *fg,
855 uint32_t *bg)
856{
857 int face_id;
858 struct face *face;
859
860 /* What face has to be used last for the mouse face? */
861 face_id = MOUSE_HL_INFO (s->f)->mouse_face_face_id;
862 face = FACE_FROM_ID_OR_NULL (s->f, face_id);
863 if (face == NULL)
864 face = FACE_FROM_ID (s->f, MOUSE_FACE_ID);
865
866 if (s->first_glyph->type == CHAR_GLYPH)
867 face_id = FACE_FOR_CHAR (s->f, face, s->first_glyph->u.ch, -1, Qnil);
868 else
869 face_id = FACE_FOR_CHAR (s->f, face, 0, -1, Qnil);
870
871 face = FACE_FROM_ID (s->f, face_id);
872 prepare_face_for_display (s->f, s->face);
873
874 if (fg)
875 *fg = face->foreground;
876 if (bg)
877 *bg = face->background;
878}
879
880static void
879haiku_draw_glyph_string_foreground (struct glyph_string *s) 881haiku_draw_glyph_string_foreground (struct glyph_string *s)
880{ 882{
881 struct face *face = s->face; 883 struct face *face = s->face;
@@ -1557,14 +1559,11 @@ haiku_draw_glyph_string (struct glyph_string *s)
1557 1559
1558 if (!box_filled_p && face->box != FACE_NO_BOX) 1560 if (!box_filled_p && face->box != FACE_NO_BOX)
1559 haiku_draw_string_box (s, 1); 1561 haiku_draw_string_box (s, 1);
1562 else
1563 haiku_draw_text_decoration (s, face, face->foreground, s->width, s->x);
1560 1564
1561 if (!s->for_overlaps) 1565 if (!s->for_overlaps)
1562 { 1566 {
1563 uint32_t dcol;
1564 dcol = face->foreground;
1565
1566 haiku_draw_text_decoration (s, face, dcol, s->width, s->x);
1567
1568 if (s->prev) 1567 if (s->prev)
1569 { 1568 {
1570 struct glyph_string *prev; 1569 struct glyph_string *prev;
diff --git a/src/w32.c b/src/w32.c
index 2b2f8aadf6b..1de148f0343 100644
--- a/src/w32.c
+++ b/src/w32.c
@@ -8548,7 +8548,7 @@ fcntl (int s, int cmd, int options)
8548int 8548int
8549sys_close (int fd) 8549sys_close (int fd)
8550{ 8550{
8551 int rc; 8551 int rc = -1;
8552 8552
8553 if (fd < 0) 8553 if (fd < 0)
8554 { 8554 {
@@ -8603,14 +8603,31 @@ sys_close (int fd)
8603 } 8603 }
8604 } 8604 }
8605 8605
8606 if (fd >= 0 && fd < MAXDESC)
8607 fd_info[fd].flags = 0;
8608
8609 /* Note that sockets do not need special treatment here (at least on 8606 /* Note that sockets do not need special treatment here (at least on
8610 NT and Windows 95 using the standard tcp/ip stacks) - it appears that 8607 NT and Windows 95 using the standard tcp/ip stacks) - it appears that
8611 closesocket is equivalent to CloseHandle, which is to be expected 8608 closesocket is equivalent to CloseHandle, which is to be expected
8612 because socket handles are fully fledged kernel handles. */ 8609 because socket handles are fully fledged kernel handles. */
8613 rc = _close (fd); 8610 if (fd < MAXDESC)
8611 {
8612 if ((fd_info[fd].flags & FILE_DONT_CLOSE) == 0)
8613 {
8614 fd_info[fd].flags = 0;
8615 rc = _close (fd);
8616 }
8617 else
8618 {
8619 /* We don't close here descriptors open by pipe processes
8620 for reading from the pipe, because the reader thread
8621 might be stuck in _sys_read_ahead, and then we will hang
8622 here. If the reader thread exits normally, it will close
8623 the descriptor; otherwise we will leave a zombie thread
8624 hanging around. */
8625 rc = 0;
8626 /* Leave the flag set for the reader thread to close the
8627 descriptor. */
8628 fd_info[fd].flags = FILE_DONT_CLOSE;
8629 }
8630 }
8614 8631
8615 return rc; 8632 return rc;
8616} 8633}
@@ -10898,6 +10915,7 @@ register_aux_fd (int infd)
10898 } 10915 }
10899 fd_info[ infd ].cp = cp; 10916 fd_info[ infd ].cp = cp;
10900 fd_info[ infd ].hnd = (HANDLE) _get_osfhandle (infd); 10917 fd_info[ infd ].hnd = (HANDLE) _get_osfhandle (infd);
10918 fd_info[ infd ].flags |= FILE_DONT_CLOSE;
10901} 10919}
10902 10920
10903#ifdef HAVE_GNUTLS 10921#ifdef HAVE_GNUTLS
diff --git a/src/w32.h b/src/w32.h
index b31d66646c9..bb3ec40324a 100644
--- a/src/w32.h
+++ b/src/w32.h
@@ -135,6 +135,7 @@ extern filedesc fd_info [ MAXDESC ];
135#define FILE_SOCKET 0x0200 135#define FILE_SOCKET 0x0200
136#define FILE_NDELAY 0x0400 136#define FILE_NDELAY 0x0400
137#define FILE_SERIAL 0x0800 137#define FILE_SERIAL 0x0800
138#define FILE_DONT_CLOSE 0x1000
138 139
139extern child_process * new_child (void); 140extern child_process * new_child (void);
140extern void delete_child (child_process *cp); 141extern void delete_child (child_process *cp);
diff --git a/src/w32proc.c b/src/w32proc.c
index 360f45e9e11..bfe720eb623 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -1206,6 +1206,7 @@ static DWORD WINAPI
1206reader_thread (void *arg) 1206reader_thread (void *arg)
1207{ 1207{
1208 child_process *cp; 1208 child_process *cp;
1209 int fd;
1209 1210
1210 /* Our identity */ 1211 /* Our identity */
1211 cp = (child_process *)arg; 1212 cp = (child_process *)arg;
@@ -1220,12 +1221,13 @@ reader_thread (void *arg)
1220 { 1221 {
1221 int rc; 1222 int rc;
1222 1223
1223 if (cp->fd >= 0 && (fd_info[cp->fd].flags & FILE_CONNECT) != 0) 1224 fd = cp->fd;
1224 rc = _sys_wait_connect (cp->fd); 1225 if (fd >= 0 && (fd_info[fd].flags & FILE_CONNECT) != 0)
1225 else if (cp->fd >= 0 && (fd_info[cp->fd].flags & FILE_LISTEN) != 0) 1226 rc = _sys_wait_connect (fd);
1226 rc = _sys_wait_accept (cp->fd); 1227 else if (fd >= 0 && (fd_info[fd].flags & FILE_LISTEN) != 0)
1228 rc = _sys_wait_accept (fd);
1227 else 1229 else
1228 rc = _sys_read_ahead (cp->fd); 1230 rc = _sys_read_ahead (fd);
1229 1231
1230 /* Don't bother waiting for the event if we already have been 1232 /* Don't bother waiting for the event if we already have been
1231 told to exit by delete_child. */ 1233 told to exit by delete_child. */
@@ -1238,7 +1240,7 @@ reader_thread (void *arg)
1238 { 1240 {
1239 DebPrint (("reader_thread.SetEvent(0x%x) failed with %lu for fd %ld (PID %d)\n", 1241 DebPrint (("reader_thread.SetEvent(0x%x) failed with %lu for fd %ld (PID %d)\n",
1240 (DWORD_PTR)cp->char_avail, GetLastError (), 1242 (DWORD_PTR)cp->char_avail, GetLastError (),
1241 cp->fd, cp->pid)); 1243 fd, cp->pid));
1242 return 1; 1244 return 1;
1243 } 1245 }
1244 1246
@@ -1266,6 +1268,13 @@ reader_thread (void *arg)
1266 if (cp->status == STATUS_READ_ERROR) 1268 if (cp->status == STATUS_READ_ERROR)
1267 break; 1269 break;
1268 } 1270 }
1271 /* If this thread was reading from a pipe process, close the
1272 descriptor used for reading, as sys_close doesn't in that case. */
1273 if (fd_info[fd].flags == FILE_DONT_CLOSE)
1274 {
1275 fd_info[fd].flags = 0;
1276 _close (fd);
1277 }
1269 return 0; 1278 return 0;
1270} 1279}
1271 1280