]> git.eshelyaron.com Git - emacs.git/commitdiff
Support mouse-autoselect-window on w32 text-mode terminals.
authorEli Zaretskii <eliz@gnu.org>
Sat, 26 May 2012 11:46:20 +0000 (14:46 +0300)
committerEli Zaretskii <eliz@gnu.org>
Sat, 26 May 2012 11:46:20 +0000 (14:46 +0300)
 src/w32inevt.c (do_mouse_event): Support mouse-autoselect-window.

src/ChangeLog
src/w32inevt.c

index 1a90acbb23b4fd360ce709625a701ba26b38e6e4..934d7f5f780db68a3f8c714a752501bd02e70acb 100644 (file)
@@ -1,3 +1,7 @@
+2012-05-26  Eli Zaretskii  <eliz@gnu.org>
+
+       * w32inevt.c (do_mouse_event): Support mouse-autoselect-window.
+
 2012-05-26  Eli Zaretskii  <eliz@gnu.org>
 
        Refactor mouse highlight invocation for w32 console.
index da8ec0eadb7306da334c86b611fb08b751e0b298..5f6856413e82b799ac1cca4a8832f97336413882 100644 (file)
@@ -35,6 +35,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "keyboard.h"
 #include "frame.h"
 #include "dispextern.h"
+#include "window.h"
 #include "blockinput.h"
 #include "termhooks.h"
 #include "termchar.h"
@@ -600,6 +601,7 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
                struct input_event *emacs_ev)
 {
   static DWORD button_state = 0;
+  static Lisp_Object last_mouse_window;
   DWORD but_change, mask;
   int i;
 
@@ -607,8 +609,9 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
     {
       FRAME_PTR f = SELECTED_FRAME ();
       Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+      int mx = event->dwMousePosition.X, my = event->dwMousePosition.Y;
 
-      mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y);
+      mouse_moved_to (mx, my);
 
       if (f->mouse_moved)
        {
@@ -618,8 +621,34 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
              clear_mouse_face (hlinfo);
            }
 
-         note_mouse_highlight (f, event->dwMousePosition.X,
-                               event->dwMousePosition.Y);
+         note_mouse_highlight (f, mx, my);
+
+         /* Generate SELECT_WINDOW_EVENTs when needed.  */
+         if (!NILP (Vmouse_autoselect_window))
+           {
+             Lisp_Object mouse_window = window_from_coordinates (f, mx, my,
+                                                                 0, 0);
+             /* A window will be selected only when it is not
+                selected now, and the last mouse movement event was
+                not in it.  A minibuffer window will be selected iff
+                it is active.  */
+             if (WINDOWP (mouse_window)
+                 && !EQ (mouse_window, last_mouse_window)
+                 && !EQ (mouse_window, selected_window))
+               {
+                 struct input_event event;
+
+                 EVENT_INIT (event);
+                 event.kind = SELECT_WINDOW_EVENT;
+                 event.frame_or_window = mouse_window;
+                 event.arg = Qnil;
+                 event.timestamp = movement_time;
+                 kbd_buffer_store_event (&event);
+               }
+             last_mouse_window = mouse_window;
+           }
+         else
+           last_mouse_window = Qnil;
        }
       return 0;
     }