#include "keyboard.h"
#include "frame.h"
#include "dispextern.h"
+#include "window.h"
#include "blockinput.h"
#include "termhooks.h"
#include "termchar.h"
struct input_event *emacs_ev)
{
static DWORD button_state = 0;
+ static Lisp_Object last_mouse_window;
DWORD but_change, mask;
int i;
{
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)
{
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;
}