From: Eli Zaretskii Date: Wed, 5 Jun 2013 20:45:34 +0000 (+0300) Subject: Fix bug #14558 with turning off mouse-highlight during highlight. X-Git-Tag: emacs-24.3.90~173^2^2~42^2~45^2~387^2~2026^2~63 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=817ebfcfde1a40283c173a87ffbe0c1f5cf7ab3a;p=emacs.git Fix bug #14558 with turning off mouse-highlight during highlight. src/xdisp.c (handle_tool_bar_click): When mouse-highlight is off, don't insist on being invoked on a highlighted tool-bar button. Avoids losing tool-bar functionality when mouse-highlight is nil. (note_tool_bar_highlight, note_mode_line_or_margin_highlight): Don't highlight when mouse-highlight is nil. (note_mouse_highlight): When mouse-highlight is nil, don't return right away; instead, run tool-bar and mode-line highlight subroutine, clear any existing highlight, and revert the mouse pointer to its default shape. --- diff --git a/src/ChangeLog b/src/ChangeLog index 31e21b04eac..1cee3c86ab5 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,15 @@ +2013-06-05 Eli Zaretskii + + * xdisp.c (handle_tool_bar_click): When mouse-highlight is off, + don't insist on being invoked on a highlighted tool-bar button. + Avoids losing tool-bar functionality when mouse-highlight is nil. + (note_tool_bar_highlight, note_mode_line_or_margin_highlight): + Don't highlight when mouse-highlight is nil. + (note_mouse_highlight): When mouse-highlight is nil, don't return + right away; instead, run tool-bar and mode-line highlight + subroutine, clear any existing highlight, and revert the mouse + pointer to its default shape. (Bug#14558) + 2013-06-05 Stefan Monnier * lisp.mk (lisp): Add prog-mode.el. diff --git a/src/xdisp.c b/src/xdisp.c index 5ae15cbd0b3..17001c81b53 100644 --- a/src/xdisp.c +++ b/src/xdisp.c @@ -12132,12 +12132,27 @@ handle_tool_bar_click (struct frame *f, int x, int y, int down_p, int hpos, vpos, prop_idx; struct glyph *glyph; Lisp_Object enabled_p; - - /* If not on the highlighted tool-bar item, return. */ + int ts; + + /* If not on the highlighted tool-bar item, and mouse-highlight is + non-nil, return. This is so we generate the tool-bar button + click only when the mouse button is released on the same item as + where it was pressed. However, when mouse-highlight is disabled, + generate the click when the button is released regardless of the + highlight, since tool-bar items are not highlighted in that + case. */ frame_to_window_pixel_xy (w, &x, &y); - if (get_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx) != 0) + ts = get_tool_bar_item (f, x, y, &glyph, &hpos, &vpos, &prop_idx); + if (ts == -1 + || (ts != 0 && !NILP (Vmouse_highlight))) return; + /* When mouse-highlight is off, generate the click for the item + where the button was pressed, disregarding where it was + released. */ + if (NILP (Vmouse_highlight) && !down_p) + prop_idx = last_tool_bar_item; + /* If item is disabled, do nothing. */ enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P); if (NILP (enabled_p)) @@ -12146,7 +12161,8 @@ handle_tool_bar_click (struct frame *f, int x, int y, int down_p, if (down_p) { /* Show item in pressed state. */ - show_mouse_face (hlinfo, DRAW_IMAGE_SUNKEN); + if (!NILP (Vmouse_highlight)) + show_mouse_face (hlinfo, DRAW_IMAGE_SUNKEN); last_tool_bar_item = prop_idx; } else @@ -12156,7 +12172,8 @@ handle_tool_bar_click (struct frame *f, int x, int y, int down_p, EVENT_INIT (event); /* Show item in released state. */ - show_mouse_face (hlinfo, DRAW_IMAGE_RAISED); + if (!NILP (Vmouse_highlight)) + show_mouse_face (hlinfo, DRAW_IMAGE_RAISED); key = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_KEY); @@ -12229,7 +12246,7 @@ note_tool_bar_highlight (struct frame *f, int x, int y) /* If tool-bar item is not enabled, don't highlight it. */ enabled_p = AREF (f->tool_bar_items, prop_idx + TOOL_BAR_ITEM_ENABLED_P); - if (!NILP (enabled_p)) + if (!NILP (enabled_p) && !NILP (Vmouse_highlight)) { /* Compute the x-position of the glyph. In front and past the image is a space. We include this in the highlighted area. */ @@ -27399,7 +27416,7 @@ note_mode_line_or_margin_highlight (Lisp_Object window, int x, int y, if (STRINGP (string)) { mouse_face = Fget_text_property (pos, Qmouse_face, string); - if (!NILP (mouse_face) + if (!NILP (Vmouse_highlight) && !NILP (mouse_face) && ((area == ON_MODE_LINE) || (area == ON_HEADER_LINE)) && glyph) { @@ -27558,8 +27575,7 @@ note_mouse_highlight (struct frame *f, int x, int y) return; #endif - if (NILP (Vmouse_highlight) - || !f->glyphs_initialized_p + if (!f->glyphs_initialized_p || f->pointer_invisible) return; @@ -27649,7 +27665,8 @@ note_mouse_highlight (struct frame *f, int x, int y) #ifdef HAVE_WINDOW_SYSTEM /* Look for :pointer property on image. */ - if (glyph != NULL && glyph->type == IMAGE_GLYPH) + if (!NILP (Vmouse_highlight) + && glyph != NULL && glyph->type == IMAGE_GLYPH) { struct image *img = IMAGE_FROM_ID (f, glyph->u.img_id); if (img != NULL && IMAGEP (img->spec)) @@ -27692,7 +27709,8 @@ note_mouse_highlight (struct frame *f, int x, int y) #endif /* HAVE_WINDOW_SYSTEM */ /* Clear mouse face if X/Y not over text. */ - if (glyph == NULL + if (NILP (Vmouse_highlight) + || glyph == NULL || area != TEXT_AREA || !MATRIX_ROW_DISPLAYS_TEXT_P (MATRIX_ROW (w->current_matrix, vpos)) /* Glyph's OBJECT is an integer for glyphs inserted by the