From 9fed97293c8bc78eef679db1ae3cab468ecc473e Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Tue, 27 Aug 2013 07:52:21 +0400 Subject: [PATCH] * lisp.h (Mouse_HLInfo): Move from here... * dispextern.h (Mouse_HLInfo): ...to here and offload lisp.h. (reset_mouse_highlight): New function. * msdos.c (dos_set_window_size, IT_update_begin) (internal_terminal_init): * nsterm.m (ns_update_window_end, x_free_frame_resources) (ns_initialize_display_info): * w32console.c (initialize_w32_display): * w32term.c (x_update_window_end, x_free_frame_resources) (w32_initialize_display_info): * xterm.c (x_update_window_end, x_free_frame_resources, x_term_init): * window.c (Fdelete_other_windows_internal): * xdisp.c (clear_mouse_face, cancel_mouse_face): Use it. * termchar.h (toplevel): * xterm.h (toplevel): Include dispextern.h. --- src/ChangeLog | 18 +++++++++++++++++ src/dispextern.h | 51 +++++++++++++++++++++++++++++++++++++++++++++++- src/lisp.h | 30 ---------------------------- src/msdos.c | 30 ++++++---------------------- src/nsterm.m | 30 ++++------------------------ src/termchar.h | 2 ++ src/w32console.c | 8 +------- src/w32term.c | 28 +++----------------------- src/window.c | 8 ++------ src/xdisp.c | 11 ++--------- src/xterm.c | 28 ++++---------------------- src/xterm.h | 2 ++ 12 files changed, 94 insertions(+), 152 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index 01f3093b6d..5633d95cbf 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,21 @@ +2013-08-27 Dmitry Antipov + + * lisp.h (Mouse_HLInfo): Move from here... + * dispextern.h (Mouse_HLInfo): ...to here and offload lisp.h. + (reset_mouse_highlight): New function. + * msdos.c (dos_set_window_size, IT_update_begin) + (internal_terminal_init): + * nsterm.m (ns_update_window_end, x_free_frame_resources) + (ns_initialize_display_info): + * w32console.c (initialize_w32_display): + * w32term.c (x_update_window_end, x_free_frame_resources) + (w32_initialize_display_info): + * xterm.c (x_update_window_end, x_free_frame_resources, x_term_init): + * window.c (Fdelete_other_windows_internal): + * xdisp.c (clear_mouse_face, cancel_mouse_face): Use it. + * termchar.h (toplevel): + * xterm.h (toplevel): Include dispextern.h. + 2013-08-26 Paul Eggert Fix minor problems found by static checking. diff --git a/src/dispextern.h b/src/dispextern.h index 6e1d85de92..cb9dddd82c 100644 --- a/src/dispextern.h +++ b/src/dispextern.h @@ -2667,8 +2667,57 @@ enum move_operation_enum MOVE_TO_POS = 0x08 }; +/*********************************************************************** + Mouse Highlight + ***********************************************************************/ + +/* Structure to hold mouse highlight data. */ + +typedef struct { + /* These variables describe the range of text currently shown in its + mouse-face, together with the window they apply to. As long as + the mouse stays within this range, we need not redraw anything on + its account. Rows and columns are glyph matrix positions in + MOUSE_FACE_WINDOW. */ + int mouse_face_beg_row, mouse_face_beg_col, mouse_face_beg_x; + int mouse_face_end_row, mouse_face_end_col, mouse_face_end_x; + Lisp_Object mouse_face_window; + int mouse_face_face_id; + Lisp_Object mouse_face_overlay; + + /* FRAME and X, Y position of mouse when last checked for + highlighting. X and Y can be negative or out of range for the frame. */ + struct frame *mouse_face_mouse_frame; + int mouse_face_mouse_x, mouse_face_mouse_y; + + /* Nonzero if part of the text currently shown in + its mouse-face is beyond the window end. */ + unsigned mouse_face_past_end : 1; + + /* Nonzero means defer mouse-motion highlighting. */ + unsigned mouse_face_defer : 1; + + /* Nonzero means that the mouse highlight should not be shown. */ + unsigned mouse_face_hidden : 1; +} Mouse_HLInfo; + +DISPEXTERN_INLINE void +reset_mouse_highlight (Mouse_HLInfo *hlinfo) +{ + + hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; + hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; + hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0; + hlinfo->mouse_face_beg_x = hlinfo->mouse_face_end_x = 0; + hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; + hlinfo->mouse_face_mouse_frame = NULL; + hlinfo->mouse_face_window = Qnil; + hlinfo->mouse_face_overlay = Qnil; + hlinfo->mouse_face_past_end = 0; + hlinfo->mouse_face_hidden = 0; + hlinfo->mouse_face_defer = 0; +} - /*********************************************************************** Window-based redisplay interface ***********************************************************************/ diff --git a/src/lisp.h b/src/lisp.h index f609727fe2..3dab0d6ddf 100644 --- a/src/lisp.h +++ b/src/lisp.h @@ -2164,36 +2164,6 @@ enum char_bits CHARACTERBITS = 22 }; -/* Structure to hold mouse highlight data. This is here because other - header files need it for defining struct x_output etc. */ -typedef struct { - /* These variables describe the range of text currently shown in its - mouse-face, together with the window they apply to. As long as - the mouse stays within this range, we need not redraw anything on - its account. Rows and columns are glyph matrix positions in - MOUSE_FACE_WINDOW. */ - int mouse_face_beg_row, mouse_face_beg_col, mouse_face_beg_x; - int mouse_face_end_row, mouse_face_end_col, mouse_face_end_x; - Lisp_Object mouse_face_window; - int mouse_face_face_id; - Lisp_Object mouse_face_overlay; - - /* FRAME and X, Y position of mouse when last checked for - highlighting. X and Y can be negative or out of range for the frame. */ - struct frame *mouse_face_mouse_frame; - int mouse_face_mouse_x, mouse_face_mouse_y; - - /* Nonzero if part of the text currently shown in - its mouse-face is beyond the window end. */ - unsigned mouse_face_past_end : 1; - - /* Nonzero means defer mouse-motion highlighting. */ - unsigned mouse_face_defer : 1; - - /* Nonzero means that the mouse highlight should not be shown. */ - unsigned mouse_face_hidden : 1; -} Mouse_HLInfo; - /* Data type checking. */ LISP_MACRO_DEFUN (NILP, bool, (Lisp_Object x), (x)) diff --git a/src/msdos.c b/src/msdos.c index 88a2eb6072..6018f72bfa 100644 --- a/src/msdos.c +++ b/src/msdos.c @@ -602,11 +602,7 @@ dos_set_window_size (int *rows, int *cols) Lisp_Object window = hlinfo->mouse_face_window; if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f) - { - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } + reset_mouse_highlight (hlinfo); } /* Enable bright background colors. */ @@ -1276,14 +1272,9 @@ IT_update_begin (struct frame *f) } } else if (mouse_face_frame && !FRAME_LIVE_P (mouse_face_frame)) - { - /* If the frame with mouse highlight was deleted, invalidate the - highlight info. */ - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_mouse_frame = NULL; - } + /* If the frame with mouse highlight was deleted, invalidate the + highlight info. */ + reset_mouse_highlight (hlinfo); unblock_input (); } @@ -1843,17 +1834,8 @@ internal_terminal_init (void) if (colors[1] >= 0 && colors[1] < 16) FRAME_BACKGROUND_PIXEL (SELECTED_FRAME ()) = colors[1]; } - the_only_display_info.mouse_highlight.mouse_face_mouse_frame = NULL; - the_only_display_info.mouse_highlight.mouse_face_beg_row = - the_only_display_info.mouse_highlight.mouse_face_beg_col = -1; - the_only_display_info.mouse_highlight.mouse_face_end_row = - the_only_display_info.mouse_highlight.mouse_face_end_col = -1; - the_only_display_info.mouse_highlight.mouse_face_face_id = DEFAULT_FACE_ID; - the_only_display_info.mouse_highlight.mouse_face_window = Qnil; - the_only_display_info.mouse_highlight.mouse_face_mouse_x = - the_only_display_info.mouse_highlight.mouse_face_mouse_y = 0; - the_only_display_info.mouse_highlight.mouse_face_defer = 0; - the_only_display_info.mouse_highlight.mouse_face_hidden = 0; + + reset_mouse_highlight (&the_only_display_info.mouse_highlight); if (have_mouse) /* detected in dos_ttraw, which see */ { diff --git a/src/nsterm.m b/src/nsterm.m index f7cc5933a5..f7f7b89783 100644 --- a/src/nsterm.m +++ b/src/nsterm.m @@ -749,8 +749,6 @@ ns_update_window_end (struct window *w, bool cursor_on_p, external (RIF) call; for one window called before update_end -------------------------------------------------------------------------- */ { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); - /* note: this fn is nearly identical in all terms */ if (!w->pseudo_window_p) { @@ -770,11 +768,7 @@ ns_update_window_end (struct window *w, bool cursor_on_p, /* If a row with mouse-face was overwritten, arrange for frame_up_to_date to redisplay the mouse highlight. */ if (mouse_face_overwritten_p) - { - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } + reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame))); NSTRACE (update_window_end); } @@ -1183,12 +1177,7 @@ x_free_frame_resources (struct frame *f) if (f == dpyinfo->x_highlight_frame) dpyinfo->x_highlight_frame = 0; if (f == hlinfo->mouse_face_mouse_frame) - { - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_mouse_frame = 0; - } + reset_mouse_highlight (hlinfo); if (f->output_data.ns->miniimage != nil) [f->output_data.ns->miniimage release]; @@ -3951,7 +3940,6 @@ ns_initialize_display_info (struct ns_display_info *dpyinfo) { NSScreen *screen = [NSScreen mainScreen]; NSWindowDepth depth = [screen depth]; - Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; dpyinfo->resx = 72.27; /* used 75.0, but this makes pt == pixel, expected */ dpyinfo->resy = 72.27; @@ -3964,22 +3952,12 @@ ns_initialize_display_info (struct ns_display_info *dpyinfo) dpyinfo->color_table = xmalloc (sizeof *dpyinfo->color_table); dpyinfo->color_table->colors = NULL; dpyinfo->root_window = 42; /* a placeholder.. */ - - hlinfo->mouse_face_mouse_frame = NULL; - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; - hlinfo->mouse_face_window = hlinfo->mouse_face_overlay = Qnil; - hlinfo->mouse_face_hidden = 0; - - hlinfo->mouse_face_mouse_x = hlinfo->mouse_face_mouse_y = 0; - hlinfo->mouse_face_defer = 0; - dpyinfo->x_highlight_frame = dpyinfo->x_focus_frame = NULL; - dpyinfo->n_fonts = 0; dpyinfo->smallest_font_height = 1; dpyinfo->smallest_char_width = 1; + + reset_mouse_highlight (&dpyinfo->mouse_highlight); } diff --git a/src/termchar.h b/src/termchar.h index 601b9fe820..687f7fbd11 100644 --- a/src/termchar.h +++ b/src/termchar.h @@ -16,6 +16,8 @@ GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Emacs. If not, see . */ +#include "dispextern.h" + /* Each termcap frame points to its own struct tty_output object in the output_data.tty field. The tty_output structure contains the information that is specific to termcap frames. */ diff --git a/src/w32console.c b/src/w32console.c index ee92a59330..a707344efc 100644 --- a/src/w32console.c +++ b/src/w32console.c @@ -636,13 +636,7 @@ initialize_w32_display (struct terminal *term, int *width, int *height) term->frame_up_to_date_hook = 0; /* Initialize the mouse-highlight data. */ - hlinfo = &term->display_info.tty->mouse_highlight; - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; - hlinfo->mouse_face_mouse_frame = NULL; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_hidden = 0; + reset_mouse_highlight (&term->display_info.tty->mouse_highlight); /* Initialize interrupt_handle. */ init_crit (); diff --git a/src/w32term.c b/src/w32term.c index 7a15323551..ba3aadd0b4 100644 --- a/src/w32term.c +++ b/src/w32term.c @@ -678,8 +678,6 @@ static void x_update_window_end (struct window *w, bool cursor_on_p, bool mouse_face_overwritten_p) { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); - if (!w->pseudo_window_p) { block_input (); @@ -698,11 +696,7 @@ x_update_window_end (struct window *w, bool cursor_on_p, /* If a row with mouse-face was overwritten, arrange for XTframe_up_to_date to redisplay the mouse highlight. */ if (mouse_face_overwritten_p) - { - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } + reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame))); /* Unhide the caret. This won't actually show the cursor, unless it was visible before the corresponding call to HideCaret in @@ -6156,16 +6150,8 @@ x_free_frame_resources (struct frame *f) dpyinfo->w32_focus_event_frame = 0; if (f == dpyinfo->x_highlight_frame) dpyinfo->x_highlight_frame = 0; - if (f == hlinfo->mouse_face_mouse_frame) - { - hlinfo->mouse_face_beg_row - = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row - = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_mouse_frame = 0; - } + reset_mouse_highlight (hlinfo); unblock_input (); } @@ -6235,7 +6221,6 @@ void w32_initialize_display_info (Lisp_Object display_name) { struct w32_display_info *dpyinfo = &one_w32_display_info; - Mouse_HLInfo *hlinfo = &dpyinfo->mouse_highlight; memset (dpyinfo, 0, sizeof (*dpyinfo)); @@ -6258,17 +6243,10 @@ w32_initialize_display_info (Lisp_Object display_name) dpyinfo->n_fonts = 0; dpyinfo->smallest_font_height = 1; dpyinfo->smallest_char_width = 1; - - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_overlay = Qnil; - hlinfo->mouse_face_hidden = 0; - dpyinfo->vertical_scroll_bar_cursor = w32_load_cursor (IDC_ARROW); /* TODO: dpyinfo->gray */ + reset_mouse_highlight (&dpyinfo->mouse_highlight); } /* Create an xrdb-style database of resources to supersede registry settings. diff --git a/src/window.c b/src/window.c index 6ef32608a5..e40572bf13 100644 --- a/src/window.c +++ b/src/window.c @@ -2842,7 +2842,7 @@ window-start value is reasonable when this function is called. */) block_input (); if (!FRAME_INITIAL_P (f)) { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); + Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f); /* We are going to free the glyph matrices of WINDOW, and with that we might lose any information about glyph rows that have @@ -2852,11 +2852,7 @@ window-start value is reasonable when this function is called. */) frame's up-to-date hook that mouse highlight was overwritten, so that it will arrange for redisplaying the highlight. */ if (EQ (hlinfo->mouse_face_window, window)) - { - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } + reset_mouse_highlight (hlinfo); } free_window_matrices (r); diff --git a/src/xdisp.c b/src/xdisp.c index 0617a3e643..98ff1aae1d 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -26795,10 +26795,7 @@ clear_mouse_face (Mouse_HLInfo *hlinfo) cleared = 1; } - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_overlay = Qnil; + reset_mouse_highlight (hlinfo); return cleared; } @@ -28586,11 +28583,7 @@ cancel_mouse_face (struct frame *f) window = hlinfo->mouse_face_window; if (! NILP (window) && XFRAME (XWINDOW (window)->frame) == f) - { - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } + reset_mouse_highlight (hlinfo); } diff --git a/src/xterm.c b/src/xterm.c index cea952f44d..7014bdb974 100644 --- a/src/xterm.c +++ b/src/xterm.c @@ -613,8 +613,6 @@ static void x_update_window_end (struct window *w, bool cursor_on_p, bool mouse_face_overwritten_p) { - Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (XFRAME (w->frame)); - if (!w->pseudo_window_p) { block_input (); @@ -633,11 +631,7 @@ x_update_window_end (struct window *w, bool cursor_on_p, /* If a row with mouse-face was overwritten, arrange for XTframe_up_to_date to redisplay the mouse highlight. */ if (mouse_face_overwritten_p) - { - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - } + reset_mouse_highlight (MOUSE_HL_INFO (XFRAME (w->frame))); } @@ -9445,16 +9439,8 @@ x_free_frame_resources (struct frame *f) dpyinfo->x_focus_event_frame = 0; if (f == dpyinfo->x_highlight_frame) dpyinfo->x_highlight_frame = 0; - if (f == hlinfo->mouse_face_mouse_frame) - { - hlinfo->mouse_face_beg_row - = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row - = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_mouse_frame = 0; - } + reset_mouse_highlight (hlinfo); unblock_input (); } @@ -9826,7 +9812,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) struct terminal *terminal; struct x_display_info *dpyinfo; XrmDatabase xrdb; - Mouse_HLInfo *hlinfo; ptrdiff_t lim; block_input (); @@ -9967,8 +9952,6 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) /* We have definitely succeeded. Record the new connection. */ dpyinfo = xzalloc (sizeof *dpyinfo); - hlinfo = &dpyinfo->mouse_highlight; - terminal = x_create_terminal (dpyinfo); { @@ -10082,13 +10065,10 @@ x_term_init (Lisp_Object display_name, char *xrm_option, char *resource_name) dpyinfo->cmap = DefaultColormapOfScreen (dpyinfo->screen); dpyinfo->root_window = RootWindowOfScreen (dpyinfo->screen); dpyinfo->icon_bitmap_id = -1; - hlinfo->mouse_face_beg_row = hlinfo->mouse_face_beg_col = -1; - hlinfo->mouse_face_end_row = hlinfo->mouse_face_end_col = -1; - hlinfo->mouse_face_face_id = DEFAULT_FACE_ID; - hlinfo->mouse_face_window = Qnil; - hlinfo->mouse_face_overlay = Qnil; dpyinfo->wm_type = X_WMTYPE_UNKNOWN; + reset_mouse_highlight (&dpyinfo->mouse_highlight); + /* See if we can construct pixel values from RGB values. */ if (dpyinfo->visual->class == TrueColor) { diff --git a/src/xterm.h b/src/xterm.h index fbc2f05a37..d1a586881b 100644 --- a/src/xterm.h +++ b/src/xterm.h @@ -20,6 +20,8 @@ along with GNU Emacs. If not, see . */ #ifndef XTERM_H #define XTERM_H +#include "dispextern.h" + #include #include -- 2.20.1