From f60e429a1a1a0d6a51761ef12e54dde52967f085 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Wed, 28 Aug 2013 09:45:38 +0400 Subject: [PATCH] Redesign redisplay interface to drop global output_cursor. * dispextern.h (struct redisplay_interface): Remove cursor_to member. (toplevel): Remove declaration of output_cursor. (set_output_cursor, x_cursor_to): Remove prototype. * window.h (struct window): New member output_cursor. (output_cursor_to): New function to replace RIF member. * dispnew.c (redraw_overlapped_rows, update_marginal_area) (update_text_area, set_window_cursor_after_update): Use it. * xdisp.c (output_cursor, set_output_cursor, x_cursor_to): Remove. (x_write_glyphs, x_insert_glyphs, x_clear_end_of_line): * nsterm.m (ns_update_window_begin, ns_update_window_end): * w32term.c (x_update_window_begin, x_update_window_end): * xterm.c (x_update_window_begin, x_update_window_end): Adjust to use per-window output cursor. --- src/ChangeLog | 17 ++++++++++ src/dispextern.h | 12 ------- src/dispnew.c | 25 +++++++------- src/nsterm.m | 10 ++---- src/w32term.c | 16 +++------ src/window.h | 19 +++++++++++ src/xdisp.c | 84 ++++++++---------------------------------------- src/xterm.c | 16 +++------ 8 files changed, 75 insertions(+), 124 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 185619f1890..dfcad3bf120 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,20 @@ +2013-08-28 Dmitry Antipov + + Redesign redisplay interface to drop global output_cursor. + * dispextern.h (struct redisplay_interface): Remove cursor_to member. + (toplevel): Remove declaration of output_cursor. + (set_output_cursor, x_cursor_to): Remove prototype. + * window.h (struct window): New member output_cursor. + (output_cursor_to): New function to replace RIF member. + * dispnew.c (redraw_overlapped_rows, update_marginal_area) + (update_text_area, set_window_cursor_after_update): Use it. + * xdisp.c (output_cursor, set_output_cursor, x_cursor_to): Remove. + (x_write_glyphs, x_insert_glyphs, x_clear_end_of_line): + * nsterm.m (ns_update_window_begin, ns_update_window_end): + * w32term.c (x_update_window_begin, x_update_window_end): + * xterm.c (x_update_window_begin, x_update_window_end): + Adjust to use per-window output cursor. + 2013-08-27 Paul Eggert Simplify SELECT_TYPE-related code. diff --git a/src/dispextern.h b/src/dispextern.h index a5cb66f7d5e..2d44dca3861 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2790,11 +2790,6 @@ struct redisplay_interface void (*update_window_end_hook) (struct window *w, bool cursor_on_p, bool mouse_face_overwritten_p); - /* Move cursor to row/column position VPOS/HPOS, pixel coordinates - Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y - are window-relative pixel positions. */ - void (*cursor_to) (struct window *w, int vpos, int hpos, int y, int x); - /* Flush the display of frame F. For X, this is XFlush. */ void (*flush_display) (struct frame *f); @@ -3232,9 +3227,6 @@ extern void x_insert_glyphs (struct window *, struct glyph_row *, struct glyph *, enum glyph_row_area, int); extern void x_clear_end_of_line (struct window *, struct glyph_row *, enum glyph_row_area, int); - -extern struct cursor_pos output_cursor; - extern void x_fix_overlapping_area (struct window *, struct glyph_row *, enum glyph_row_area, int); extern void draw_phys_cursor_glyph (struct window *, @@ -3244,10 +3236,6 @@ extern void get_phys_cursor_geometry (struct window *, struct glyph_row *, struct glyph *, int *, int *, int *); extern void erase_phys_cursor (struct window *); extern void display_and_set_cursor (struct window *, bool, int, int, int, int); - -extern void set_output_cursor (struct cursor_pos *); -extern void x_cursor_to (struct window *, int, int, int, int); - extern void x_update_cursor (struct frame *, bool); extern void x_clear_cursor (struct window *); extern void x_draw_vertical_border (struct window *w); diff --git a/src/dispnew.c b/src/dispnew.c index 1c80facd422..349689e57f5 100644 --- a/src/dispnew.c +++ b/src/dispnew.c @@ -3223,8 +3223,8 @@ redraw_overlapped_rows (struct window *w, int yb) for (area = LEFT_MARGIN_AREA; area < LAST_AREA; ++area) { - FRAME_RIF (f)->cursor_to (w, i, 0, row->y, - area == TEXT_AREA ? row->x : 0); + output_cursor_to (w, i, 0, row->y, + area == TEXT_AREA ? row->x : 0); if (row->used[area]) FRAME_RIF (f)->write_glyphs (w, row, row->glyphs[area], area, row->used[area]); @@ -3481,7 +3481,7 @@ update_window (struct window *w, bool force_p) /* End the update of window W. Don't set the cursor if we paused updating the display because in this case, set_window_cursor_after_update hasn't been called, and - output_cursor doesn't contain the cursor location. */ + W->output_cursor doesn't contain the cursor location. */ rif->update_window_end_hook (w, !paused_p, mouse_face_overwritten_p); } else @@ -3511,7 +3511,7 @@ update_marginal_area (struct window *w, struct glyph_row *updated_row, /* Set cursor to start of glyphs, write them, and clear to the end of the area. I don't think that something more sophisticated is necessary here, since marginal areas will not be the default. */ - rif->cursor_to (w, vpos, 0, desired_row->y, 0); + output_cursor_to (w, vpos, 0, desired_row->y, 0); if (desired_row->used[area]) rif->write_glyphs (w, updated_row, desired_row->glyphs[area], area, desired_row->used[area]); @@ -3549,7 +3549,7 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos) && !(current_row->mode_line_p && vpos > 0)) || current_row->x != desired_row->x) { - rif->cursor_to (w, vpos, 0, desired_row->y, desired_row->x); + output_cursor_to (w, vpos, 0, desired_row->y, desired_row->x); if (desired_row->used[TEXT_AREA]) rif->write_glyphs (w, updated_row, desired_row->glyphs[TEXT_AREA], @@ -3692,7 +3692,7 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos) break; } - rif->cursor_to (w, vpos, start_hpos, desired_row->y, start_x); + output_cursor_to (w, vpos, start_hpos, desired_row->y, start_x); rif->write_glyphs (w, updated_row, start, TEXT_AREA, i - start_hpos); changed_p = 1; @@ -3702,7 +3702,7 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos) /* Write the rest. */ if (i < desired_row->used[TEXT_AREA]) { - rif->cursor_to (w, vpos, i, desired_row->y, x); + output_cursor_to (w, vpos, i, desired_row->y, x); rif->write_glyphs (w, updated_row, desired_glyph, TEXT_AREA, desired_row->used[TEXT_AREA] - i); changed_p = 1; @@ -3724,8 +3724,8 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos) { /* If old row extends to the end of the text area, clear. */ if (i >= desired_row->used[TEXT_AREA]) - rif->cursor_to (w, vpos, i, desired_row->y, - desired_row->pixel_width); + output_cursor_to (w, vpos, i, desired_row->y, + desired_row->pixel_width); rif->clear_end_of_line (w, updated_row, TEXT_AREA, -1); changed_p = 1; } @@ -3736,8 +3736,8 @@ update_text_area (struct window *w, struct glyph_row *updated_row, int vpos) int xlim; if (i >= desired_row->used[TEXT_AREA]) - rif->cursor_to (w, vpos, i, desired_row->y, - desired_row->pixel_width); + output_cursor_to (w, vpos, i, desired_row->y, + desired_row->pixel_width); /* If cursor is displayed at the end of the line, make sure it's cleared. Nowadays we don't have a phys_cursor_glyph @@ -3836,7 +3836,6 @@ static void set_window_cursor_after_update (struct window *w) { struct frame *f = XFRAME (w->frame); - struct redisplay_interface *rif = FRAME_RIF (f); int cx, cy, vpos, hpos; /* Not intended for frame matrix updates. */ @@ -3908,7 +3907,7 @@ set_window_cursor_after_update (struct window *w) Horizontal position is -1 when cursor is on the left fringe. */ hpos = clip_to_bounds (-1, hpos, w->current_matrix->matrix_w - 1); vpos = clip_to_bounds (0, vpos, w->current_matrix->nrows - 1); - rif->cursor_to (w, vpos, hpos, cy, cx); + output_cursor_to (w, vpos, hpos, cy, cx); } diff --git a/src/nsterm.m b/src/nsterm.m index 01ee2319ddf..921c3a5ce05 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -720,7 +720,7 @@ ns_update_window_begin (struct window *w) Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); NSTRACE (ns_update_window_begin); - set_output_cursor (&w->cursor); + w->output_cursor = w->cursor; block_input (); @@ -756,8 +756,8 @@ ns_update_window_end (struct window *w, bool cursor_on_p, if (cursor_on_p) display_and_set_cursor (w, 1, - output_cursor.hpos, output_cursor.vpos, - output_cursor.x, output_cursor.y); + w->output_cursor.hpos, w->output_cursor.vpos, + w->output_cursor.x, w->output_cursor.y); if (draw_window_fringes (w, 1)) x_draw_vertical_border (w); @@ -1989,9 +1989,6 @@ ns_clear_frame (struct frame *f) mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); - output_cursor.hpos = output_cursor.vpos = 0; - output_cursor.x = -1; - r = [view bounds]; block_input (); @@ -3978,7 +3975,6 @@ static struct redisplay_interface ns_redisplay_interface = ns_after_update_window_line, ns_update_window_begin, ns_update_window_end, - x_cursor_to, ns_flush, 0, /* flush_display_optional */ x_clear_window_mouse_face, diff --git a/src/w32term.c b/src/w32term.c index ba3aadd0b49..394d348c97f 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -576,8 +576,7 @@ x_update_begin (struct frame *f) } -/* Start update of window W. Set output_cursor to the cursor - position of W. */ +/* Start update of window W. */ static void x_update_window_begin (struct window *w) @@ -591,7 +590,7 @@ x_update_window_begin (struct window *w) SendMessage (w32_system_caret_hwnd, WM_EMACS_HIDE_CARET, 0, 0); } - set_output_cursor (&w->cursor); + w->output_cursor = w->cursor; block_input (); @@ -683,9 +682,9 @@ x_update_window_end (struct window *w, bool cursor_on_p, block_input (); if (cursor_on_p) - display_and_set_cursor (w, 1, output_cursor.hpos, - output_cursor.vpos, - output_cursor.x, output_cursor.y); + display_and_set_cursor (w, 1, + w->output_cursor.hpos, w->output_cursor.vpos, + w->output_cursor.x, w->output_cursor.y); if (draw_window_fringes (w, 1)) x_draw_vertical_border (w); @@ -2651,11 +2650,7 @@ x_clear_frame (struct frame *f) /* Clearing the frame will erase any cursor, so mark them all as no longer visible. */ mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); - output_cursor.hpos = output_cursor.vpos = 0; - output_cursor.x = -1; - /* We don't set the output cursor here because there will always - follow an explicit cursor_to. */ block_input (); w32_clear_window (f); @@ -6321,7 +6316,6 @@ static struct redisplay_interface w32_redisplay_interface = x_after_update_window_line, x_update_window_begin, x_update_window_end, - x_cursor_to, x_flush, 0, /* flush_display_optional */ x_clear_window_mouse_face, diff --git a/src/window.h b/src/window.h index de77dcabc85..3e37fa9d983 100644 --- a/src/window.h +++ b/src/window.h @@ -236,6 +236,9 @@ struct window /* Where the cursor actually is. */ struct cursor_pos phys_cursor; + /* Internally used for redisplay purposes. */ + struct cursor_pos output_cursor; + /* Vertical cursor position as of last update that completed without pause. This is the position of last_point. */ int last_cursor_vpos; @@ -956,6 +959,22 @@ extern void init_window (void); extern void syms_of_window (void); extern void keys_of_window (void); +/* Move cursor to row/column position VPOS/HPOS, pixel coordinates + Y/X. HPOS/VPOS are window-relative row and column numbers and X/Y + are window-relative pixel positions. This is always done during + window update, so the position is the future output cursor position + for currently updated window W. */ + +WINDOW_INLINE void +output_cursor_to (struct window *w, int vpos, int hpos, int y, int x) +{ + eassert (w); + w->output_cursor.hpos = hpos; + w->output_cursor.vpos = vpos; + w->output_cursor.x = x; + w->output_cursor.y = y; +} + INLINE_HEADER_END #endif /* not WINDOW_H_INCLUDED */ diff --git a/src/xdisp.c b/src/xdisp.c index 46992d2f396..44a8630bab4 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -11445,62 +11445,6 @@ update_menu_bar (struct frame *f, int save_match_data, int hooks_run) return hooks_run; } - - -/*********************************************************************** - Output Cursor - ***********************************************************************/ - -#ifdef HAVE_WINDOW_SYSTEM - -/* EXPORT: - Nominal cursor position -- where to draw output. - HPOS and VPOS are window relative glyph matrix coordinates. - X and Y are window relative pixel coordinates. */ - -struct cursor_pos output_cursor; - - -/* EXPORT: - Set the global variable output_cursor to CURSOR. All cursor - positions are relative to currently updated window. */ - -void -set_output_cursor (struct cursor_pos *cursor) -{ - output_cursor.hpos = cursor->hpos; - output_cursor.vpos = cursor->vpos; - output_cursor.x = cursor->x; - output_cursor.y = cursor->y; -} - - -/* EXPORT for RIF: - Set a nominal cursor position. - - HPOS and VPOS are column/row positions in a window glyph matrix. - X and Y are window text area relative pixel positions. - - This is always done during window update, so the position is the - future output cursor position for currently updated window W. - NOTE: W is used only to check whether this function is called - in a consistent manner via the redisplay interface. */ - -void -x_cursor_to (struct window *w, int vpos, int hpos, int y, int x) -{ - eassert (w); - - /* Set the output cursor. */ - output_cursor.hpos = hpos; - output_cursor.vpos = vpos; - output_cursor.x = x; - output_cursor.y = y; -} - -#endif /* HAVE_WINDOW_SYSTEM */ - - /*********************************************************************** Tool-bars ***********************************************************************/ @@ -25790,7 +25734,7 @@ x_write_glyphs (struct window *w, struct glyph_row *updated_row, /* Write glyphs. */ hpos = start - updated_row->glyphs[updated_area]; - x = draw_glyphs (w, output_cursor.x, + x = draw_glyphs (w, w->output_cursor.x, updated_row, updated_area, hpos, hpos + len, DRAW_NORMAL_TEXT, 0); @@ -25798,7 +25742,7 @@ x_write_glyphs (struct window *w, struct glyph_row *updated_row, /* Invalidate old phys cursor if the glyph at its hpos is redrawn. */ if (updated_area == TEXT_AREA && w->phys_cursor_on_p - && w->phys_cursor.vpos == output_cursor.vpos + && w->phys_cursor.vpos == w->output_cursor.vpos && chpos >= hpos && chpos < hpos + len) w->phys_cursor_on_p = 0; @@ -25806,8 +25750,8 @@ x_write_glyphs (struct window *w, struct glyph_row *updated_row, unblock_input (); /* Advance the output cursor. */ - output_cursor.hpos += len; - output_cursor.x = x; + w->output_cursor.hpos += len; + w->output_cursor.x = x; } @@ -25840,25 +25784,25 @@ x_insert_glyphs (struct window *w, struct glyph_row *updated_row, /* Get the width of the region to shift right. */ shifted_region_width = (window_box_width (w, updated_area) - - output_cursor.x + - w->output_cursor.x - shift_by_width); /* Shift right. */ - frame_x = window_box_left (w, updated_area) + output_cursor.x; - frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, output_cursor.y); + frame_x = window_box_left (w, updated_area) + w->output_cursor.x; + frame_y = WINDOW_TO_FRAME_PIXEL_Y (w, w->output_cursor.y); FRAME_RIF (f)->shift_glyphs_for_insert (f, frame_x, frame_y, shifted_region_width, line_height, shift_by_width); /* Write the glyphs. */ hpos = start - row->glyphs[updated_area]; - draw_glyphs (w, output_cursor.x, row, updated_area, + draw_glyphs (w, w->output_cursor.x, row, updated_area, hpos, hpos + len, DRAW_NORMAL_TEXT, 0); /* Advance the output cursor. */ - output_cursor.hpos += len; - output_cursor.x += shift_by_width; + w->output_cursor.hpos += len; + w->output_cursor.x += shift_by_width; unblock_input (); } @@ -25897,16 +25841,16 @@ x_clear_end_of_line (struct window *w, struct glyph_row *updated_row, else to_x = min (to_x, max_x); - to_y = min (max_y, output_cursor.y + updated_row->height); + to_y = min (max_y, w->output_cursor.y + updated_row->height); /* Notice if the cursor will be cleared by this operation. */ if (!updated_row->full_width_p) notice_overwritten_cursor (w, updated_area, - output_cursor.x, -1, + w->output_cursor.x, -1, updated_row->y, MATRIX_ROW_BOTTOM_Y (updated_row)); - from_x = output_cursor.x; + from_x = w->output_cursor.x; /* Translate to frame coordinates. */ if (updated_row->full_width_p) @@ -25922,7 +25866,7 @@ x_clear_end_of_line (struct window *w, struct glyph_row *updated_row, } min_y = WINDOW_HEADER_LINE_HEIGHT (w); - from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, output_cursor.y)); + from_y = WINDOW_TO_FRAME_PIXEL_Y (w, max (min_y, w->output_cursor.y)); to_y = WINDOW_TO_FRAME_PIXEL_Y (w, to_y); /* Prevent inadvertently clearing to end of the X window. */ diff --git a/src/xterm.c b/src/xterm.c index 777f13e431c..b7a98dbc5c1 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -551,8 +551,7 @@ x_update_begin (struct frame *f) } -/* Start update of window W. Set output_cursor to the cursor - position of W. */ +/* Start update of window W. */ static void x_update_window_begin (struct window *w) @@ -560,7 +559,7 @@ x_update_window_begin (struct window *w) struct frame *f = XFRAME (WINDOW_FRAME (w)); Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); - set_output_cursor (&w->cursor); + w->output_cursor = w->cursor; block_input (); @@ -618,9 +617,9 @@ x_update_window_end (struct window *w, bool cursor_on_p, block_input (); if (cursor_on_p) - display_and_set_cursor (w, 1, output_cursor.hpos, - output_cursor.vpos, - output_cursor.x, output_cursor.y); + display_and_set_cursor (w, 1, + w->output_cursor.hpos, w->output_cursor.vpos, + w->output_cursor.x, w->output_cursor.y); if (draw_window_fringes (w, 1)) x_draw_vertical_border (w); @@ -2983,11 +2982,7 @@ x_clear_frame (struct frame *f) /* Clearing the frame will erase any cursor, so mark them all as no longer visible. */ mark_window_cursors_off (XWINDOW (FRAME_ROOT_WINDOW (f))); - output_cursor.hpos = output_cursor.vpos = 0; - output_cursor.x = -1; - /* We don't set the output cursor here because there will always - follow an explicit cursor_to. */ block_input (); XClearWindow (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f)); @@ -10448,7 +10443,6 @@ static struct redisplay_interface x_redisplay_interface = x_after_update_window_line, x_update_window_begin, x_update_window_end, - x_cursor_to, x_flush, #ifdef XFlush x_flush, -- 2.39.2