Skip to content

Commit 9ae94eb

Browse files
committed
Refactor update_window_begin and update_window_end hooks
Bug#35464. * src/dispnew.c (gui_update_window_begin, gui_update_window_end): New procedures implementing common functionality. * src/nsterm.m: (ns_update_window_begin, ns_update_window_end): * src/xterm.c: (x_update_window_begin, x_update_window_end): Remove in favor of only using the new generic versions. * src/w32term.c: (w32_update_window_begin, w32_update_window_end): Remove duplicated and unused code.
1 parent d17ae7f commit 9ae94eb

File tree

6 files changed

+118
-243
lines changed

6 files changed

+118
-243
lines changed

src/dispextern.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3521,6 +3521,10 @@ void clear_glyph_matrix_rows (struct glyph_matrix *, int, int);
35213521
void clear_glyph_row (struct glyph_row *);
35223522
void prepare_desired_row (struct window *, struct glyph_row *, bool);
35233523
void update_single_window (struct window *);
3524+
#ifdef HAVE_WINDOW_SYSTEM
3525+
extern void gui_update_window_begin (struct window *);
3526+
extern void gui_update_window_end (struct window *, bool, bool);
3527+
#endif
35243528
void do_pending_window_change (bool);
35253529
void change_frame_size (struct frame *, int, int, bool, bool, bool, bool);
35263530
void init_display (void);

src/dispnew.c

Lines changed: 91 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3390,7 +3390,9 @@ update_window (struct window *w, bool force_p)
33903390
struct glyph_matrix *desired_matrix = w->desired_matrix;
33913391
bool paused_p;
33923392
int preempt_count = clip_to_bounds (1, baud_rate / 2400 + 1, INT_MAX);
3393+
#ifdef HAVE_WINDOW_SYSTEM
33933394
struct redisplay_interface *rif = FRAME_RIF (XFRAME (WINDOW_FRAME (w)));
3395+
#endif
33943396
#ifdef GLYPH_DEBUG
33953397
/* Check that W's frame doesn't have glyph matrices. */
33963398
eassert (FRAME_WINDOW_P (XFRAME (WINDOW_FRAME (w))));
@@ -3411,7 +3413,9 @@ update_window (struct window *w, bool force_p)
34113413
bool changed_p = 0, mouse_face_overwritten_p = 0;
34123414
int n_updated = 0;
34133415

3414-
rif->update_window_begin_hook (w);
3416+
#ifdef HAVE_WINDOW_SYSTEM
3417+
gui_update_window_begin (w);
3418+
#endif
34153419
yb = window_text_bottom_y (w);
34163420
row = MATRIX_ROW (desired_matrix, 0);
34173421
end = MATRIX_MODE_LINE_ROW (desired_matrix);
@@ -3533,13 +3537,13 @@ update_window (struct window *w, bool force_p)
35333537

35343538
#ifdef HAVE_WINDOW_SYSTEM
35353539
update_window_fringes (w, 0);
3536-
#endif
35373540

35383541
/* End the update of window W. Don't set the cursor if we
35393542
paused updating the display because in this case,
35403543
set_window_cursor_after_update hasn't been called, and
35413544
W->output_cursor doesn't contain the cursor location. */
3542-
rif->update_window_end_hook (w, !paused_p, mouse_face_overwritten_p);
3545+
gui_update_window_end (w, !paused_p, mouse_face_overwritten_p);
3546+
#endif
35433547
}
35443548
else
35453549
paused_p = 1;
@@ -3555,6 +3559,90 @@ update_window (struct window *w, bool force_p)
35553559
return paused_p;
35563560
}
35573561

