comparison src/redisplay-x.c @ 183:e121b013d1f0 r20-3b18

Import from CVS: tag r20-3b18
author cvs
date Mon, 13 Aug 2007 09:54:23 +0200
parents 8eaf7971accc
children 3d6bfa290dbd
comparison
equal deleted inserted replaced
182:f07455f06202 183:e121b013d1f0
91 static void x_bevel_modeline (struct window *w, struct display_line *dl); 91 static void x_bevel_modeline (struct window *w, struct display_line *dl);
92 92
93 93
94 /* Note: We do not use the Xmb*() functions and XFontSets. 94 /* Note: We do not use the Xmb*() functions and XFontSets.
95 Those functions are generally losing for a number of reasons: 95 Those functions are generally losing for a number of reasons:
96 96
97 1) They only support one locale (e.g. you could display 97 1) They only support one locale (e.g. you could display
98 Japanese and ASCII text, but not mixed Japanese/Chinese 98 Japanese and ASCII text, but not mixed Japanese/Chinese
99 text). You could maybe call setlocale() frequently 99 text). You could maybe call setlocale() frequently
100 to try to deal with this, but that would generally 100 to try to deal with this, but that would generally
101 fail because an XFontSet is tied to one locale and 101 fail because an XFontSet is tied to one locale and
167 if (!EQ (charset, prev_charset)) 167 if (!EQ (charset, prev_charset))
168 { 168 {
169 run_storage[runs_so_far].ptr = text_storage; 169 run_storage[runs_so_far].ptr = text_storage;
170 run_storage[runs_so_far].charset = charset; 170 run_storage[runs_so_far].charset = charset;
171 run_storage[runs_so_far].dimension = dimension; 171 run_storage[runs_so_far].dimension = dimension;
172 172
173 if (runs_so_far) 173 if (runs_so_far)
174 { 174 {
175 run_storage[runs_so_far - 1].len = 175 run_storage[runs_so_far - 1].len =
176 text_storage - run_storage[runs_so_far - 1].ptr; 176 text_storage - run_storage[runs_so_far - 1].ptr;
177 if (run_storage[runs_so_far - 1].dimension == 2) 177 if (run_storage[runs_so_far - 1].dimension == 2)
265 unsigned char *text_storage = (unsigned char *) alloca (2 * len); 265 unsigned char *text_storage = (unsigned char *) alloca (2 * len);
266 struct textual_run *runs = 266 struct textual_run *runs =
267 (struct textual_run *) alloca (len * sizeof (struct textual_run)); 267 (struct textual_run *) alloca (len * sizeof (struct textual_run));
268 int nruns; 268 int nruns;
269 int i; 269 int i;
270 270
271 nruns = separate_textual_runs (text_storage, runs, str, len); 271 nruns = separate_textual_runs (text_storage, runs, str, len);
272 272
273 for (i = 0; i < nruns; i++) 273 for (i = 0; i < nruns; i++)
274 width_so_far += x_text_width_single_run (cachel, runs + i); 274 width_so_far += x_text_width_single_run (cachel, runs + i);
275 275
446 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE) 446 else if (rb->type == RUNE_BLANK || rb->type == RUNE_HLINE)
447 { 447 {
448 if (rb->type == RUNE_BLANK) 448 if (rb->type == RUNE_BLANK)
449 x_output_blank (w, dl, rb, start_pixpos, cursor_start, 449 x_output_blank (w, dl, rb, start_pixpos, cursor_start,
450 cursor_width); 450 cursor_width);
451 else 451 else
452 { 452 {
453 /* #### Our flagging of when we need to redraw the 453 /* #### Our flagging of when we need to redraw the
454 modeline shadows sucks. Since RUNE_HLINE is only used 454 modeline shadows sucks. Since RUNE_HLINE is only used
455 by the modeline at the moment it is a good bet 455 by the modeline at the moment it is a good bet
456 that if it gets redrawn then we should also 456 that if it gets redrawn then we should also
488 add_glyph_rune(). */ 488 add_glyph_rune(). */
489 Lisp_Object string = 489 Lisp_Object string =
490 XIMAGE_INSTANCE_TEXT_STRING (instance); 490 XIMAGE_INSTANCE_TEXT_STRING (instance);
491 convert_bufbyte_string_into_emchar_dynarr 491 convert_bufbyte_string_into_emchar_dynarr
492 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf); 492 (XSTRING_DATA (string), XSTRING_LENGTH (string), buf);
493 493
494 x_output_string (w, dl, buf, xpos, 494 x_output_string (w, dl, buf, xpos,
495 rb->object.dglyph.xoffset, 495 rb->object.dglyph.xoffset,
496 start_pixpos, -1, findex, 496 start_pixpos, -1, findex,
497 (rb->cursor_type == CURSOR_ON), 497 (rb->cursor_type == CURSOR_ON),
498 cursor_start, cursor_width, 498 cursor_start, cursor_width,
509 cursor_width, cursor_height); 509 cursor_width, cursor_height);
510 break; 510 break;
511 511
512 case IMAGE_POINTER: 512 case IMAGE_POINTER:
513 abort (); 513 abort ();
514 514
515 case IMAGE_SUBWINDOW: 515 case IMAGE_SUBWINDOW:
516 /* #### implement me */ 516 /* #### implement me */
517 break; 517 break;
518 518
519 case IMAGE_NOTHING: 519 case IMAGE_NOTHING:
520 /* nothing is as nothing does */ 520 /* nothing is as nothing does */
521 break; 521 break;
522 522
523 default: 523 default:
524 abort (); 524 abort ();
525 } 525 }
526 526
527 xpos += rb->width; 527 xpos += rb->width;
789 Lisp_Object window = Qnil; 789 Lisp_Object window = Qnil;
790 Display *dpy = DEVICE_X_DISPLAY (d); 790 Display *dpy = DEVICE_X_DISPLAY (d);
791 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f)); 791 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
792 792
793 int clip_end; 793 int clip_end;
794 794
795 /* Cursor-related variables */ 795 /* Cursor-related variables */
796 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d)); 796 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
797 int cursor_clip; 797 int cursor_clip;
798 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor, 798 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
799 WINDOW_BUFFER (w)); 799 WINDOW_BUFFER (w));
810 int i; 810 int i;
811 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex); 811 struct face_cachel *cachel = WINDOW_FACE_CACHEL (w, findex);
812 812
813 XSETDEVICE (device, d); 813 XSETDEVICE (device, d);
814 XSETWINDOW (window, w); 814 XSETWINDOW (window, w);
815 815
816 if (width < 0) 816 if (width < 0)
817 width = x_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf)); 817 width = x_text_width (cachel, Dynarr_atp (buf, 0), Dynarr_length (buf));
818 height = dl->ascent + dl->descent - dl->clip; 818 height = dl->ascent + dl->descent - dl->clip;
819 819
820 /* Regularize the variables passed in. */ 820 /* Regularize the variables passed in. */
821 821
822 if (clip_start < xpos) 822 if (clip_start < xpos)
823 clip_start = xpos; 823 clip_start = xpos;
824 clip_end = xpos + width; 824 clip_end = xpos + width;
825 if (clip_start >= clip_end) 825 if (clip_start >= clip_end)
826 /* It's all clipped out. */ 826 /* It's all clipped out. */
827 return; 827 return;
828 828
829 xpos -= xoffset; 829 xpos -= xoffset;
830 830
831 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0), 831 nruns = separate_textual_runs (text_storage, runs, Dynarr_atp (buf, 0),
832 Dynarr_length (buf)); 832 Dynarr_length (buf));
833 833
834 cursor_clip = (cursor_start >= clip_start && 834 cursor_clip = (cursor_start >= clip_start &&
835 cursor_start < clip_end); 835 cursor_start < clip_end);
850 /* We have to reset this since any call to WINDOW_FACE_CACHEL 850 /* We have to reset this since any call to WINDOW_FACE_CACHEL
851 may cause the cache to resize and any pointers to it to 851 may cause the cache to resize and any pointers to it to
852 become invalid. */ 852 become invalid. */
853 cachel = WINDOW_FACE_CACHEL (w, findex); 853 cachel = WINDOW_FACE_CACHEL (w, findex);
854 } 854 }
855 855
856 #ifdef HAVE_XIM 856 #ifdef HAVE_XIM
857 if (cursor && focus && (cursor_start == clip_start) && cursor_height) 857 if (cursor && focus && (cursor_start == clip_start) && cursor_height)
858 XIM_SetSpotLocation (f, xpos - 2, dl->ypos + dl->descent - 2); 858 XIM_SetSpotLocation (f, xpos - 2, dl->ypos + dl->descent - 2);
859 #endif /* HAVE_XIM */ 859 #endif /* HAVE_XIM */
860 860
872 872
873 if (bgc) 873 if (bgc)
874 XFillRectangle (dpy, x_win, bgc, clip_start, 874 XFillRectangle (dpy, x_win, bgc, clip_start,
875 dl->ypos - dl->ascent, clip_end - clip_start, 875 dl->ypos - dl->ascent, clip_end - clip_start,
876 height); 876 height);
877 877
878 for (i = 0; i < nruns; i++) 878 for (i = 0; i < nruns; i++)
879 { 879 {
880 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset); 880 Lisp_Object font = FACE_CACHEL_FONT (cachel, runs[i].charset);
881 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font); 881 struct Lisp_Font_Instance *fi = XFONT_INSTANCE (font);
882 int this_width; 882 int this_width;
895 clear some areas. */ 895 clear some areas. */
896 if ((int) fi->height < (int) (height + dl->clip)) 896 if ((int) fi->height < (int) (height + dl->clip))
897 { 897 {
898 int clear_start = max (xpos, clip_start); 898 int clear_start = max (xpos, clip_start);
899 int clear_end = min (xpos + this_width, clip_end); 899 int clear_end = min (xpos + this_width, clip_end);
900 900
901 if (cursor) 901 if (cursor)
902 { 902 {
903 int ypos1_line, ypos1_string, ypos2_line, ypos2_string; 903 int ypos1_line, ypos1_string, ypos2_line, ypos2_string;
904 904
905 ypos1_string = dl->ypos - fi->ascent; 905 ypos1_string = dl->ypos - fi->ascent;
906 ypos2_string = dl->ypos + fi->descent; 906 ypos2_string = dl->ypos + fi->descent;
907 ypos1_line = dl->ypos - dl->ascent; 907 ypos1_line = dl->ypos - dl->ascent;
908 ypos2_line = dl->ypos + dl->descent - dl->clip; 908 ypos2_line = dl->ypos + dl->descent - dl->clip;
909 909
910 /* Make sure we don't clear below the real bottom of the 910 /* Make sure we don't clear below the real bottom of the
911 line. */ 911 line. */
912 if (ypos1_string > ypos2_line) 912 if (ypos1_string > ypos2_line)
913 ypos1_string = ypos2_line; 913 ypos1_string = ypos2_line;
914 if (ypos2_string > ypos2_line) 914 if (ypos2_string > ypos2_line)
915 ypos2_string = ypos2_line; 915 ypos2_string = ypos2_line;
916 916
917 if (ypos1_line < ypos1_string) 917 if (ypos1_line < ypos1_string)
918 { 918 {
919 x_clear_region (window, findex, clear_start, ypos1_line, 919 x_clear_region (window, findex, clear_start, ypos1_line,
920 clear_end - clear_start, 920 clear_end - clear_start,
921 ypos1_string - ypos1_line); 921 ypos1_string - ypos1_line);
922 } 922 }
923 923
924 if (ypos2_line > ypos2_string) 924 if (ypos2_line > ypos2_string)
925 { 925 {
926 x_clear_region (window, findex, clear_start, ypos2_string, 926 x_clear_region (window, findex, clear_start, ypos2_string,
927 clear_end - clear_start, 927 clear_end - clear_start,
928 ypos2_line - ypos2_string); 928 ypos2_line - ypos2_string);
944 Qnil, Qnil); 944 Qnil, Qnil);
945 945
946 if (need_clipping) 946 if (need_clipping)
947 { 947 {
948 XRectangle clip_box[1]; 948 XRectangle clip_box[1];
949 949
950 clip_box[0].x = 0; 950 clip_box[0].x = 0;
951 clip_box[0].y = 0; 951 clip_box[0].y = 0;
952 clip_box[0].width = clip_end - clip_start; 952 clip_box[0].width = clip_end - clip_start;
953 clip_box[0].height = height; 953 clip_box[0].height = height;
954 954
955 XSetClipRectangles (dpy, gc, clip_start, dl->ypos - dl->ascent, 955 XSetClipRectangles (dpy, gc, clip_start, dl->ypos - dl->ascent,
956 clip_box, 1, Unsorted); 956 clip_box, 1, Unsorted);
957 } 957 }
958 958
959 if (runs[i].dimension == 1) 959 if (runs[i].dimension == 1)
969 /* We draw underlines in the same color as the text. */ 969 /* We draw underlines in the same color as the text. */
970 if (cachel->underline) 970 if (cachel->underline)
971 { 971 {
972 unsigned long upos, uthick; 972 unsigned long upos, uthick;
973 XFontStruct *xfont; 973 XFontStruct *xfont;
974 974
975 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)); 975 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font));
976 if (!XGetFontProperty (xfont, XA_UNDERLINE_POSITION, &upos)) 976 if (!XGetFontProperty (xfont, XA_UNDERLINE_POSITION, &upos))
977 upos = 0; 977 upos = 0;
978 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick)) 978 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick))
979 uthick = 1; 979 uthick = 1;
980 980
981 if (dl->ypos + upos < dl->ypos + dl->descent - dl->clip) 981 if (dl->ypos + upos < dl->ypos + dl->descent - dl->clip)
982 { 982 {
983 if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip) 983 if (dl->ypos + upos + uthick > dl->ypos + dl->descent - dl->clip)
984 uthick = dl->descent - dl->clip - upos; 984 uthick = dl->descent - dl->clip - upos;
985 985
986 if (uthick == 1) 986 if (uthick == 1)
987 { 987 {
988 XDrawLine (dpy, x_win, gc, xpos, dl->ypos + upos, 988 XDrawLine (dpy, x_win, gc, xpos, dl->ypos + upos,
989 xpos + this_width, dl->ypos + upos); 989 xpos + this_width, dl->ypos + upos);
990 } 990 }
993 XFillRectangle (dpy, x_win, gc, xpos, 993 XFillRectangle (dpy, x_win, gc, xpos,
994 dl->ypos + upos, this_width, uthick); 994 dl->ypos + upos, this_width, uthick);
995 } 995 }
996 } 996 }
997 } 997 }
998 998
999 if (cachel->strikethru) { 999 if (cachel->strikethru) {
1000 unsigned long ascent,descent,upos, uthick; 1000 unsigned long ascent,descent,upos, uthick;
1001 XFontStruct *xfont; 1001 XFontStruct *xfont;
1002 1002
1003 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font)); 1003 xfont = FONT_INSTANCE_X_FONT (XFONT_INSTANCE (font));
1004 1004
1005 if (!XGetFontProperty (xfont, XA_STRIKEOUT_ASCENT, &ascent)) 1005 if (!XGetFontProperty (xfont, XA_STRIKEOUT_ASCENT, &ascent))
1006 ascent = xfont->ascent; 1006 ascent = xfont->ascent;
1007 if (!XGetFontProperty (xfont, XA_STRIKEOUT_DESCENT, &descent)) 1007 if (!XGetFontProperty (xfont, XA_STRIKEOUT_DESCENT, &descent))
1008 descent = xfont->descent; 1008 descent = xfont->descent;
1009 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick)) 1009 if (!XGetFontProperty (xfont, XA_UNDERLINE_THICKNESS, &uthick))
1010 uthick = 1; 1010 uthick = 1;
1011 1011
1012 upos = ascent - ((ascent + descent) / 2) + 1; 1012 upos = ascent - ((ascent + descent) / 2) + 1;
1013 1013
1014 /* Generally, upos will be positive (above the baseline),so subtract */ 1014 /* Generally, upos will be positive (above the baseline),so subtract */
1015 if (dl->ypos - upos < dl->ypos + dl->descent - dl->clip) 1015 if (dl->ypos - upos < dl->ypos + dl->descent - dl->clip)
1016 { 1016 {
1017 if (dl->ypos - upos + uthick > dl->ypos + dl->descent - dl->clip) 1017 if (dl->ypos - upos + uthick > dl->ypos + dl->descent - dl->clip)
1018 uthick = dl->descent - dl->clip + upos; 1018 uthick = dl->descent - dl->clip + upos;
1019 1019
1020 if (uthick == 1) 1020 if (uthick == 1)
1021 { 1021 {
1022 XDrawLine (dpy, x_win, gc, xpos, dl->ypos - upos, 1022 XDrawLine (dpy, x_win, gc, xpos, dl->ypos - upos,
1023 xpos + this_width, dl->ypos - upos); 1023 xpos + this_width, dl->ypos - upos);
1024 } 1024 }
1027 XFillRectangle (dpy, x_win, gc, xpos, dl->ypos + upos, 1027 XFillRectangle (dpy, x_win, gc, xpos, dl->ypos + upos,
1028 this_width, uthick); 1028 this_width, uthick);
1029 } 1029 }
1030 } 1030 }
1031 } 1031 }
1032 1032
1033 /* Restore the GC */ 1033 /* Restore the GC */
1034 if (need_clipping) 1034 if (need_clipping)
1035 { 1035 {
1036 XSetClipMask (dpy, gc, None); 1036 XSetClipMask (dpy, gc, None);
1037 XSetClipOrigin (dpy, gc, 0, 0); 1037 XSetClipOrigin (dpy, gc, 0, 0);
1038 } 1038 }
1039 1039
1040 /* If we are actually superimposing the cursor then redraw with just 1040 /* If we are actually superimposing the cursor then redraw with just
1041 the appropriate section highlighted. */ 1041 the appropriate section highlighted. */
1042 if (cursor_clip && !cursor && focus && cursor_cachel) 1042 if (cursor_clip && !cursor && focus && cursor_cachel)
1043 { 1043 {
1044 GC cgc; 1044 GC cgc;
1045 XRectangle clip_box[1]; 1045 XRectangle clip_box[1];
1046 1046
1047 cgc = x_get_gc (d, font, cursor_cachel->foreground, 1047 cgc = x_get_gc (d, font, cursor_cachel->foreground,
1048 cursor_cachel->background, Qnil, Qnil); 1048 cursor_cachel->background, Qnil, Qnil);
1049 1049
1050 clip_box[0].x = 0; 1050 clip_box[0].x = 0;
1051 clip_box[0].y = 0; 1051 clip_box[0].y = 0;
1052 clip_box[0].width = cursor_width; 1052 clip_box[0].width = cursor_width;
1053 clip_box[0].height = height; 1053 clip_box[0].height = height;
1054 1054
1055 XSetClipRectangles (dpy, cgc, cursor_start, dl->ypos - dl->ascent, 1055 XSetClipRectangles (dpy, cgc, cursor_start, dl->ypos - dl->ascent,
1056 clip_box, 1, Unsorted); 1056 clip_box, 1, Unsorted);
1057 1057
1058 if (runs[i].dimension == 1) 1058 if (runs[i].dimension == 1)
1059 XDrawImageString (dpy, x_win, cgc, xpos, dl->ypos, 1059 XDrawImageString (dpy, x_win, cgc, xpos, dl->ypos,
1060 (char *) runs[i].ptr, runs[i].len); 1060 (char *) runs[i].ptr, runs[i].len);
1061 else 1061 else
1062 XDrawImageString16 (dpy, x_win, cgc, xpos, dl->ypos, 1062 XDrawImageString16 (dpy, x_win, cgc, xpos, dl->ypos,
1063 (XChar2b *) runs[i].ptr, runs[i].len); 1063 (XChar2b *) runs[i].ptr, runs[i].len);
1064 1064
1065 XSetClipMask (dpy, cgc, None); 1065 XSetClipMask (dpy, cgc, None);
1066 XSetClipOrigin (dpy, cgc, 0, 0); 1066 XSetClipOrigin (dpy, cgc, 0, 0);
1067 } 1067 }
1068 1068
1069 xpos += this_width; 1069 xpos += this_width;
1096 redisplay.c) This is the only way to be able to easily add 1096 redisplay.c) This is the only way to be able to easily add
1097 new cursor types or (e.g.) make the bar cursor be able to 1097 new cursor types or (e.g.) make the bar cursor be able to
1098 span two characters instead of overlaying just one. */ 1098 span two characters instead of overlaying just one. */
1099 int bogusly_obtained_ascent_value = 1099 int bogusly_obtained_ascent_value =
1100 XFONT_INSTANCE (FACE_CACHEL_FONT (cachel, runs[0].charset))->ascent; 1100 XFONT_INSTANCE (FACE_CACHEL_FONT (cachel, runs[0].charset))->ascent;
1101 1101
1102 if (!NILP (bar_cursor_value)) 1102 if (!NILP (bar_cursor_value))
1103 { 1103 {
1104 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil, 1104 gc = x_get_gc (d, Qnil, cursor_cachel->background, Qnil, Qnil,
1105 make_int (bar_width)); 1105 make_int (bar_width));
1106 } 1106 }
1107 else 1107 else
1108 { 1108 {
1109 gc = x_get_gc (d, Qnil, cursor_cachel->background, 1109 gc = x_get_gc (d, Qnil, cursor_cachel->background,
1110 Qnil, Qnil, Qnil); 1110 Qnil, Qnil, Qnil);
1111 } 1111 }
1112 1112
1113 tmp_y = dl->ypos - bogusly_obtained_ascent_value; 1113 tmp_y = dl->ypos - bogusly_obtained_ascent_value;
1114 tmp_height = cursor_height; 1114 tmp_height = cursor_height;
1115 if (tmp_y + tmp_height > (int) (dl->ypos - dl->ascent + height)) 1115 if (tmp_y + tmp_height > (int) (dl->ypos - dl->ascent + height))
1116 { 1116 {
1117 tmp_y = dl->ypos - dl->ascent + height - tmp_height; 1117 tmp_y = dl->ypos - dl->ascent + height - tmp_height;
1118 if (tmp_y < (int) (dl->ypos - dl->ascent)) 1118 if (tmp_y < (int) (dl->ypos - dl->ascent))
1119 tmp_y = dl->ypos - dl->ascent; 1119 tmp_y = dl->ypos - dl->ascent;
1120 tmp_height = dl->ypos - dl->ascent + height - tmp_y; 1120 tmp_height = dl->ypos - dl->ascent + height - tmp_y;
1121 } 1121 }
1122 1122
1123 if (need_clipping) 1123 if (need_clipping)
1124 { 1124 {
1125 XRectangle clip_box[1]; 1125 XRectangle clip_box[1];
1126 clip_box[0].x = 0; 1126 clip_box[0].x = 0;
1127 clip_box[0].y = 0; 1127 clip_box[0].y = 0;
1182 gcv.clip_y_origin = y - pixmap_offset; 1182 gcv.clip_y_origin = y - pixmap_offset;
1183 pixmap_mask |= (GCFunction | GCClipMask | GCClipXOrigin | 1183 pixmap_mask |= (GCFunction | GCClipMask | GCClipXOrigin |
1184 GCClipYOrigin); 1184 GCClipYOrigin);
1185 /* Can't set a clip rectangle below because we already have a mask. 1185 /* Can't set a clip rectangle below because we already have a mask.
1186 We could conceivably create a new clipmask by zeroing out 1186 We could conceivably create a new clipmask by zeroing out
1187 everything outside the clip region. Is it worth it? 1187 everything outside the clip region. Is it worth it?
1188 Is it possible to get an equivalent effect by changing the 1188 Is it possible to get an equivalent effect by changing the
1189 args to XCopyArea below rather than messing with a clip box? 1189 args to XCopyArea below rather than messing with a clip box?
1190 - dkindred@cs.cmu.edu */ 1190 - dkindred@cs.cmu.edu */
1191 need_clipping = 0; 1191 need_clipping = 0;
1192 } 1192 }
1193 1193
1194 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, pixmap_mask); 1194 gc = gc_cache_lookup (DEVICE_X_GC_CACHE (d), &gcv, pixmap_mask);
1195 } 1195 }
1196 else 1196 else
1854 1854
1855 /* We do this to make sure that the 3D modelines get redrawn if 1855 /* We do this to make sure that the 3D modelines get redrawn if
1856 they are in the exposed region. */ 1856 they are in the exposed region. */
1857 orig_windows_structure_changed = f->windows_structure_changed; 1857 orig_windows_structure_changed = f->windows_structure_changed;
1858 f->windows_structure_changed = 1; 1858 f->windows_structure_changed = 1;
1859 } 1859 }
1860 1860
1861 if (window_needs_vertical_divider (w)) 1861 if (window_needs_vertical_divider (w))
1862 { 1862 {
1863 x_output_vertical_divider (w, 0); 1863 x_output_vertical_divider (w, 0);
1864 } 1864 }
2067 Display *dpy = DEVICE_X_DISPLAY (d); 2067 Display *dpy = DEVICE_X_DISPLAY (d);
2068 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f)); 2068 Window x_win = XtWindow (FRAME_X_TEXT_WIDGET (f));
2069 GC gc; 2069 GC gc;
2070 face_index elt = get_builtin_face_cache_index (w, Vtext_cursor_face); 2070 face_index elt = get_builtin_face_cache_index (w, Vtext_cursor_face);
2071 struct face_cachel *cursor_cachel = WINDOW_FACE_CACHEL (w, elt); 2071 struct face_cachel *cursor_cachel = WINDOW_FACE_CACHEL (w, elt);
2072 2072
2073 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d)); 2073 int focus = EQ (w->frame, DEVICE_FRAME_WITH_FOCUS_REAL (d));
2074 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor, 2074 Lisp_Object bar_cursor_value = symbol_value_in_buffer (Qbar_cursor,
2075 WINDOW_BUFFER (w)); 2075 WINDOW_BUFFER (w));
2076 2076
2077 int x = xpos; 2077 int x = xpos;
2078 int y = dl->ypos - dl->ascent; 2078 int y = dl->ypos - dl->ascent;
2079 int width = EOL_CURSOR_WIDTH; 2079 int width = EOL_CURSOR_WIDTH;
2080 int height = dl->ascent + dl->descent - dl->clip; 2080 int height = dl->ascent + dl->descent - dl->clip;
2081 int cursor_height, cursor_y; 2081 int cursor_height, cursor_y;
2082 int defheight, defascent; 2082 int defheight, defascent;
2083 2083
2084 XClearArea (dpy, x_win, x, y, width, height, False); 2084 XClearArea (dpy, x_win, x, y, width, height, False);
2085 2085
2086 if (NILP (w->text_cursor_visible_p)) 2086 if (NILP (w->text_cursor_visible_p))
2087 return; 2087 return;
2088 2088
2092 Lisp_Object window = Qnil; 2092 Lisp_Object window = Qnil;
2093 2093
2094 XSETWINDOW (window, w); 2094 XSETWINDOW (window, w);
2095 default_face_font_info (window, &defascent, 0, &defheight, 0, 0); 2095 default_face_font_info (window, &defascent, 0, &defheight, 0, 0);
2096 } 2096 }
2097 2097
2098 /* make sure the cursor is entirely contained between y and y+height */ 2098 /* make sure the cursor is entirely contained between y and y+height */
2099 cursor_height = min (defheight, height); 2099 cursor_height = min (defheight, height);
2100 cursor_y = max (y, min (y + height - cursor_height, 2100 cursor_y = max (y, min (y + height - cursor_height,
2101 dl->ypos - defascent)); 2101 dl->ypos - defascent));
2102 2102
2103 if (focus) 2103 if (focus)
2104 { 2104 {
2105 #ifdef HAVE_XIM 2105 #ifdef HAVE_XIM
2106 XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2); 2106 XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2);
2107 #endif /* HAVE_XIM */ 2107 #endif /* HAVE_XIM */
2108 2108
2109 if (NILP (bar_cursor_value)) 2109 if (NILP (bar_cursor_value))
2110 { 2110 {
2111 XFillRectangle (dpy, x_win, gc, x, cursor_y, width, cursor_height); 2111 XFillRectangle (dpy, x_win, gc, x, cursor_y, width, cursor_height);
2112 } 2112 }
2113 else 2113 else
2205 Arg al [2]; 2205 Arg al [2];
2206 2206
2207 XtSetArg (al [0], XtNwidth, &width); 2207 XtSetArg (al [0], XtNwidth, &width);
2208 XtSetArg (al [1], XtNheight, &height); 2208 XtSetArg (al [1], XtNheight, &height);
2209 XtGetValues (shell, al, 2); 2209 XtGetValues (shell, al, 2);
2210 2210
2211 XSETFRAME (frame, f); 2211 XSETFRAME (frame, f);
2212 2212
2213 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame); 2213 tmp_pixel = FACE_FOREGROUND (Vdefault_face, frame);
2214 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel)); 2214 tmp_fcolor = COLOR_INSTANCE_X_COLOR (XCOLOR_INSTANCE (tmp_pixel));
2215 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame); 2215 tmp_pixel = FACE_BACKGROUND (Vdefault_face, frame);
2233 int usecs = 100000; 2233 int usecs = 100000;
2234 struct timeval tv; 2234 struct timeval tv;
2235 tv.tv_sec = usecs / 1000000L; 2235 tv.tv_sec = usecs / 1000000L;
2236 tv.tv_usec = usecs % 1000000L; 2236 tv.tv_usec = usecs % 1000000L;
2237 /* I'm sure someone is going to complain about this... */ 2237 /* I'm sure someone is going to complain about this... */
2238 (void) select (0, 0, 0, 0, &tv); 2238 select (0, 0, 0, 0, &tv);
2239 } 2239 }
2240 #endif /* !HAVE_POLL */ 2240 #endif /* !HAVE_POLL */
2241 2241
2242 XFillRectangle (dpy, w, gc, 0, 0, width, height); 2242 XFillRectangle (dpy, w, gc, 0, 0, width, height);
2243 XSync (dpy, False); 2243 XSync (dpy, False);