diff -ur --exclude-from=exclude.txt emacs-21.2.95-vanilla/src/window.c emacs-21.2.95/src/window.c --- emacs-21.2.95-vanilla/src/window.c Wed Jun 5 20:56:50 2002 +++ emacs-21.2.95/src/window.c Wed Feb 19 13:06:41 2003 @@ -216,6 +216,10 @@ Lisp_Object Vscroll_preserve_screen_position; +/* Nonzero if focus follows mouse mode is on. */ + +int focus_follows_mouse; + #if 0 /* This isn't used anywhere. */ /* Nonzero means we can split a frame even if it is "unsplittable". */ static int inhibit_frame_unsplittable; @@ -5582,6 +5586,28 @@ foreach_window (f, freeze_window_start, (void *) (freeze_p ? f : 0)); } +/* Try to select the window on frame FRAME when the + mouse pointer position at (X, Y) enters it. */ + +void +select_mouse_entered_window (frame, x, y) + FRAME_PTR frame; + int x; + int y; +{ + if (focus_follows_mouse) + { + int part; + Lisp_Object window; + + window = window_from_coordinates (frame, x, y, &part, 0); + if (WINDOW_LIVE_P (window) && + (window != FRAME_SELECTED_WINDOW (frame)) && + !MINI_WINDOW_P (XWINDOW (window)) && + (++part == ON_TEXT)) + Fselect_window (window); + } +} /*********************************************************************** Initialization @@ -5917,6 +5943,10 @@ This variable automatically becomes buffer-local when set."); Fmake_variable_buffer_local (Qwindow_size_fixed); window_size_fixed = 0; + + DEFVAR_BOOL ("focus-follows-mouse", &focus_follows_mouse, + "Non-nil means select a window when the mouse enters it's text area."); + focus_follows_mouse = 1; defsubr (&Sselected_window); defsubr (&Sminibuffer_window); diff -ur --exclude-from=exclude.txt emacs-21.2.95-vanilla/src/window.h emacs-21.2.95/src/window.h --- emacs-21.2.95-vanilla/src/window.h Thu Jan 18 17:09:39 2001 +++ emacs-21.2.95/src/window.h Wed Feb 19 13:07:20 2003 @@ -386,6 +386,7 @@ void *)); extern void grow_mini_window P_ ((struct window *, int)); extern void shrink_mini_window P_ ((struct window *)); +extern void select_mouse_entered_window P_ ((struct frame *, int, int)); /* Make WINDOW display BUFFER as its contents. RUN_HOOKS_P non-zero diff -ur --exclude-from=exclude.txt emacs-21.2.95-vanilla/src/xterm.c emacs-21.2.95/src/xterm.c --- emacs-21.2.95-vanilla/src/xterm.c Tue Oct 15 18:21:45 2002 +++ emacs-21.2.95/src/xterm.c Wed Feb 19 13:08:40 2003 @@ -6658,6 +6658,11 @@ last_mouse_scroll_bar = Qnil; note_mouse_highlight (frame, event->x, event->y); } + + if (!event->state) + /* Clean mouse movement without any keys or buttons pressed. Select + the window under mouse pointer if focus follows mouse is on. */ + select_mouse_entered_window (frame, event->x, event->y); } /* This is used for debugging, to turn off note_mouse_highlight. */