Skip to content

Commit 4aec94d

Browse files
committed
Avoid leaving artifacts when the system caret is used on w32
* src/xdisp.c (try_window_reusing_current_matrix, try_window_id): * src/dispnew.c (scrolling_window) [HAVE_NTGUI]: If w32-use-visible-system-caret is non-nil, disallow scrolling the display are in scroll_run_hook. This avoids copying traces of the caret, about which Emacs knows nothing, and thus considers those pixels show the default background. (Bug#39188) (gui_update_window_end): Block input only around part of the code, as we did before this code was extracted from backend-specific implementations. * src/w32term.c (w32_update_window_begin, w32_update_window_end): Only hide/show the caret when redisplaying the window where the caret is shown.
1 parent 5abd8d7 commit 4aec94d

File tree

3 files changed

+31
-5
lines changed

3 files changed

+31
-5
lines changed

src/dispnew.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3743,11 +3743,10 @@ gui_update_window_end (struct window *w, bool cursor_on_p,
37433743
{
37443744
struct frame *f = XFRAME (WINDOW_FRAME (w));
37453745

3746-
block_input ();
3747-
37483746
/* Pseudo windows don't have cursors, so don't display them here. */
37493747
if (!w->pseudo_window_p)
37503748
{
3749+
block_input ();
37513750

37523751
if (cursor_on_p)
37533752
display_and_set_cursor (w, true,
@@ -3761,6 +3760,7 @@ gui_update_window_end (struct window *w, bool cursor_on_p,
37613760
else
37623761
gui_draw_vertical_border (w);
37633762
}
3763+
unblock_input ();
37643764
}
37653765

37663766
/* If a row with mouse-face was overwritten, arrange for
@@ -3778,7 +3778,6 @@ gui_update_window_end (struct window *w, bool cursor_on_p,
37783778
FRAME_RIF (f)->update_window_end_hook (w,
37793779
cursor_on_p,
37803780
mouse_face_overwritten_p);
3781-
unblock_input ();
37823781
}
37833782

37843783
#endif /* HAVE_WINDOW_SYSTEM */
@@ -4360,6 +4359,14 @@ scrolling_window (struct window *w, int tab_line_p)
43604359
return 0;
43614360
#endif
43624361

4362+
/* Can't scroll the display of w32 GUI frames when position of point
4363+
is indicated by the system caret, because scrolling the display
4364+
will then "copy" the pixles used by the caret. */
4365+
#ifdef HAVE_NTGUI
4366+
if (w32_use_visible_system_caret)
4367+
return 0;
4368+
#endif
4369+
43634370
/* Give up if some rows in the desired matrix are not enabled. */
43644371
if (! MATRIX_ROW_ENABLED_P (desired_matrix, i))
43654372
return -1;

src/w32term.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,8 @@ static void
560560
w32_update_window_begin (struct window *w)
561561
{
562562
/* Hide the system caret during an update. */
563-
if (w32_use_visible_system_caret && w32_system_caret_hwnd)
563+
if (w32_use_visible_system_caret && w32_system_caret_hwnd
564+
&& w == w32_system_caret_window)
564565
{
565566
SendMessageTimeout (w32_system_caret_hwnd, WM_EMACS_HIDE_CARET, 0, 0,
566567
0, 6000, NULL);
@@ -657,7 +658,8 @@ w32_update_window_end (struct window *w, bool cursor_on_p,
657658
/* Unhide the caret. This won't actually show the cursor, unless it
658659
was visible before the corresponding call to HideCaret in
659660
w32_update_window_begin. */
660-
if (w32_use_visible_system_caret && w32_system_caret_hwnd)
661+
if (w32_use_visible_system_caret && w32_system_caret_hwnd
662+
&& w == w32_system_caret_window)
661663
{
662664
SendMessageTimeout (w32_system_caret_hwnd, WM_EMACS_SHOW_CARET, 0, 0,
663665
0, 6000, NULL);

src/xdisp.c

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19191,6 +19191,14 @@ try_window_reusing_current_matrix (struct window *w)
1919119191
if (!NILP (Vdisplay_line_numbers))
1919219192
return false;
1919319193

19194+
/* Can't scroll the display of w32 GUI frames when position of point
19195+
is indicated by the system caret, because scrolling the display
19196+
will then "copy" the pixles used by the caret. */
19197+
#ifdef HAVE_NTGUI
19198+
if (w32_use_visible_system_caret)
19199+
return false;
19200+
#endif
19201+
1919419202
/* The variable new_start now holds the new window start. The old
1919519203
start `start' can be determined from the current matrix. */
1919619204
SET_TEXT_POS_FROM_MARKER (new_start, w->start);
@@ -20175,6 +20183,15 @@ try_window_id (struct window *w)
2017520183
if (MATRIX_ROW_START_CHARPOS (row) == MATRIX_ROW_END_CHARPOS (row))
2017620184
GIVE_UP (20);
2017720185

20186+
/* Can't let scroll_run_hook below run on w32 GUI frames when
20187+
position of point is indicated by the system caret, because
20188+
scrolling the display will then "copy" the pixles used by the
20189+
caret. */
20190+
#ifdef HAVE_NTGUI
20191+
if (FRAME_W32_P (f) && w32_use_visible_system_caret)
20192+
GIVE_UP (25);
20193+
#endif
20194+
2017820195
/* Compute the position at which we have to start displaying new
2017920196
lines. Some of the lines at the top of the window might be
2018020197
reusable because they are not displaying changed text. Find the

0 commit comments

Comments
 (0)