From mboxrd@z Thu Jan 1 00:00:00 1970 Path: quimby.gnus.org!not-for-mail From: storm@cua.dk (Kim F. Storm) Newsgroups: gmane.emacs.devel Subject: Re: Proposal: Only highlight mouse-face when mouse is moved Date: 15 Feb 2002 23:27:07 +0100 Message-ID: <5xd6z65qkk.fsf@kfs2.cua.dk> References: <5x7kph8wer.fsf@kfs2.cua.dk> <200202140312.g1E3Cxc09227@aztec.santafe.edu> <5xheoke65y.fsf@kfs2.cua.dk> <200202151036.g1FAas007336@santafe.santafe.edu> <3405-Fri15Feb2002144425+0200-eliz@is.elta.co.il> <5xn0ya6frd.fsf@kfs2.cua.dk> <7458-Fri15Feb2002153338+0200-eliz@is.elta.co.il> NNTP-Posting-Host: quimby2.netfonds.no Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: quimby2.netfonds.no 1013812796 30666 195.204.10.66 (15 Feb 2002 22:39:56 GMT) X-Complaints-To: usenet@quimby2.netfonds.no NNTP-Posting-Date: 15 Feb 2002 22:39:56 GMT Cc: emacs-devel@gnu.org Original-Received: from fencepost.gnu.org ([199.232.76.164]) by quimby2.netfonds.no with esmtp (Exim 3.12 #1 (Debian)) id 16br1H-0007yV-00 for ; Fri, 15 Feb 2002 23:39:55 +0100 Original-Received: from localhost ([127.0.0.1] helo=fencepost.gnu.org) by fencepost.gnu.org with esmtp (Exim 3.33 #1 (Debian)) id 16bqp7-0005YQ-00; Fri, 15 Feb 2002 17:27:21 -0500 Original-Received: from mail.filanet.dk ([195.215.206.179]) by fencepost.gnu.org with smtp (Exim 3.33 #1 (Debian)) id 16bqnq-0005WC-00 for ; Fri, 15 Feb 2002 17:26:03 -0500 Original-Received: from kfs2.cua.dk.cua.dk (unknown [10.1.82.3]) by mail.filanet.dk (Postfix) with SMTP id 5EE577C047; Fri, 15 Feb 2002 22:25:57 +0000 (GMT) Original-To: Eli Zaretskii In-Reply-To: <7458-Fri15Feb2002153338+0200-eliz@is.elta.co.il> Original-Lines: 444 User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2.50 Errors-To: emacs-devel-admin@gnu.org X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.0.5 Precedence: bulk List-Help: List-Post: List-Subscribe: , List-Id: Emacs development discussions. List-Unsubscribe: , List-Archive: Xref: quimby.gnus.org gmane.emacs.devel:1185 X-Report-Spam: http://spam.gmane.org/gmane.emacs.devel:1185 "Eli Zaretskii" writes: > > Have any of you actually tried the patch I posted yesterday? > > I cannot try it because you only posted a patch that's specific to X, > and I don't have an X installation here. Here is a complete patch (except for NEWS and ChangeLog) which also (attempts to) work for the w32 and msdos ports -- neither of which I can test myself. So I'd really appreciate some help testing (and evaluating) this. Index: src/frame.c =================================================================== RCS file: /cvs/emacs/src/frame.c,v retrieving revision 1.279 diff -c -r1.279 frame.c *** src/frame.c 14 Jan 2002 13:47:02 -0000 1.279 --- src/frame.c 15 Feb 2002 21:50:25 -0000 *************** *** 79,84 **** --- 79,85 ---- Lisp_Object Vterminal_frame; Lisp_Object Vdefault_frame_alist; Lisp_Object Vmouse_position_function; + Lisp_Object Vmouse_highlight; static void set_menu_bar_lines_1 (window, n) *************** *** 2534,2539 **** --- 2535,2548 ---- This abnormal hook exists for the benefit of packages like `xt-mouse.el' which need to do mouse handling at the Lisp level. */); Vmouse_position_function = Qnil; + + DEFVAR_LISP ("mouse-highlight", &Vmouse_highlight, + doc: /* If non-nil, clickable text is highlighted when mouse is over it. + If the value is an integer, highlighting is only shown after moving the + mouse, while keyboard input turns off the highlight even when the mouse + is over the clickable text. However, the mouse shape still indicates + when the mouse is over clickable text. */); + Vmouse_highlight = make_number (1); DEFVAR_KBOARD ("default-minibuffer-frame", Vdefault_minibuffer_frame, doc: /* Minibufferless frames use this frame's minibuffer. Index: src/frame.h =================================================================== RCS file: /cvs/emacs/src/frame.h,v retrieving revision 1.94 diff -c -r1.94 frame.h *** src/frame.h 1 Dec 2001 01:14:09 -0000 1.94 --- src/frame.h 15 Feb 2002 21:50:25 -0000 *************** *** 661,666 **** --- 661,668 ---- extern Lisp_Object Vdefault_frame_alist; extern Lisp_Object Vterminal_frame; + + extern Lisp_Object Vmouse_highlight; /* Device-independent scroll bar stuff. */ Index: src/msdos.c =================================================================== RCS file: /cvs/emacs/src/msdos.c,v retrieving revision 1.160 diff -c -r1.160 msdos.c *** src/msdos.c 11 Feb 2002 07:14:56 -0000 1.160 --- src/msdos.c 15 Feb 2002 21:50:26 -0000 *************** *** 1181,1189 **** Mouse Highlight (and friends..) ************************************************************************/ - /* This is used for debugging, to turn off note_mouse_highlight. */ - int disable_mouse_highlight; - /* If non-nil, dos_rawgetc generates an event to display that string. (The display is done in keyboard.c:read_char, by calling show_help_echo.) */ --- 1181,1186 ---- *************** *** 1235,1240 **** --- 1232,1240 ---- /* There's no sense to do anything if the mouse face isn't realized. */ if (hl > 0) { + if (dpyinfo->mouse_face_hidden) + goto set_cursor_shape; + fp = FACE_FROM_ID (SELECTED_FRAME(), dpyinfo->mouse_face_face_id); if (!fp) goto set_cursor_shape; *************** *** 1489,1495 **** if (mouse_preempted) return; ! if (disable_mouse_highlight || !f->glyphs_initialized_p) return; --- 1489,1495 ---- if (mouse_preempted) return; ! if (NILP (Vmouse_highlight) || !f->glyphs_initialized_p) return; *************** *** 2584,2589 **** --- 2584,2590 ---- the_only_x_display.display_info.mouse_face_mouse_x = the_only_x_display.display_info.mouse_face_mouse_y = 0; the_only_x_display.display_info.mouse_face_defer = 0; + the_only_x_display.display_info.mouse_face_hidden = 0; init_frame_faces (sf); *************** *** 3154,3159 **** --- 3155,3161 ---- { struct input_event event; union REGS regs; + struct display_info *dpyinfo = FRAME_X_DISPLAY_INFO (SELECTED_FRAME()); #ifndef HAVE_X_WINDOWS /* Maybe put the cursor where it should be. */ *************** *** 3363,3369 **** make_event: if (code == 0) continue; ! if (code >= 0x100) event.kind = non_ascii_keystroke; else --- 3365,3377 ---- make_event: if (code == 0) continue; ! ! if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) ! { ! dpyinfo->mouse_face_hidden = 1; ! clear_mouse_face (dpyinfo); ! } ! if (code >= 0x100) event.kind = non_ascii_keystroke; else *************** *** 3388,3393 **** --- 3396,3407 ---- might need to update mouse highlight. */ if (mouse_last_x != mouse_prev_x || mouse_last_y != mouse_prev_y) { + if (dpyinfo->mouse_face_hidden) + { + dpyinfo->mouse_face_hidden = 0; + clear_mouse_face (dpyinfo); + } + previous_help_echo = help_echo; help_echo = help_echo_object = help_echo_window = Qnil; help_echo_pos = -1; *************** *** 3429,3435 **** if (mouse_button_count == 2 && but < 2) { int x2, y2; /* don't clobber original coordinates */ - /* If only one button is pressed, wait 100 msec and check again. This way, Speedy Gonzales isn't punished, while the slow get their chance. */ --- 3443,3448 ---- *************** *** 3473,3479 **** else return ((prev_get_char = dos_rawgetc ()) != -1); } - /* Read a key. Return -1 if no key is ready. */ dos_keyread () --- 3486,3491 ---- Index: src/msdos.h =================================================================== RCS file: /cvs/emacs/src/msdos.h,v retrieving revision 1.23 diff -c -r1.23 msdos.h *** src/msdos.h 30 Oct 2001 15:32:26 -0000 1.23 --- src/msdos.h 15 Feb 2002 21:50:26 -0000 *************** *** 80,85 **** --- 80,88 ---- /* Nonzero means defer mouse-motion highlighting. */ int mouse_face_defer; + + /* Nonzero means that the mouse highlight should not be shown. */ + int mouse_face_hidden; }; /* This is a cut-down version of the one in xterm.h, which see. */ Index: src/w32term.c =================================================================== RCS file: /cvs/emacs/src/w32term.c,v retrieving revision 1.141 diff -c -r1.141 w32term.c *** src/w32term.c 6 Feb 2002 20:57:44 -0000 1.141 --- src/w32term.c 15 Feb 2002 21:50:29 -0000 *************** *** 6314,6324 **** } } - /* This is used for debugging, to turn off note_mouse_highlight. */ - - int disable_mouse_highlight; - - /************************************************************************ Mouse Face --- 6314,6319 ---- *************** *** 6535,6541 **** if (popup_activated ()) return; ! if (disable_mouse_highlight || !f->glyphs_initialized_p) return; --- 6530,6536 ---- if (popup_activated ()) return; ! if (NILP (Vmouse_highlight) || !f->glyphs_initialized_p) return; *************** *** 7444,7449 **** --- 7439,7446 ---- if (/* If window is in the process of being destroyed, don't bother to do anything. */ w->current_matrix != NULL + /* Don't update mouse highlight if hidden */ + && (draw != DRAW_MOUSE_FACE || !dpyinfo->mouse_face_hidden) /* Recognize when we are called to operate on rows that don't exist anymore. This can happen when a window is split. */ && dpyinfo->mouse_face_end_row < w->current_matrix->nrows) *************** *** 8642,8647 **** --- 8639,8650 ---- if (f && !f->iconified) { + if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) + { + dpyinfo->mouse_face_hidden = 1; + clear_mouse_face (dpyinfo); + } + if (temp_index == sizeof temp_buffer / sizeof (short)) temp_index = 0; temp_buffer[temp_index++] = msg.msg.wParam; *************** *** 8663,8668 **** --- 8666,8677 ---- if (f && !f->iconified) { + if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) + { + dpyinfo->mouse_face_hidden = 1; + clear_mouse_face (dpyinfo); + } + if (temp_index == sizeof temp_buffer / sizeof (short)) temp_index = 0; temp_buffer[temp_index++] = msg.msg.wParam; *************** *** 8689,8694 **** --- 8698,8709 ---- else f = x_window_to_frame (dpyinfo, msg.msg.hwnd); + if (dpyinfo->mouse_face_hidden) + { + dpyinfo->mouse_face_hidden = 0; + clear_mouse_face (dpyinfo); + } + if (f) note_mouse_movement (f, &msg.msg); else *************** *** 10852,10857 **** --- 10867,10873 ---- dpyinfo->mouse_face_face_id = DEFAULT_FACE_ID; dpyinfo->mouse_face_window = Qnil; dpyinfo->mouse_face_overlay = Qnil; + dpyinfo->mouse_face_hidden = 0; /* TODO: dpyinfo->gray */ } Index: src/w32term.h =================================================================== RCS file: /cvs/emacs/src/w32term.h,v retrieving revision 1.42 diff -c -r1.42 w32term.h *** src/w32term.h 20 Jan 2002 23:10:35 -0000 1.42 --- src/w32term.h 15 Feb 2002 21:50:29 -0000 *************** *** 195,200 **** --- 195,203 ---- /* Nonzero means defer mouse-motion highlighting. */ int mouse_face_defer; + /* Nonzero means that the mouse highlight should not be shown. */ + int mouse_face_hidden; + int mouse_face_image_state; char *w32_id_name; Index: src/xterm.c =================================================================== RCS file: /cvs/emacs/src/xterm.c,v retrieving revision 1.704 diff -c -r1.704 xterm.c *** src/xterm.c 15 Feb 2002 09:36:05 -0000 1.704 --- src/xterm.c 15 Feb 2002 21:50:33 -0000 *************** *** 6662,6672 **** } } - /* This is used for debugging, to turn off note_mouse_highlight. */ - - int disable_mouse_highlight; - - /************************************************************************ Mouse Face --- 6662,6667 ---- *************** *** 6884,6890 **** return; #endif ! if (disable_mouse_highlight || !f->glyphs_initialized_p) return; --- 6879,6885 ---- return; #endif ! if (NILP (Vmouse_highlight) || !f->glyphs_initialized_p) return; *************** *** 7790,7795 **** --- 7785,7792 ---- if (/* If window is in the process of being destroyed, don't bother to do anything. */ w->current_matrix != NULL + /* Don't update mouse highlight if hidden */ + && (draw != DRAW_MOUSE_FACE || !dpyinfo->mouse_face_hidden) /* Recognize when we are called to operate on rows that don't exist anymore. This can happen when a window is split. */ && dpyinfo->mouse_face_end_row < w->current_matrix->nrows) *************** *** 10430,10435 **** --- 10427,10438 ---- case KeyPress: f = x_any_window_to_frame (dpyinfo, event.xkey.window); + if (!dpyinfo->mouse_face_hidden && INTEGERP (Vmouse_highlight)) + { + dpyinfo->mouse_face_hidden = 1; + clear_mouse_face (dpyinfo); + } + #if defined USE_MOTIF && defined USE_TOOLKIT_SCROLL_BARS if (f == 0) { *************** *** 10842,10847 **** --- 10845,10856 ---- else f = x_window_to_frame (dpyinfo, event.xmotion.window); + if (dpyinfo->mouse_face_hidden) + { + dpyinfo->mouse_face_hidden = 0; + clear_mouse_face (dpyinfo); + } + if (f) note_mouse_movement (f, &event.xmotion); else *************** *** 14656,14661 **** --- 14665,14671 ---- dpyinfo->mouse_face_overlay = Qnil; dpyinfo->mouse_face_mouse_x = dpyinfo->mouse_face_mouse_y = 0; dpyinfo->mouse_face_defer = 0; + dpyinfo->mouse_face_hidden = 0; dpyinfo->x_focus_frame = 0; dpyinfo->x_focus_event_frame = 0; dpyinfo->x_highlight_frame = 0; Index: src/xterm.h =================================================================== RCS file: /cvs/emacs/src/xterm.h,v retrieving revision 1.126 diff -c -r1.126 xterm.h *** src/xterm.h 27 Jan 2002 16:44:10 -0000 1.126 --- src/xterm.h 15 Feb 2002 21:50:33 -0000 *************** *** 223,228 **** --- 223,231 ---- /* Nonzero means defer mouse-motion highlighting. */ int mouse_face_defer; + /* Nonzero means that the mouse highlight should not be shown. */ + int mouse_face_hidden; + int mouse_face_image_state; char *x_id_name; -- Kim F. Storm http://www.cua.dk _______________________________________________ Emacs-devel mailing list Emacs-devel@gnu.org http://mail.gnu.org/mailman/listinfo/emacs-devel