3562+
#ifdef HAVE_WINDOW_SYSTEM
3563+
3564+
/* Start update of window W. */
3565+
3566+
void
3567+
gui_update_window_begin (struct window *w)
3568+
{
3569+
struct frame *f = XFRAME (WINDOW_FRAME (w));
3570+
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
3571+
3572+
block_input ();
3573+
3574+
if (FRAME_RIF (f)->update_window_begin_hook)
3575+
FRAME_RIF (f)->update_window_begin_hook (w);
3576+
3577+
w->output_cursor = w->cursor;
3578+
3579+
if (f == hlinfo->mouse_face_mouse_frame)
3580+
{
3581+
/* Don't do highlighting for mouse motion during the update. */
3582+
hlinfo->mouse_face_defer = true;
3583+
3584+
/* If the frame needs to be redrawn, simply forget about any
3585+
prior mouse highlighting. */
3586+
if (FRAME_GARBAGED_P (f))
3587+
hlinfo->mouse_face_window = Qnil;
3588+
}
3589+
3590+
unblock_input ();
3591+
}
3592+
3593+
/* End update of window W.
3594+
3595+
Draw vertical borders between horizontally adjacent windows, and
3596+
display W's cursor if CURSOR_ON_P is non-zero.
3597+
3598+
MOUSE_FACE_OVERWRITTEN_P non-zero means that some row containing
3599+
glyphs in mouse-face were overwritten. In that case we have to
3600+
make sure that the mouse-highlight is properly redrawn. */
3601+
void
3602+
gui_update_window_end (struct window *w, bool cursor_on_p,
3603+
bool mouse_face_overwritten_p)
3604+
{
3605+
struct frame *f = XFRAME (WINDOW_FRAME (w));
3606+
3607+
block_input ();
3608+
3609+
/* Pseudo windows don't have cursors, so don't display them here. */
3610+
if (!w->pseudo_window_p)
3611+
{
3612+
3613+
if (cursor_on_p)
3614+
display_and_set_cursor (w, true,
3615+
w->output_cursor.hpos, w->output_cursor.vpos,
3616+
w->output_cursor.x, w->output_cursor.y);
3617+
3618+
if (draw_window_fringes (w, true))
3619+
{
3620+
if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
3621+
gui_draw_right_divider (w);
3622+
else
3623+
gui_draw_vertical_border (w);
3624+
}
3625+
}
3626+
3627+
/* If a row with mouse-face was overwritten, arrange for
3628+
frame_up_to_date_hook to redisplay the mouse highlight. */
3629+
if (mouse_face_overwritten_p)
3630+
{
3631+
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
3632+
3633+
hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
3634+
hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
3635+
hlinfo->mouse_face_window = Qnil;
3636+
}
3637+
3638+
if (FRAME_RIF (f)->update_window_end_hook)
3639+
FRAME_RIF (f)->update_window_end_hook (w,
3640+
cursor_on_p,
3641+
mouse_face_overwritten_p);
3642+
unblock_input ();
3643+
}
3644+
3645+
#endif /* HAVE_WINDOW_SYSTEM */
35583646

35593647
/* Update the display of area AREA in window W, row number VPOS.
35603648
AREA can be either LEFT_MARGIN_AREA or RIGHT_MARGIN_AREA. */

src/nsterm.m

Lines changed: 4 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,7 +1106,7 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
11061106
ns_update_begin (struct frame *f)
11071107
/* --------------------------------------------------------------------------
11081108
Prepare for a grouped sequence of drawing calls
1109-
external (RIF) call; whole frame, called before update_window_begin
1109+
external (RIF) call; whole frame, called before gui_update_window_begin
11101110
-------------------------------------------------------------------------- */
11111111
{
11121112
#ifdef NS_IMPL_COCOA
@@ -1128,81 +1128,11 @@ static NSRect constrain_frame_rect(NSRect frameRect, bool isFullscreen)
11281128
}
11291129

11301130

