comparison src/xterm.c @ 6660:cb14d76e993c

(note_mouse_highlight): Do nothing if gc_in_progress. Set mouse_face_deferred_gc when that case arise. (XTframe_up_to_date): If mouse_face_deferred_gc, redo highlighting. (show_mouse_face): Turn off cursor only if it's in the area being manipulated. (XTupdate_begin): Don't turn off highlight if we aren't updating the window that it is in.
author Richard M. Stallman <rms@gnu.org>
date Mon, 04 Apr 1994 00:43:13 +0000
parents 1305248ee38a
children af1629dfdb4c
comparison
equal deleted inserted replaced
6659:830263c59354 6660:cb14d76e993c
283 redraw anything on its account. */ 283 redraw anything on its account. */
284 static int mouse_face_beg, mouse_face_end; 284 static int mouse_face_beg, mouse_face_end;
285 static Lisp_Object mouse_face_window; 285 static Lisp_Object mouse_face_window;
286 static int mouse_face_face_id; 286 static int mouse_face_face_id;
287 287
288 /* 1 if a mouse motion event came and we didn't handle it right away because
289 gc was in progress. */
290 static int mouse_face_deferred_gc;
291
288 /* FRAME and X, Y position of mouse when last checked for highlighting. */ 292 /* FRAME and X, Y position of mouse when last checked for highlighting. */
289 static FRAME_PTR mouse_face_mouse_frame; 293 static FRAME_PTR mouse_face_mouse_frame;
290 static int mouse_face_mouse_x, mouse_face_mouse_y; 294 static int mouse_face_mouse_x, mouse_face_mouse_y;
291 295
292 /* Nonzero means defer mouse-motion highlighting. */ 296 /* Nonzero means defer mouse-motion highlighting. */
391 395
392 BLOCK_INPUT; 396 BLOCK_INPUT;
393 397
394 if (f == mouse_face_mouse_frame) 398 if (f == mouse_face_mouse_frame)
395 { 399 {
400 /* Don't do highlighting for mouse motion during the update. */
396 mouse_face_defer = 1; 401 mouse_face_defer = 1;
397 if (!NILP (mouse_face_window)) 402 if (!NILP (mouse_face_window))
398 clear_mouse_face (); 403 {
404 int firstline, lastline, i;
405 struct window *w = XWINDOW (mouse_face_window);
406
407 /* Find the first, and the last+1, lines affected by redisplay. */
408 for (firstline = 0; firstline < f->height; firstline++)
409 if (FRAME_DESIRED_GLYPHS (f)->enable[firstline])
410 break;
411
412 lastline = f->height;
413 for (i = f->height - 1; i >= 0; i--)
414 {
415 if (FRAME_DESIRED_GLYPHS (f)->enable[i])
416 break;
417 else
418 lastline = i;
419 }
420
421 /* Can we tell that this update does not affect the window
422 where the mouse highlight is? If so, no need to turn off. */
423 if (! (firstline > (XFASTINT (w->top) + window_internal_height (w))
424 || lastline < XFASTINT (w->top)))
425 /* Otherwise turn off the mouse highlight now. */
426 clear_mouse_face ();
427 }
399 } 428 }
400 #ifndef HAVE_X11 429 #ifndef HAVE_X11
401 dumpqueue (); 430 dumpqueue ();
402 #endif /* HAVE_X11 */ 431 #endif /* HAVE_X11 */
403 UNBLOCK_INPUT; 432 UNBLOCK_INPUT;
436 465
437 XFlushQueue (); 466 XFlushQueue ();
438 UNBLOCK_INPUT; 467 UNBLOCK_INPUT;
439 } 468 }
440 469
441 /* This is called when all windows on frame F are now up to date. */ 470 /* This is called after a redisplay on frame F. */
442 471
443 static 472 static
444 XTframe_up_to_date (f) 473 XTframe_up_to_date (f)
445 FRAME_PTR f; 474 FRAME_PTR f;
446 { 475 {
447 if (f == mouse_face_mouse_frame) 476 if (mouse_face_deferred_gc || f == mouse_face_mouse_frame)
448 note_mouse_highlight (f, mouse_face_mouse_x, mouse_face_mouse_y); 477 {
478 note_mouse_highlight (mouse_face_mouse_frame,
479 mouse_face_mouse_x, mouse_face_mouse_y);
480 mouse_face_deferred_gc = 0;
481 }
449 } 482 }
450 483
451 /* External interface to control of standout mode. 484 /* External interface to control of standout mode.
452 Call this when about to modify line at position VPOS 485 Call this when about to modify line at position VPOS
453 and not change whether it is highlighted. */ 486 and not change whether it is highlighted. */
1936 mouse_face_mouse_frame = f; 1969 mouse_face_mouse_frame = f;
1937 1970
1938 if (mouse_face_defer) 1971 if (mouse_face_defer)
1939 return; 1972 return;
1940 1973
1974 if (gc_in_progress)
1975 {
1976 mouse_face_deferred_gc = 1;
1977 return;
1978 }
1979
1941 /* Find out which glyph the mouse is on. */ 1980 /* Find out which glyph the mouse is on. */
1942 pixel_to_glyph_coords (f, x, y, &column, &row, 1981 pixel_to_glyph_coords (f, x, y, &column, &row,
1943 &new_glyph, x_mouse_grabbed); 1982 &new_glyph, x_mouse_grabbed);
1944 1983
1945 /* Which window is that in? */ 1984 /* Which window is that in? */
2133 int begcol, begrow, endcol, endrow; 2172 int begcol, begrow, endcol, endrow;
2134 struct window *w = XWINDOW (mouse_face_window); 2173 struct window *w = XWINDOW (mouse_face_window);
2135 int width = window_internal_width (w); 2174 int width = window_internal_width (w);
2136 FRAME_PTR f = XFRAME (WINDOW_FRAME (w)); 2175 FRAME_PTR f = XFRAME (WINDOW_FRAME (w));
2137 int i; 2176 int i;
2177 int curs_x = f->phys_cursor_x;
2178 int curs_y = f->phys_cursor_y;
2179 int cursor_off = 0;
2138 2180
2139 fast_find_position (mouse_face_window, mouse_face_beg, 2181 fast_find_position (mouse_face_window, mouse_face_beg,
2140 &begcol, &begrow); 2182 &begcol, &begrow);
2141 fast_find_position (mouse_face_window, mouse_face_end, 2183 fast_find_position (mouse_face_window, mouse_face_end,
2142 &endcol, &endrow); 2184 &endcol, &endrow);
2143 2185
2144 x_display_cursor (f, 0);
2145
2146 for (i = begrow; i <= endrow; i++) 2186 for (i = begrow; i <= endrow; i++)
2147 { 2187 {
2148 int column = (i == begrow ? begcol : w->left); 2188 int column = (i == begrow ? begcol : w->left);
2149 int endcolumn = (i == endrow ? endcol : w->left + width); 2189 int endcolumn = (i == endrow ? endcol : w->left + width);
2150 endcolumn = min (endcolumn, FRAME_CURRENT_GLYPHS (f)->used[i] - w->left), 2190 endcolumn = min (endcolumn, FRAME_CURRENT_GLYPHS (f)->used[i] - w->left);
2191
2192 /* If the cursor's in the text we are about to rewrite,
2193 turn the cursor off. */
2194 if (i == curs_y
2195 && (curs_x >= begrow - 1 || curs_x <= endrow))
2196 {
2197 x_display_cursor (f, 0);
2198 cursor_off = 1;
2199 }
2151 2200
2152 dumpglyphs (f, 2201 dumpglyphs (f,
2153 CHAR_TO_PIXEL_COL (f, column), 2202 CHAR_TO_PIXEL_COL (f, column),
2154 CHAR_TO_PIXEL_ROW (f, i), 2203 CHAR_TO_PIXEL_ROW (f, i),
2155 FRAME_CURRENT_GLYPHS (f)->glyphs[i] + column, 2204 FRAME_CURRENT_GLYPHS (f)->glyphs[i] + column,
2156 endcolumn - column, 2205 endcolumn - column,
2157 /* Highlight with mouse face if hl > 0. */ 2206 /* Highlight with mouse face if hl > 0. */
2158 hl > 0 ? 3 : 0); 2207 hl > 0 ? 3 : 0);
2159 } 2208 }
2160 2209
2161 x_display_cursor (f, 1); 2210 /* If we turned the cursor off, turn it back on. */
2211 if (cursor_off)
2212 x_display_cursor (f, 1);
2162 } 2213 }
2163 2214
2164 /* Clear out the mouse-highlighted active region. 2215 /* Clear out the mouse-highlighted active region.
2165 Redraw it unhighlighted first. */ 2216 Redraw it unhighlighted first. */
2166 2217