comparison src/redisplay-x.c @ 116:9f59509498e1 r20-1b10

Import from CVS: tag r20-1b10
author cvs
date Mon, 13 Aug 2007 09:23:06 +0200
parents 48d667d6f17f
children 0132846995bd
comparison
equal deleted inserted replaced
115:f109f7dabbe2 116:9f59509498e1
1077 && (cursor_start + cursor_width >= clip_start) 1077 && (cursor_start + cursor_width >= clip_start)
1078 && !NILP (bar_cursor_value)))) 1078 && !NILP (bar_cursor_value))))
1079 { 1079 {
1080 int tmp_height, tmp_y; 1080 int tmp_height, tmp_y;
1081 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2; 1081 int bar_width = EQ (bar_cursor_value, Qt) ? 1 : 2;
1082 int cursor_x; 1082 int need_clipping = (cursor_start < clip_start
1083 || clip_end < cursor_start + cursor_width);
1083 1084
1084 /* #### This value is correct (as far as I know) because 1085 /* #### This value is correct (as far as I know) because
1085 all of the times we need to draw this cursor, we will 1086 all of the times we need to draw this cursor, we will
1086 be called with exactly one character, so we know we 1087 be called with exactly one character, so we know we
1087 can always use runs[0]. 1088 can always use runs[0].
1107 { 1108 {
1108 gc = x_get_gc (d, Qnil, cursor_cachel->background, 1109 gc = x_get_gc (d, Qnil, cursor_cachel->background,
1109 Qnil, Qnil, Qnil); 1110 Qnil, Qnil, Qnil);
1110 } 1111 }
1111 1112
1112 if (cursor)
1113 cursor_x = clip_start;
1114 else
1115 cursor_x = cursor_start;
1116
1117 tmp_y = dl->ypos - bogusly_obtained_ascent_value; 1113 tmp_y = dl->ypos - bogusly_obtained_ascent_value;
1118 tmp_height = cursor_height; 1114 tmp_height = cursor_height;
1119 if (tmp_y + tmp_height > (int) (dl->ypos - dl->ascent + height)) 1115 if (tmp_y + tmp_height > (int) (dl->ypos - dl->ascent + height))
1120 { 1116 {
1121 tmp_y = dl->ypos - dl->ascent + height - tmp_height; 1117 tmp_y = dl->ypos - dl->ascent + height - tmp_height;
1122 if (tmp_y < (int) (dl->ypos - dl->ascent)) 1118 if (tmp_y < (int) (dl->ypos - dl->ascent))
1123 tmp_y = dl->ypos - dl->ascent; 1119 tmp_y = dl->ypos - dl->ascent;
1124 tmp_height = dl->ypos - dl->ascent + height - tmp_y; 1120 tmp_height = dl->ypos - dl->ascent + height - tmp_y;
1125 } 1121 }
1126 1122
1123 if (need_clipping)
1124 {
1125 XRectangle clip_box[1];
1126 clip_box[0].x = 0;
1127 clip_box[0].y = 0;
1128 clip_box[0].width = clip_end - clip_start;
1129 clip_box[0].height = tmp_height;
1130 XSetClipRectangles (dpy, gc, clip_start, tmp_y,
1131 clip_box, 1, Unsorted);
1132 }
1133
1127 if (!focus && NILP (bar_cursor_value)) 1134 if (!focus && NILP (bar_cursor_value))
1128 { 1135 {
1129 XDrawRectangle (dpy, x_win, gc, cursor_x, tmp_y, 1136 XDrawRectangle (dpy, x_win, gc, cursor_start, tmp_y,
1130 cursor_width - 1, tmp_height - 1); 1137 cursor_width - 1, tmp_height - 1);
1131 } 1138 }
1132 else if (focus && !NILP (bar_cursor_value)) 1139 else if (focus && !NILP (bar_cursor_value))
1133 { 1140 {
1134 XDrawLine (dpy, x_win, gc, cursor_x + bar_width - 1, tmp_y, 1141 XDrawLine (dpy, x_win, gc, cursor_start + bar_width - 1, tmp_y,
1135 cursor_x + bar_width - 1, tmp_y + tmp_height - 1); 1142 cursor_start + bar_width - 1, tmp_y + tmp_height - 1);
1143 }
1144
1145 /* Restore the GC */
1146 if (need_clipping)
1147 {
1148 XSetClipMask (dpy, gc, None);
1149 XSetClipOrigin (dpy, gc, 0, 0);
1136 } 1150 }
1137 } 1151 }
1138 } 1152 }
1139 1153
1140 void 1154 void
1824 x_redraw_exposed_windows (w->hchild, x, y, width, height); 1838 x_redraw_exposed_windows (w->hchild, x, y, width, height);
1825 return; 1839 return;
1826 } 1840 }
1827 1841
1828 /* If the window doesn't intersect the exposed region, we're done here. */ 1842 /* If the window doesn't intersect the exposed region, we're done here. */
1829 if (x > WINDOW_RIGHT (w) || (x + width) < WINDOW_LEFT (w) 1843 if (x >= WINDOW_RIGHT (w) || (x + width) <= WINDOW_LEFT (w)
1830 || y > WINDOW_BOTTOM (w) || (y + height) < WINDOW_TOP (w)) 1844 || y >= WINDOW_BOTTOM (w) || (y + height) <= WINDOW_TOP (w))
1831 { 1845 {
1832 return; 1846 return;
1833 } 1847 }
1834 else 1848 else
1835 { 1849 {
2091 2105
2092 XSETWINDOW (window, w); 2106 XSETWINDOW (window, w);
2093 default_face_font_info (window, &defascent, 0, &defheight, 0, 0); 2107 default_face_font_info (window, &defascent, 0, &defheight, 0, 0);
2094 } 2108 }
2095 2109
2096 cursor_y = dl->ypos - defascent; 2110 /* make sure the cursor is entirely contained between y and y+height */
2097 if (cursor_y < y) 2111 cursor_height = min (defheight, height);
2098 cursor_y = y; 2112 cursor_y = max (y, min (y + height - cursor_height,
2099 cursor_height = defheight; 2113 dl->ypos - defascent));
2100 if (cursor_y + cursor_height > y + height)
2101 cursor_height = y + height - cursor_y;
2102 2114
2103 if (focus) 2115 if (focus)
2104 { 2116 {
2105 #ifdef HAVE_XIM 2117 #ifdef HAVE_XIM
2106 XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2); 2118 XIM_SetSpotLocation (f, x - 2 , cursor_y + cursor_height - 2);