7758 |
{ |
{ |
7759 |
struct window *w = XWINDOW (dpyinfo->mouse_face_window); |
struct window *w = XWINDOW (dpyinfo->mouse_face_window); |
7760 |
struct frame *f = XFRAME (WINDOW_FRAME (w)); |
struct frame *f = XFRAME (WINDOW_FRAME (w)); |
|
int i; |
|
|
int cursor_off_p = 0; |
|
|
struct cursor_pos saved_cursor; |
|
|
|
|
|
saved_cursor = output_cursor; |
|
|
|
|
|
/* If window is in the process of being destroyed, don't bother |
|
|
to do anything. */ |
|
|
if (w->current_matrix == NULL) |
|
|
goto set_x_cursor; |
|
|
|
|
|
/* Recognize when we are called to operate on rows that don't exist |
|
|
anymore. This can happen when a window is split. */ |
|
|
if (dpyinfo->mouse_face_end_row >= w->current_matrix->nrows) |
|
|
goto set_x_cursor; |
|
|
|
|
|
set_output_cursor (&w->phys_cursor); |
|
|
|
|
|
/* Note that mouse_face_beg_row etc. are window relative. */ |
|
|
for (i = dpyinfo->mouse_face_beg_row; |
|
|
i <= dpyinfo->mouse_face_end_row; |
|
|
i++) |
|
|
{ |
|
|
int start_hpos, end_hpos, start_x; |
|
|
struct glyph_row *row = MATRIX_ROW (w->current_matrix, i); |
|
7761 |
|
|
7762 |
/* Don't do anything if row doesn't have valid contents. */ |
if (/* If window is in the process of being destroyed, don't bother |
7763 |
if (!row->enabled_p) |
to do anything. */ |
7764 |
continue; |
w->current_matrix != NULL |
7765 |
|
/* Recognize when we are called to operate on rows that don't exist |
7766 |
|
anymore. This can happen when a window is split. */ |
7767 |
|
&& dpyinfo->mouse_face_end_row < w->current_matrix->nrows) |
7768 |
|
{ |
7769 |
|
int phys_cursor_on_p = w->phys_cursor_on_p; |
7770 |
|
struct glyph_row *row, *first, *last; |
7771 |
|
|
7772 |
/* For all but the first row, the highlight starts at column 0. */ |
first = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_beg_row); |
7773 |
if (i == dpyinfo->mouse_face_beg_row) |
last = MATRIX_ROW (w->current_matrix, dpyinfo->mouse_face_end_row); |
7774 |
{ |
|
7775 |
start_hpos = dpyinfo->mouse_face_beg_col; |
for (row = first; row <= last && row->enabled_p; ++row) |
|
start_x = dpyinfo->mouse_face_beg_x; |
|
|
} |
|
|
else |
|
7776 |
{ |
{ |
7777 |
start_hpos = 0; |
int start_hpos, end_hpos, start_x; |
|
start_x = 0; |
|
|
} |
|
7778 |
|
|
7779 |
if (i == dpyinfo->mouse_face_end_row) |
/* For all but the first row, the highlight starts at column 0. */ |
7780 |
end_hpos = dpyinfo->mouse_face_end_col; |
if (row == first) |
7781 |
else |
{ |
7782 |
end_hpos = row->used[TEXT_AREA]; |
start_hpos = dpyinfo->mouse_face_beg_col; |
7783 |
|
start_x = dpyinfo->mouse_face_beg_x; |
7784 |
/* If the cursor's in the text we are about to rewrite, turn the |
} |
7785 |
cursor off. */ |
else |
7786 |
if (!w->pseudo_window_p |
{ |
7787 |
&& i == output_cursor.vpos |
start_hpos = 0; |
7788 |
&& output_cursor.hpos >= start_hpos - 1 |
start_x = 0; |
7789 |
&& output_cursor.hpos <= end_hpos) |
} |
7790 |
{ |
|
7791 |
x_update_window_cursor (w, 0); |
if (row == last) |
7792 |
cursor_off_p = 1; |
end_hpos = dpyinfo->mouse_face_end_col; |
7793 |
} |
else |
7794 |
|
end_hpos = row->used[TEXT_AREA]; |
7795 |
|
|
7796 |
|
if (end_hpos > start_hpos) |
7797 |
|
{ |
7798 |
|
x_draw_glyphs (w, start_x, row, TEXT_AREA, |
7799 |
|
start_hpos, end_hpos, draw, 0); |
7800 |
|
|
7801 |
if (end_hpos > start_hpos) |
row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED; |
7802 |
{ |
} |
|
x_draw_glyphs (w, start_x, row, TEXT_AREA, |
|
|
start_hpos, end_hpos, draw, 0); |
|
|
row->mouse_face_p = draw == DRAW_MOUSE_FACE || DRAW_IMAGE_RAISED; |
|
7803 |
} |
} |
|
} |
|
7804 |
|
|
7805 |
/* If we turned the cursor off, turn it back on. */ |
/* When we've written over the cursor, arrange for it to |
7806 |
if (cursor_off_p) |
be displayed again. */ |
7807 |
x_display_cursor (w, 1, |
if (phys_cursor_on_p && !w->phys_cursor_on_p) |
7808 |
output_cursor.hpos, output_cursor.vpos, |
x_display_cursor (w, 1, |
7809 |
output_cursor.x, output_cursor.y); |
w->phys_cursor.hpos, w->phys_cursor.vpos, |
7810 |
|
w->phys_cursor.x, w->phys_cursor.y); |
7811 |
output_cursor = saved_cursor; |
} |
7812 |
|
|
|
set_x_cursor: |
|
|
|
|
7813 |
/* Change the mouse cursor. */ |
/* Change the mouse cursor. */ |
7814 |
if (draw == DRAW_NORMAL_TEXT) |
if (draw == DRAW_NORMAL_TEXT) |
7815 |
XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |
XDefineCursor (FRAME_X_DISPLAY (f), FRAME_X_WINDOW (f), |