comparison src/w32term.c @ 41249:2043af2d023f

(note_mouse_highlight): Fix type of variable `ignore'. (x_draw_bar_cursor): If the background color of the glyph under the cursor equals the frame's cursor color, use the glyph's foreground color for drawing the bar cursor. (x_after_update_window_line): Clear internal border in different circumstances. (w32_set_vertical_scroll_bar): Check for width and height > 0. (w32_draw_relief_rect): Correct relief by 1 pixel. (x_set_glyph_string_background_width): Set extends_to_end_of_line_p if the row's fill_line_p is set and drawing the last glyph with DRAW_IMAGE_{RAISED,SUNKEN}. (x_display_and_set_cursor): If cursor_in_echo_area, use NO_CURSOR if cursor_in_non_selected_windows is false. (show_mouse_face): Clean up. Recognize overwritten cursor differently. (x_draw_glyphs): Remove parameters REAL_START and REAL_END. Notice if cursor gets overwritten. (notice_overwritten_cursor): Renamed from note_overwritten_text_cursor. Rewritten to take glyph widths into account, and to take X positions as parameters. (x_draw_phys_cursor_glyph): Save state of w->phys_cursor_on_p around call to x_draw_glyphs. (x_setup_relief_colors): Use `IMAGE_BACKGROUND' and `IMAGE_BACKGROUND_TRANSPARENT' to calculate the correct background color to use for image glyph reliefs. (x_draw_image_relief): Accept zero tool_bar_button_relief. (glyph_rect): Remove unused variable `area'.
author Jason Rumney <jasonr@gnu.org>
date Sun, 18 Nov 2001 21:53:11 +0000
parents 9a179e92e3ba
children 783d21cc62b9
comparison
equal deleted inserted replaced
41248:74f8ac2c0480 41249:2043af2d023f
405 enum fringe_bitmap_type)); 405 enum fringe_bitmap_type));
406 static void w32_clip_to_row P_ ((struct window *, struct glyph_row *, 406 static void w32_clip_to_row P_ ((struct window *, struct glyph_row *,
407 HDC, int)); 407 HDC, int));
408 static int x_phys_cursor_in_rect_p P_ ((struct window *, RECT *)); 408 static int x_phys_cursor_in_rect_p P_ ((struct window *, RECT *));
409 static void x_draw_row_fringe_bitmaps P_ ((struct window *, struct glyph_row *)); 409 static void x_draw_row_fringe_bitmaps P_ ((struct window *, struct glyph_row *));
410 static void note_overwritten_text_cursor P_ ((struct window *, int, int)); 410 static void notice_overwritten_cursor P_ ((struct window *, int, int));
411 411
412 static Lisp_Object Qvendor_specific_keysyms; 412 static Lisp_Object Qvendor_specific_keysyms;
413 413
414 414
415 /*********************************************************************** 415 /***********************************************************************
759 static void 759 static void
760 x_after_update_window_line (desired_row) 760 x_after_update_window_line (desired_row)
761 struct glyph_row *desired_row; 761 struct glyph_row *desired_row;
762 { 762 {
763 struct window *w = updated_window; 763 struct window *w = updated_window;
764 764 struct frame *f;
765 int width, height;
766
765 xassert (w); 767 xassert (w);
766 768
767 if (!desired_row->mode_line_p && !w->pseudo_window_p) 769 if (!desired_row->mode_line_p && !w->pseudo_window_p)
768 { 770 {
769 struct frame *f;
770 int width;
771
772 BLOCK_INPUT; 771 BLOCK_INPUT;
773 x_draw_row_fringe_bitmaps (w, desired_row); 772 x_draw_row_fringe_bitmaps (w, desired_row);
774 773 UNBLOCK_INPUT;
775 /* When a window has disappeared, make sure that no rest of 774 }
776 full-width rows stays visible in the internal border. */ 775
777 if (windows_or_buffers_changed 776 /* When a window has disappeared, make sure that no rest of
778 && (f = XFRAME (w->frame), 777 full-width rows stays visible in the internal border. Could
779 width = FRAME_INTERNAL_BORDER_WIDTH (f), 778 check here if updated_window is the leftmost/rightmost window,
780 width != 0)) 779 but I guess it's not worth doing since vertically split windows
781 { 780 are almost never used, internal border is rarely set, and the
782 int height = desired_row->visible_height; 781 overhead is very small. */
783 int x = (window_box_right (w, -1) 782 if (windows_or_buffers_changed
784 + FRAME_X_RIGHT_FRINGE_WIDTH (f)); 783 && desired_row->full_width_p
785 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y)); 784 && (f = XFRAME (w->frame),
786 HDC hdc = get_frame_dc (f); 785 width = FRAME_INTERNAL_BORDER_WIDTH (f),
787 786 width != 0)
788 w32_clear_area (f, hdc, x, y, width, height); 787 && (height = desired_row->visible_height,
789 release_frame_dc (f, hdc); 788 height > 0))
790 } 789 {
791 790 int y = WINDOW_TO_FRAME_PIXEL_Y (w, max (0, desired_row->y));
791 /* Internal border is drawn below the tool bar. */
792 if (WINDOWP (f->tool_bar_window)
793 && w == XWINDOW (f->tool_bar_window))
794 y -= width;
795
796 BLOCK_INPUT;
797 {
798 HDC hdc = get_frame_dc (f);
799 w32_clear_area (f, hdc, 0, y, width, height);
800 w32_clear_area (f, hdc, f->output_data.w32->pixel_width - width,
801 y, width, height);
802 release_frame_dc (f, hdc);
803 }
792 UNBLOCK_INPUT; 804 UNBLOCK_INPUT;
793 } 805 }
794 } 806 }
795 807
796 808
2740 struct glyph_row *, 2752 struct glyph_row *,
2741 enum glyph_row_area, int, 2753 enum glyph_row_area, int,
2742 enum draw_glyphs_face)); 2754 enum draw_glyphs_face));
2743 static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *, 2755 static int x_draw_glyphs P_ ((struct window *, int , struct glyph_row *,
2744 enum glyph_row_area, int, int, 2756 enum glyph_row_area, int, int,
2745 enum draw_glyphs_face, int *, int *, int)); 2757 enum draw_glyphs_face, int));
2746 static void x_set_glyph_string_clipping P_ ((struct glyph_string *)); 2758 static void x_set_glyph_string_clipping P_ ((struct glyph_string *));
2747 static void x_set_glyph_string_gc P_ ((struct glyph_string *)); 2759 static void x_set_glyph_string_gc P_ ((struct glyph_string *));
2748 static void x_draw_glyph_string_background P_ ((struct glyph_string *, 2760 static void x_draw_glyph_string_background P_ ((struct glyph_string *,
2749 int)); 2761 int));
2750 static void x_draw_glyph_string_foreground P_ ((struct glyph_string *)); 2762 static void x_draw_glyph_string_foreground P_ ((struct glyph_string *));
3617 struct w32_output *di = s->f->output_data.w32; 3629 struct w32_output *di = s->f->output_data.w32;
3618 COLORREF color; 3630 COLORREF color;
3619 3631
3620 if (s->face->use_box_color_for_shadows_p) 3632 if (s->face->use_box_color_for_shadows_p)
3621 color = s->face->box_color; 3633 color = s->face->box_color;
3634 else if (s->first_glyph->type == IMAGE_GLYPH
3635 && !IMAGE_BACKGROUND_TRANSPARENT (s->img, s->f, 0))
3636 color = IMAGE_BACKGROUND (s->img, s->f, 0);
3622 else 3637 else
3623 color = s->gc->background; 3638 color = s->gc->background;
3624 3639
3625 if (di->white_relief.gc == 0 3640 if (di->white_relief.gc == 0
3626 || color != di->relief_background) 3641 || color != di->relief_background)
3662 3677
3663 /* Top. */ 3678 /* Top. */
3664 for (i = 0; i < width; ++i) 3679 for (i = 0; i < width; ++i)
3665 w32_fill_area (f, hdc, gc.foreground, 3680 w32_fill_area (f, hdc, gc.foreground,
3666 left_x + i * left_p, top_y + i, 3681 left_x + i * left_p, top_y + i,
3667 (right_x + 1 - i * right_p) - (left_x + i * left_p), 1); 3682 (right_x + 1 - i * right_p) - (left_x + i * left_p) + 1, 1);
3668 3683
3669 /* Left. */ 3684 /* Left. */
3670 if (left_p) 3685 if (left_p)
3671 for (i = 0; i < width; ++i) 3686 for (i = 0; i < width; ++i)
3672 w32_fill_area (f, hdc, gc.foreground, 3687 w32_fill_area (f, hdc, gc.foreground,
3673 left_x + i, top_y + i, 1, 3688 left_x + i, top_y + i, 1,
3674 (bottom_y - i + 1) - (top_y + i)); 3689 (bottom_y - i) - (top_y + i) + 2);
3675 3690
3676 if (raised_p) 3691 if (raised_p)
3677 gc.foreground = f->output_data.w32->black_relief.gc->foreground; 3692 gc.foreground = f->output_data.w32->black_relief.gc->foreground;
3678 else 3693 else
3679 gc.foreground = f->output_data.w32->white_relief.gc->foreground; 3694 gc.foreground = f->output_data.w32->white_relief.gc->foreground;
3680 3695
3681 /* Bottom. */ 3696 /* Bottom. */
3682 for (i = 0; i < width; ++i) 3697 for (i = 0; i < width; ++i)
3683 w32_fill_area (f, hdc, gc.foreground, 3698 w32_fill_area (f, hdc, gc.foreground,
3684 left_x + i * left_p, bottom_y - i, 3699 left_x + i * left_p, bottom_y - i,
3685 (right_x + 2 - i * right_p) - (left_x + i * left_p), 1); 3700 (right_x - i * right_p) - (left_x + i * left_p) + 2, 1);
3686 3701
3687 /* Right. */ 3702 /* Right. */
3688 if (right_p) 3703 if (right_p)
3689 for (i = 0; i < width; ++i) 3704 for (i = 0; i < width; ++i)
3690 w32_fill_area (f, hdc, gc.foreground, 3705 w32_fill_area (f, hdc, gc.foreground,
3691 right_x - i, top_y + i + 1, 1, 3706 right_x - i, top_y + i + 1, 1,
3692 (bottom_y - i) - (top_y + i + 1)); 3707 (bottom_y - i) - (top_y + i));
3693 3708
3694 w32_set_clip_rectangle (hdc, NULL); 3709 w32_set_clip_rectangle (hdc, NULL);
3695 3710
3696 release_frame_dc (f, hdc); 3711 release_frame_dc (f, hdc);
3697 } 3712 }
3921 y += s->img->vmargin; 3936 y += s->img->vmargin;
3922 3937
3923 if (s->hl == DRAW_IMAGE_SUNKEN 3938 if (s->hl == DRAW_IMAGE_SUNKEN
3924 || s->hl == DRAW_IMAGE_RAISED) 3939 || s->hl == DRAW_IMAGE_RAISED)
3925 { 3940 {
3926 thick = tool_bar_button_relief > 0 ? tool_bar_button_relief : 3; 3941 thick = tool_bar_button_relief >= 0 ? tool_bar_button_relief : 3;
3927 raised_p = s->hl == DRAW_IMAGE_RAISED; 3942 raised_p = s->hl == DRAW_IMAGE_RAISED;
3928 } 3943 }
3929 else 3944 else
3930 { 3945 {
3931 thick = abs (s->img->relief); 3946 thick = abs (s->img->relief);
4645 && ((s->hl == DRAW_NORMAL_TEXT 4660 && ((s->hl == DRAW_NORMAL_TEXT
4646 && (s->row->fill_line_p 4661 && (s->row->fill_line_p
4647 || s->face->background != default_face->background 4662 || s->face->background != default_face->background
4648 || s->face->stipple != default_face->stipple 4663 || s->face->stipple != default_face->stipple
4649 || s->row->mouse_face_p)) 4664 || s->row->mouse_face_p))
4650 || s->hl == DRAW_MOUSE_FACE)) 4665 || s->hl == DRAW_MOUSE_FACE
4666 || ((s->hl == DRAW_IMAGE_RAISED || s->hl == DRAW_IMAGE_SUNKEN)
4667 && s->row->fill_line_p)))
4651 s->extends_to_end_of_line_p = 1; 4668 s->extends_to_end_of_line_p = 1;
4652 4669
4653 /* If S extends its face to the end of the line, set its 4670 /* If S extends its face to the end of the line, set its
4654 background_width to the distance to the right edge of the drawing 4671 background_width to the distance to the right edge of the drawing
4655 area. */ 4672 area. */
4847 DRAW_MOUSE_FACE draw in mouse face. 4864 DRAW_MOUSE_FACE draw in mouse face.
4848 DRAW_INVERSE_VIDEO draw in mode line face 4865 DRAW_INVERSE_VIDEO draw in mode line face
4849 DRAW_IMAGE_SUNKEN draw an image with a sunken relief around it 4866 DRAW_IMAGE_SUNKEN draw an image with a sunken relief around it
4850 DRAW_IMAGE_RAISED draw an image with a raised relief around it 4867 DRAW_IMAGE_RAISED draw an image with a raised relief around it
4851 4868
4852 If REAL_START is non-null, return in *REAL_START the real starting
4853 position for display. This can be different from START in case
4854 overlapping glyphs must be displayed. If REAL_END is non-null,
4855 return in *REAL_END the real end position for display. This can be
4856 different from END in case overlapping glyphs must be displayed.
4857
4858 If OVERLAPS_P is non-zero, draw only the foreground of characters 4869 If OVERLAPS_P is non-zero, draw only the foreground of characters
4859 and clip to the physical height of ROW. 4870 and clip to the physical height of ROW.
4860 4871
4861 Value is the x-position reached, relative to AREA of W. */ 4872 Value is the x-position reached, relative to AREA of W. */
4862 4873
4863 static int 4874 static int
4864 x_draw_glyphs (w, x, row, area, start, end, hl, real_start, real_end, 4875 x_draw_glyphs (w, x, row, area, start, end, hl, overlaps_p)
4865 overlaps_p)
4866 struct window *w; 4876 struct window *w;
4867 int x; 4877 int x;
4868 struct glyph_row *row; 4878 struct glyph_row *row;
4869 enum glyph_row_area area; 4879 enum glyph_row_area area;
4870 int start, end; 4880 int start, end;
4871 enum draw_glyphs_face hl; 4881 enum draw_glyphs_face hl;
4872 int *real_start, *real_end;
4873 int overlaps_p; 4882 int overlaps_p;
4874 { 4883 {
4875 struct glyph_string *head, *tail; 4884 struct glyph_string *head, *tail;
4876 struct glyph_string *s; 4885 struct glyph_string *s;
4877 int last_x, area_width; 4886 int last_x, area_width;
4881 4890
4882 /* Let's rather be paranoid than getting a SEGV. */ 4891 /* Let's rather be paranoid than getting a SEGV. */
4883 end = min (end, row->used[area]); 4892 end = min (end, row->used[area]);
4884 start = max (0, start); 4893 start = max (0, start);
4885 start = min (end, start); 4894 start = min (end, start);
4886 if (real_start)
4887 *real_start = start;
4888 if (real_end)
4889 *real_end = end;
4890 4895
4891 /* Translate X to frame coordinates. Set last_x to the right 4896 /* Translate X to frame coordinates. Set last_x to the right
4892 end of the drawing area. */ 4897 end of the drawing area. */
4893 if (row->full_width_p) 4898 if (row->full_width_p)
4894 { 4899 {
4956 j = i; 4961 j = i;
4957 BUILD_GLYPH_STRINGS (hdc, w, row, area, j, start, h, t, 4962 BUILD_GLYPH_STRINGS (hdc, w, row, area, j, start, h, t,
4958 DRAW_NORMAL_TEXT, dummy_x, last_x, 4963 DRAW_NORMAL_TEXT, dummy_x, last_x,
4959 overlaps_p); 4964 overlaps_p);
4960 start = i; 4965 start = i;
4961 if (real_start)
4962 *real_start = start;
4963 x_compute_overhangs_and_x (t, head->x, 1); 4966 x_compute_overhangs_and_x (t, head->x, 1);
4964 x_prepend_glyph_string_lists (&head, &tail, h, t); 4967 x_prepend_glyph_string_lists (&head, &tail, h, t);
4965 } 4968 }
4966 4969
4967 /* Prepend glyph strings for glyphs in front of the first glyph 4970 /* Prepend glyph strings for glyphs in front of the first glyph
4977 BUILD_GLYPH_STRINGS (hdc, w, row, area, i, start, h, t, 4980 BUILD_GLYPH_STRINGS (hdc, w, row, area, i, start, h, t,
4978 DRAW_NORMAL_TEXT, dummy_x, last_x, 4981 DRAW_NORMAL_TEXT, dummy_x, last_x,
4979 overlaps_p); 4982 overlaps_p);
4980 for (s = h; s; s = s->next) 4983 for (s = h; s; s = s->next)
4981 s->background_filled_p = 1; 4984 s->background_filled_p = 1;
4982 if (real_start)
4983 *real_start = i;
4984 x_compute_overhangs_and_x (t, head->x, 1); 4985 x_compute_overhangs_and_x (t, head->x, 1);
4985 x_prepend_glyph_string_lists (&head, &tail, h, t); 4986 x_prepend_glyph_string_lists (&head, &tail, h, t);
4986 } 4987 }
4987 4988
4988 /* Append glyphs strings for glyphs following the last glyph 4989 /* Append glyphs strings for glyphs following the last glyph
4995 BUILD_GLYPH_STRINGS (hdc, w, row, area, end, i, h, t, 4996 BUILD_GLYPH_STRINGS (hdc, w, row, area, end, i, h, t,
4996 DRAW_NORMAL_TEXT, x, last_x, 4997 DRAW_NORMAL_TEXT, x, last_x,
4997 overlaps_p); 4998 overlaps_p);
4998 x_compute_overhangs_and_x (h, tail->x + tail->width, 0); 4999 x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
4999 x_append_glyph_string_lists (&head, &tail, h, t); 5000 x_append_glyph_string_lists (&head, &tail, h, t);
5000 if (real_end)
5001 *real_end = i;
5002 } 5001 }
5003 5002
5004 /* Append glyph strings for glyphs following the last glyph 5003 /* Append glyph strings for glyphs following the last glyph
5005 string tail that overwrite tail. The foreground of such 5004 string tail that overwrite tail. The foreground of such
5006 glyphs has to be drawn because it writes into the background 5005 glyphs has to be drawn because it writes into the background
5014 overlaps_p); 5013 overlaps_p);
5015 for (s = h; s; s = s->next) 5014 for (s = h; s; s = s->next)
5016 s->background_filled_p = 1; 5015 s->background_filled_p = 1;
5017 x_compute_overhangs_and_x (h, tail->x + tail->width, 0); 5016 x_compute_overhangs_and_x (h, tail->x + tail->width, 0);
5018 x_append_glyph_string_lists (&head, &tail, h, t); 5017 x_append_glyph_string_lists (&head, &tail, h, t);
5019 if (real_end)
5020 *real_end = i;
5021 } 5018 }
5022 } 5019 }
5023 5020
5024 /* Draw all strings. */ 5021 /* Draw all strings. */
5025 for (s = head; s; s = s->next) 5022 for (s = head; s; s = s->next)
5026 x_draw_glyph_string (s); 5023 x_draw_glyph_string (s);
5024
5025 if (area == TEXT_AREA && !row->full_width_p)
5026 {
5027 int x0 = head ? head->x : x;
5028 int x1 = tail ? tail->x + tail->background_width : x;
5029
5030 x0 = FRAME_TO_WINDOW_PIXEL_X (w, x0);
5031 x1 = FRAME_TO_WINDOW_PIXEL_X (w, x1);
5032
5033 if (!row->full_width_p && XFASTINT (w->left_margin_width) != 0)
5034 {
5035 int left_area_width = window_box_width (w, LEFT_MARGIN_AREA);
5036 x0 -= left_area_width;
5037 x1 -= left_area_width;
5038 }
5039
5040 notice_overwritten_cursor (w, x0, x1);
5041 }
5027 5042
5028 /* Value is the x-position up to which drawn, relative to AREA of W. 5043 /* Value is the x-position up to which drawn, relative to AREA of W.
5029 This doesn't include parts drawn because of overhangs. */ 5044 This doesn't include parts drawn because of overhangs. */
5030 x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached); 5045 x_reached = FRAME_TO_WINDOW_PIXEL_X (w, x_reached);
5031 if (!row->full_width_p) 5046 if (!row->full_width_p)
5075 } 5090 }
5076 while (i < row->used[area] 5091 while (i < row->used[area]
5077 && row->glyphs[area][i].overlaps_vertically_p); 5092 && row->glyphs[area][i].overlaps_vertically_p);
5078 5093
5079 x_draw_glyphs (w, start_x, row, area, start, i, 5094 x_draw_glyphs (w, start_x, row, area, start, i,
5080 DRAW_NORMAL_TEXT, 5095 DRAW_NORMAL_TEXT, 1);
5081 NULL, NULL, 1);
5082 } 5096 }
5083 else 5097 else
5084 { 5098 {
5085 x += row->glyphs[area][i].pixel_width; 5099 x += row->glyphs[area][i].pixel_width;
5086 ++i; 5100 ++i;
5100 static void 5114 static void
5101 x_write_glyphs (start, len) 5115 x_write_glyphs (start, len)
5102 struct glyph *start; 5116 struct glyph *start;
5103 int len; 5117 int len;
5104 { 5118 {
5105 int x, hpos, real_start, real_end; 5119 int x, hpos;
5106 5120
5107 xassert (updated_window && updated_row); 5121 xassert (updated_window && updated_row);
5108 BLOCK_INPUT; 5122 BLOCK_INPUT;
5109 5123
5110 /* Write glyphs. */ 5124 /* Write glyphs. */
5111 5125
5112 hpos = start - updated_row->glyphs[updated_area]; 5126 hpos = start - updated_row->glyphs[updated_area];
5113 x = x_draw_glyphs (updated_window, output_cursor.x, 5127 x = x_draw_glyphs (updated_window, output_cursor.x,
5114 updated_row, updated_area, 5128 updated_row, updated_area,
5115 hpos, hpos + len, 5129 hpos, hpos + len,
5116 DRAW_NORMAL_TEXT, 5130 DRAW_NORMAL_TEXT, 0);
5117 &real_start, &real_end, 0);
5118
5119 /* If we drew over the cursor, note that it is not visible any more. */
5120 note_overwritten_text_cursor (updated_window, real_start,
5121 real_end - real_start);
5122 5131
5123 UNBLOCK_INPUT; 5132 UNBLOCK_INPUT;
5124 5133
5125 /* Advance the output cursor. */ 5134 /* Advance the output cursor. */
5126 output_cursor.hpos += len; 5135 output_cursor.hpos += len;
5138 struct frame *f; 5147 struct frame *f;
5139 struct window *w; 5148 struct window *w;
5140 int line_height, shift_by_width, shifted_region_width; 5149 int line_height, shift_by_width, shifted_region_width;
5141 struct glyph_row *row; 5150 struct glyph_row *row;
5142 struct glyph *glyph; 5151 struct glyph *glyph;
5143 int frame_x, frame_y, hpos, real_start, real_end; 5152 int frame_x, frame_y, hpos;
5144 HDC hdc; 5153 HDC hdc;
5145 5154
5146 xassert (updated_window && updated_row); 5155 xassert (updated_window && updated_row);
5147 BLOCK_INPUT; 5156 BLOCK_INPUT;
5148 w = updated_window; 5157 w = updated_window;
5171 hdc, frame_x, frame_y, SRCCOPY); 5180 hdc, frame_x, frame_y, SRCCOPY);
5172 5181
5173 /* Write the glyphs. */ 5182 /* Write the glyphs. */
5174 hpos = start - row->glyphs[updated_area]; 5183 hpos = start - row->glyphs[updated_area];
5175 x_draw_glyphs (w, output_cursor.x, row, updated_area, hpos, hpos + len, 5184 x_draw_glyphs (w, output_cursor.x, row, updated_area, hpos, hpos + len,
5176 DRAW_NORMAL_TEXT, &real_start, &real_end, 0); 5185 DRAW_NORMAL_TEXT, 0);
5177 note_overwritten_text_cursor (w, real_start, real_end - real_start); 5186
5178
5179 /* Advance the output cursor. */ 5187 /* Advance the output cursor. */
5180 output_cursor.hpos += len; 5188 output_cursor.hpos += len;
5181 output_cursor.x += shift_by_width; 5189 output_cursor.x += shift_by_width;
5182 release_frame_dc (f, hdc); 5190 release_frame_dc (f, hdc);
5183 5191
5247 5255
5248 to_y = min (max_y, output_cursor.y + updated_row->height); 5256 to_y = min (max_y, output_cursor.y + updated_row->height);
5249 5257
5250 /* Notice if the cursor will be cleared by this operation. */ 5258 /* Notice if the cursor will be cleared by this operation. */
5251 if (!updated_row->full_width_p) 5259 if (!updated_row->full_width_p)
5252 note_overwritten_text_cursor (w, output_cursor.hpos, -1); 5260 notice_overwritten_cursor (w, output_cursor.x, -1);
5253 5261
5254 from_x = output_cursor.x; 5262 from_x = output_cursor.x;
5255 5263
5256 /* Translate to frame coordinates. */ 5264 /* Translate to frame coordinates. */
5257 if (updated_row->full_width_p) 5265 if (updated_row->full_width_p)
5573 5581
5574 if (area == TEXT_AREA && row->fill_line_p) 5582 if (area == TEXT_AREA && row->fill_line_p)
5575 /* If row extends face to end of line write the whole line. */ 5583 /* If row extends face to end of line write the whole line. */
5576 x_draw_glyphs (w, 0, row, area, 5584 x_draw_glyphs (w, 0, row, area,
5577 0, row->used[area], 5585 0, row->used[area],
5578 DRAW_NORMAL_TEXT, 5586 DRAW_NORMAL_TEXT, 0);
5579 NULL, NULL, 0);
5580 else 5587 else
5581 { 5588 {
5582 /* Set START_X to the window-relative start position for drawing glyphs of 5589 /* Set START_X to the window-relative start position for drawing glyphs of
5583 AREA. The first glyph of the text area can be partially visible. 5590 AREA. The first glyph of the text area can be partially visible.
5584 The first glyphs of other areas cannot. */ 5591 The first glyphs of other areas cannot. */
5612 /* Repaint. */ 5619 /* Repaint. */
5613 if (last > first) 5620 if (last > first)
5614 x_draw_glyphs (w, first_x - start_x, row, area, 5621 x_draw_glyphs (w, first_x - start_x, row, area,
5615 first - row->glyphs[area], 5622 first - row->glyphs[area],
5616 last - row->glyphs[area], 5623 last - row->glyphs[area],
5617 DRAW_NORMAL_TEXT, 5624 DRAW_NORMAL_TEXT, 0);
5618 NULL, NULL, 0);
5619 } 5625 }
5620 } 5626 }
5621 5627
5622 5628
5623 /* Redraw the parts of the glyph row ROW on window W intersecting 5629 /* Redraw the parts of the glyph row ROW on window W intersecting
5632 { 5638 {
5633 xassert (row->enabled_p); 5639 xassert (row->enabled_p);
5634 5640
5635 if (row->mode_line_p || w->pseudo_window_p) 5641 if (row->mode_line_p || w->pseudo_window_p)
5636 x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA], 5642 x_draw_glyphs (w, 0, row, TEXT_AREA, 0, row->used[TEXT_AREA],
5637 DRAW_NORMAL_TEXT, NULL, NULL, 0); 5643 DRAW_NORMAL_TEXT, 0);
5638 else 5644 else
5639 { 5645 {
5640 if (row->used[LEFT_MARGIN_AREA]) 5646 if (row->used[LEFT_MARGIN_AREA])
5641 expose_area (w, row, r, LEFT_MARGIN_AREA); 5647 expose_area (w, row, r, LEFT_MARGIN_AREA);
5642 if (row->used[TEXT_AREA]) 5648 if (row->used[TEXT_AREA])
6736 &overlay); 6742 &overlay);
6737 if (!NILP (mouse_face) && !NILP (overlay)) 6743 if (!NILP (mouse_face) && !NILP (overlay))
6738 { 6744 {
6739 Lisp_Object before = Foverlay_start (overlay); 6745 Lisp_Object before = Foverlay_start (overlay);
6740 Lisp_Object after = Foverlay_end (overlay); 6746 Lisp_Object after = Foverlay_end (overlay);
6741 Lisp_Object ignore; 6747 int ignore;
6742 6748
6743 /* Note that we might not be able to find position 6749 /* Note that we might not be able to find position
6744 BEFORE in the glyph matrix if the overlay is 6750 BEFORE in the glyph matrix if the overlay is
6745 entirely covered by a `display' property. In 6751 entirely covered by a `display' property. In
6746 this case, we overshoot. So let's stop in 6752 this case, we overshoot. So let's stop in
7342 struct w32_display_info *dpyinfo; 7348 struct w32_display_info *dpyinfo;
7343 enum draw_glyphs_face draw; 7349 enum draw_glyphs_face draw;
7344 { 7350 {
7345 struct window *w = XWINDOW (dpyinfo->mouse_face_window); 7351 struct window *w = XWINDOW (dpyinfo->mouse_face_window);
7346 struct frame *f = XFRAME (WINDOW_FRAME (w)); 7352 struct frame *f = XFRAME (WINDOW_FRAME (w));
7347 int i;
7348 int cursor_off_p = 0;
7349 struct cursor_pos saved_cursor;
7350
7351 saved_cursor = output_cursor;
7352 7353
7353 /* If window is in the process of being destroyed, don't bother 7354 if (/* If window is in the process of being destroyed, don't bother
7354 to do anything. */ 7355 to do anything. */
7355 if (w->current_matrix == NULL) 7356 w->current_matrix != NULL
7356 goto set_x_cursor; 7357 /* Recognize when we are called to operate on rows that don't exist
7357 7358 anymore. This can happen when a window is split. */
7358 /* Recognize when we are called to operate on rows that don't exist 7359 && dpyinfo->mouse_face_end_row < w->current_matrix->nrows)
7359 anymore. This can happen when a window is split. */ 7360 {
7360 if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows) 7361 int phys_cursor_on_p = w->phys_cursor_on_p;
7361 goto set_x_cursor; 7362 struct glyph_row *row, *first, *last;
7362 7363
7363 set_output_cursor (&w->phys_cursor); 7364 first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row);
7364 7365 last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row);
7365 /* Note that mouse_face_beg_row etc. are window relative. */ 7366
7366 for (i = dpyinfo->mouse_face_beg_row; 7367 for (row = first; row <= last && row->enabled_p; ++row)
7367 i <= dpyinfo->mouse_face_end_row;
7368 i++)
7369 {
7370 int start_hpos, end_hpos, start_x;
7371 struct glyph_row *row = MATRIX_ROW (w->current_matrix, i);
7372
7373 /* Don't do anything if row doesn't have valid contents. */
7374 if (!row->enabled_p)
7375 continue;
7376
7377 /* For all but the first row, the highlight starts at column 0. */
7378 if (i == dpyinfo->mouse_face_beg_row)
7379 { 7368 {
7380 start_hpos = dpyinfo->mouse_face_beg_col; 7369 int start_hpos, end_hpos, start_x;
7381 start_x = dpyinfo->mouse_face_beg_x; 7370
7371 /* For all but the first row, the highlight starts at column 0. */
7372 if (row == first)
7373 {
7374 start_hpos = dpyinfo->mouse_face_beg_col;
7375 start_x = dpyinfo->mouse_face_beg_x;
7376 }
7377 else
7378 {
7379 start_hpos = 0;
7380 start_x = 0;
7381 }
7382
7383 if (row == last)
7384 end_hpos = dpyinfo->mouse_face_end_col;
7385 else
7386 end_hpos = row->used[TEXT_AREA];
7387
7388 if (end_hpos > start_hpos)
7389 {
7390 x_draw_glyphs (w, start_x, row, TEXT_AREA,
7391 start_hpos, end_hpos, draw, 0);
7392
7393 row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED;
7394 }
7382 } 7395 }
7383 else 7396
7384 { 7397 /* When we've written over the cursor, arrange for it to
7385 start_hpos = 0; 7398 be displayed again. */
7386 start_x = 0; 7399 if (phys_cursor_on_p && !w->phys_cursor_on_p)
7387 } 7400 x_display_cursor (w, 1,
7388 7401 w->phys_cursor.hpos, w->phys_cursor.vpos,
7389 if (i == dpyinfo->mouse_face_end_row) 7402 w->phys_cursor.x, w->phys_cursor.y);
7390 end_hpos = dpyinfo->mouse_face_end_col; 7403 }
7391 else 7404
7392 end_hpos = row->used[TEXT_AREA];
7393
7394 /* If the cursor's in the text we are about to rewrite, turn the
7395 cursor off. */
7396 if (!w->pseudo_window_p
7397 && i == output_cursor.vpos
7398 && output_cursor.hpos >= start_hpos - 1
7399 && output_cursor.hpos <= end_hpos)
7400 {
7401 x_update_window_cursor (w, 0);
7402 cursor_off_p = 1;
7403 }
7404
7405 if (end_hpos > start_hpos)
7406 {
7407 x_draw_glyphs (w, start_x, row, TEXT_AREA,
7408 start_hpos, end_hpos, draw, NULL, NULL, 0);
7409 row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED;
7410 }
7411 }
7412
7413 /* If we turned the cursor off, turn it back on. */
7414 if (cursor_off_p)
7415 x_display_cursor (w, 1,
7416 output_cursor.hpos, output_cursor.vpos,
7417 output_cursor.x, output_cursor.y);
7418
7419 output_cursor = saved_cursor;
7420
7421 set_x_cursor:
7422 #if 0 /* TODO: mouse cursor */ 7405 #if 0 /* TODO: mouse cursor */
7423 /* Change the mouse cursor. */ 7406 /* Change the mouse cursor. */
7424 if (draw == DRAW_NORMAL_TEXT) 7407 if (draw == DRAW_NORMAL_TEXT)
7425 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7408 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
7426 f->output_data.x->text_cursor); 7409 f->output_data.x->text_cursor);
7429 f->output_data.x->cross_cursor); 7412 f->output_data.x->cross_cursor);
7430 else 7413 else
7431 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), 7414 XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f),
7432 f->output_data.x->nontext_cursor); 7415 f->output_data.x->nontext_cursor);
7433 #endif 7416 #endif
7434 ;
7435 } 7417 }
7436 7418
7437 /* Clear out the mouse-highlighted active region. 7419 /* Clear out the mouse-highlighted active region.
7438 Redraw it un-highlighted first. */ 7420 Redraw it un-highlighted first. */
7439 7421
7519 if (!NILP (window)) 7501 if (!NILP (window))
7520 { 7502 {
7521 struct window *w = XWINDOW (window); 7503 struct window *w = XWINDOW (window);
7522 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix); 7504 struct glyph_row *r = MATRIX_FIRST_TEXT_ROW (w->current_matrix);
7523 struct glyph_row *end = r + w->current_matrix->nrows - 1; 7505 struct glyph_row *end = r + w->current_matrix->nrows - 1;
7524 int area;
7525 7506
7526 frame_to_window_pixel_xy (w, &x, &y); 7507 frame_to_window_pixel_xy (w, &x, &y);
7527 7508
7528 for (; !found && r < end && r->enabled_p; ++r) 7509 for (; !found && r < end && r->enabled_p; ++r)
7529 if (r->y + r->height >= y) 7510 if (r->y + r->height >= y)
8002 /* Does the scroll bar exist yet? */ 7983 /* Does the scroll bar exist yet? */
8003 if (NILP (w->vertical_scroll_bar)) 7984 if (NILP (w->vertical_scroll_bar))
8004 { 7985 {
8005 HDC hdc; 7986 HDC hdc;
8006 BLOCK_INPUT; 7987 BLOCK_INPUT;
8007 if (width && height) 7988 if (width > 0 && height > 0)
8008 { 7989 {
8009 hdc = get_frame_dc (f); 7990 hdc = get_frame_dc (f);
8010 w32_clear_area (f, hdc, left, top, width, height); 7991 w32_clear_area (f, hdc, left, top, width, height);
8011 release_frame_dc (f, hdc); 7992 release_frame_dc (f, hdc);
8012 } 7993 }
9150 9131
9151 /*********************************************************************** 9132 /***********************************************************************
9152 Text Cursor 9133 Text Cursor
9153 ***********************************************************************/ 9134 ***********************************************************************/
9154 9135
9155 /* Note if the text cursor of window W has been overwritten by a 9136 /* Notice if the text cursor of window W has been overwritten by a
9156 drawing operation that outputs N glyphs starting at HPOS in the 9137 drawing operation that outputs glyphs starting at START_X and
9157 line given by output_cursor.vpos. N < 0 means all the rest of the 9138 ending at END_X in the line given by output_cursor.vpos.
9158 line after HPOS has been written. */ 9139 Coordinates are area-relative. END_X < 0 means all the rest
9140 of the line after START_X has been written. */
9159 9141
9160 static void 9142 static void
9161 note_overwritten_text_cursor (w, hpos, n) 9143 notice_overwritten_cursor (w, start_x, end_x)
9162 struct window *w; 9144 struct window *w;
9163 int hpos, n; 9145 int start_x, end_x;
9164 { 9146 {
9165 if (updated_area == TEXT_AREA 9147 if (updated_area == TEXT_AREA
9148 && w->phys_cursor_on_p
9166 && output_cursor.vpos == w->phys_cursor.vpos 9149 && output_cursor.vpos == w->phys_cursor.vpos
9167 && hpos <= w->phys_cursor.hpos 9150 && start_x <= w->phys_cursor.x
9168 && (n < 0 9151 && (end_x < 0 || end_x > w->phys_cursor.x))
9169 || hpos + n > w->phys_cursor.hpos))
9170 w->phys_cursor_on_p = 0; 9152 w->phys_cursor_on_p = 0;
9171 } 9153 }
9172 9154
9173 9155
9174 /* Set clipping for output in glyph row ROW. W is the window in which 9156 /* Set clipping for output in glyph row ROW. W is the window in which
9290 row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos); 9272 row = MATRIX_ROW (w->current_matrix, w->phys_cursor.vpos);
9291 x_draw_phys_cursor_glyph (w, row, DRAW_CURSOR); 9273 x_draw_phys_cursor_glyph (w, row, DRAW_CURSOR);
9292 } 9274 }
9293 else 9275 else
9294 { 9276 {
9277 COLORREF cursor_color = f->output_data.w32->cursor_pixel;
9278 struct face *face = FACE_FROM_ID (f, cursor_glyph->face_id);
9279
9295 if (width < 0) 9280 if (width < 0)
9296 width = f->output_data.w32->cursor_width; 9281 width = f->output_data.w32->cursor_width;
9282
9283 /* If the glyph's background equals the color we normally draw
9284 the bar cursor in, the bar cursor in its normal color is
9285 invisible. Use the glyph's foreground color instead in this
9286 case, on the assumption that the glyph's colors are chosen so
9287 that the glyph is legible. */
9288 if (face->background == cursor_color)
9289 cursor_color = face->foreground;
9297 9290
9298 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x); 9291 x = WINDOW_TEXT_TO_FRAME_PIXEL_X (w, w->phys_cursor.x);
9299 hdc = get_frame_dc (f); 9292 hdc = get_frame_dc (f);
9300 w32_clip_to_row (w, row, hdc, 0); 9293 w32_clip_to_row (w, row, hdc, 0);
9301 w32_fill_area (f, hdc, f->output_data.w32->cursor_pixel, 9294 w32_fill_area (f, hdc, cursor_color, x,
9302 x,
9303 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y), 9295 WINDOW_TO_FRAME_PIXEL_Y (w, w->phys_cursor.y),
9304 min (cursor_glyph->pixel_width, width), 9296 min (cursor_glyph->pixel_width, width),
9305 row->height); 9297 row->height);
9306 release_frame_dc (f, hdc); 9298 release_frame_dc (f, hdc);
9307 } 9299 }
9333 /* If cursor hpos is out of bounds, don't draw garbage. This can 9325 /* If cursor hpos is out of bounds, don't draw garbage. This can
9334 happen in mini-buffer windows when switching between echo area 9326 happen in mini-buffer windows when switching between echo area
9335 glyphs and mini-buffer. */ 9327 glyphs and mini-buffer. */
9336 if (w->phys_cursor.hpos < row->used[TEXT_AREA]) 9328 if (w->phys_cursor.hpos < row->used[TEXT_AREA])
9337 { 9329 {
9330 int on_p = w->phys_cursor_on_p;
9338 x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA, 9331 x_draw_glyphs (w, w->phys_cursor.x, row, TEXT_AREA,
9339 w->phys_cursor.hpos, w->phys_cursor.hpos + 1, 9332 w->phys_cursor.hpos, w->phys_cursor.hpos + 1,
9340 hl, 0, 0, 0); 9333 hl, 0);
9334 w->phys_cursor_on_p = on_p;
9341 9335
9342 /* When we erase the cursor, and ROW is overlapped by other 9336 /* When we erase the cursor, and ROW is overlapped by other
9343 rows, make sure that these overlapping parts of other rows 9337 rows, make sure that these overlapping parts of other rows
9344 are redrawn. */ 9338 are redrawn. */
9345 if (hl == DRAW_NORMAL_TEXT && row->overlapped_p) 9339 if (hl == DRAW_NORMAL_TEXT && row->overlapped_p)
9539 { 9533 {
9540 if (w == XWINDOW (echo_area_window)) 9534 if (w == XWINDOW (echo_area_window))
9541 new_cursor_type = FRAME_DESIRED_CURSOR (f); 9535 new_cursor_type = FRAME_DESIRED_CURSOR (f);
9542 else 9536 else
9543 { 9537 {
9544 new_cursor_type = HOLLOW_BOX_CURSOR; 9538 if (cursor_non_selected)
9539 new_cursor_type = HOLLOW_BOX_CURSOR;
9540 else
9541 new_cursor_type = NO_CURSOR;
9545 active_cursor = 0; 9542 active_cursor = 0;
9546 } 9543 }
9547 } 9544 }
9548 else 9545 else
9549 { 9546 {