1131-
static void
1132-
ns_update_window_begin (struct window *w)
1133-
/* --------------------------------------------------------------------------
1134-
Prepare for a grouped sequence of drawing calls
1135-
external (RIF) call; for one window, called after update_begin
1136-
-------------------------------------------------------------------------- */
1137-
{
1138-
struct frame *f = XFRAME (WINDOW_FRAME (w));
1139-
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
1140-
1141-
NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_begin");
1142-
w->output_cursor = w->cursor;
1143-
1144-
block_input ();
1145-
1146-
if (f == hlinfo->mouse_face_mouse_frame)
1147-
{
1148-
/* Don't do highlighting for mouse motion during the update. */
1149-
hlinfo->mouse_face_defer = 1;
1150-
1151-
/* If the frame needs to be redrawn,
1152-
simply forget about any prior mouse highlighting. */
1153-
if (FRAME_GARBAGED_P (f))
1154-
hlinfo->mouse_face_window = Qnil;
1155-
1156-
/* (further code for mouse faces ifdef'd out in other terms elided) */
1157-
}
1158-
1159-
unblock_input ();
1160-
}
1161-
1162-
1163-
static void
1164-
ns_update_window_end (struct window *w, bool cursor_on_p,
1165-
bool mouse_face_overwritten_p)
1166-
/* --------------------------------------------------------------------------
1167-
Finished a grouped sequence of drawing calls
1168-
external (RIF) call; for one window called before update_end
1169-
-------------------------------------------------------------------------- */
1170-
{
1171-
NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_window_end");
1172-
1173-
/* note: this fn is nearly identical in all terms */
1174-
if (!w->pseudo_window_p)
1175-
{
1176-
block_input ();
1177-
1178-
if (cursor_on_p)
1179-
display_and_set_cursor (w, 1,
1180-
w->output_cursor.hpos, w->output_cursor.vpos,
1181-
w->output_cursor.x, w->output_cursor.y);
1182-
1183-
if (draw_window_fringes (w, 1))
1184-
{
1185-
if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
1186-
gui_draw_right_divider (w);
1187-
else
1188-
gui_draw_vertical_border (w);
1189-
}
1190-
1191-
unblock_input ();
1192-
}
1193-
1194-
/* If a row with mouse-face was overwritten, arrange for
1195-
frame_up_to_date to redisplay the mouse highlight. */
1196-
if (mouse_face_overwritten_p)
1197-
reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame)));
1198-
}
1199-
1200-
12011131
static void
12021132
ns_update_end (struct frame *f)
12031133
/* --------------------------------------------------------------------------
12041134
Finished a grouped sequence of drawing calls
1205-
external (RIF) call; for whole frame, called after update_window_end
1135+
external (RIF) call; for whole frame, called after gui_update_window_end
12061136
-------------------------------------------------------------------------- */
12071137
{
12081138
NSTRACE_WHEN (NSTRACE_GROUP_UPDATES, "ns_update_end");
@@ -5166,8 +5096,8 @@ static Lisp_Object ns_string_to_lispmod (const char *s)
51665096
gui_clear_end_of_line,
51675097
ns_scroll_run,
51685098
ns_after_update_window_line,
5169-
ns_update_window_begin,
5170-
ns_update_window_end,
5099+
NULL, /* update_window_begin */
5100+
NULL, /* update_window_end */
51715101
0, /* flush_display */
51725102
gui_clear_window_mouse_face,
51735103
gui_get_glyph_overhangs,

src/w32term.c

Lines changed: 3 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,7 @@ w32_display_pixel_width (struct w32_display_info *dpyinfo)
529529

530530
/* Start an update of frame F. This function is installed as a hook
531531
for update_begin, i.e. it is called when update_begin is called.
532-
This function is called prior to calls to w32_update_window_begin
532+
This function is called prior to calls to gui_update_window_begin
533533
for each window being updated. */
534534

535535
static void
@@ -555,58 +555,12 @@ w32_update_begin (struct frame *f)
555555
static void
556556
w32_update_window_begin (struct window *w)
557557
{
558-
struct frame *f = XFRAME (WINDOW_FRAME (w));
559-
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
560-
561558
/* Hide the system caret during an update. */
562559
if (w32_use_visible_system_caret && w32_system_caret_hwnd)
563560
{
564561
SendMessageTimeout (w32_system_caret_hwnd, WM_EMACS_HIDE_CARET, 0, 0,
565562
0, 6000, NULL);
566563
}
567-
568-
w->output_cursor = w->cursor;
569-
570-
block_input ();
571-
572-
if (f == hlinfo->mouse_face_mouse_frame)
573-
{
574-
/* Don't do highlighting for mouse motion during the update. */
575-
hlinfo->mouse_face_defer = true;
576-
577-
/* If F needs to be redrawn, simply forget about any prior mouse
578-
highlighting. */
579-
if (FRAME_GARBAGED_P (f))
580-
hlinfo->mouse_face_window = Qnil;
581-
582-
#if 0 /* Rows in a current matrix containing glyphs in mouse-face have
583-
their mouse_face_p flag set, which means that they are always
584-
unequal to rows in a desired matrix which never have that
585-
flag set. So, rows containing mouse-face glyphs are never
586-
scrolled, and we don't have to switch the mouse highlight off
587-
here to prevent it from being scrolled. */
588-
589-
/* Can we tell that this update does not affect the window
590-
where the mouse highlight is? If so, no need to turn off.
591-
Likewise, don't do anything if the frame is garbaged;
592-
in that case, the frame's current matrix that we would use
593-
is all wrong, and we will redisplay that line anyway. */
594-
if (!NILP (hlinfo->mouse_face_window)
595-
&& w == XWINDOW (hlinfo->mouse_face_window))
596-
{
597-
int i;
598-
599-
for (i = 0; i < w->desired_matrix->nrows; ++i)
600-
if (MATRIX_ROW_ENABLED_P (w->desired_matrix, i))
601-
break;
602-
603-
if (i < w->desired_matrix->nrows)
604-
clear_mouse_face (hlinfo);
605-
}
606-
#endif /* 0 */
607-
}
608-
609-
unblock_input ();
610564
}
611565

612566
/* Draw a vertical window border from (x,y0) to (x,y1) */
@@ -694,39 +648,8 @@ w32_draw_window_divider (struct window *w, int x0, int x1, int y0, int y1)
694648

695649
static void
696650
w32_update_window_end (struct window *w, bool cursor_on_p,
697-
bool mouse_face_overwritten_p)
651+
bool mouse_face_overwritten_p)
698652
{
699-
if (!w->pseudo_window_p)
700-
{
701-
block_input ();
702-
703-
if (cursor_on_p)
704-
display_and_set_cursor (w, true,
705-
w->output_cursor.hpos, w->output_cursor.vpos,
706-
w->output_cursor.x, w->output_cursor.y);
707-
708-
if (draw_window_fringes (w, true))
709-
{
710-
if (WINDOW_RIGHT_DIVIDER_WIDTH (w))
711-
gui_draw_right_divider (w);
712-
else
713-
gui_draw_vertical_border (w);
714-
}
715-
716-
unblock_input ();
717-
}
718-
719-
/* If a row with mouse-face was overwritten, arrange for
720-
XTframe_up_to_date to redisplay the mouse highlight. */
721-
if (mouse_face_overwritten_p)
722-
{
723-
Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame));
724-
725-
hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1;
726-
hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1;
727-
hlinfo->mouse_face_window = Qnil;
728-
}
729-
730653
/* Unhide the caret. This won't actually show the cursor, unless it
731654
was visible before the corresponding call to HideCaret in
732655
w32_update_window_begin. */
@@ -2859,7 +2782,7 @@ w32_scroll_run (struct window *w, struct run *run)
28592782

28602783
block_input ();
28612784

2862-
/* Cursor off. Will be switched on again in w32_update_window_end. */
2785+
/* Cursor off. Will be switched on again in gui_update_window_end. */
28632786
gui_clear_cursor (w);
28642787

28652788
{

0 commit comments

Comments
 (0)