]> code.delx.au - gnu-emacs/blobdiff - src/w32inevt.c
Merge from emacs-24
[gnu-emacs] / src / w32inevt.c
index 0b4bc5580450976e66294cc060c2847608b8b661..a85fdbbe43570e7e5821b6051f752fd9f23f266c 100644 (file)
@@ -1,6 +1,5 @@
 /* Input event support for Emacs on the Microsoft W32 API.
-   Copyright (C) 1992, 1993, 1995, 2001, 2002, 2003, 2004, 2005, 2006,
-                 2007, 2008, 2009, 2010, 2011  Free Software Foundation, Inc.
+   Copyright (C) 1992-1993, 1995, 2001-2012  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -36,40 +35,22 @@ 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"
 #include "w32heap.h"
 #include "w32term.h"
 
-/* stdin, from ntterm */
+/* stdin, from w32console.c */
 extern HANDLE keyboard_handle;
 
 /* Info for last mouse motion */
 static COORD movement_pos;
-static DWORD movement_time;
-
-/* from keyboard.c */
-extern void reinvoke_input_signal (void);
-
-/* from w32console.c */
-extern int w32_use_full_screen_buffer;
+static Time movement_time;
 
 /* from w32fns.c */
-extern Lisp_Object Vw32_alt_is_meta;
 extern unsigned int map_keypad_keys (unsigned int, unsigned int);
-
-/* from w32term */
-extern Lisp_Object Vw32_capslock_is_shiftlock;
-extern Lisp_Object Vw32_enable_caps_lock;
-extern Lisp_Object Vw32_enable_num_lock;
-extern Lisp_Object Vw32_recognize_altgr;
-extern Lisp_Object Vw32_pass_lwindow_to_system;
-extern Lisp_Object Vw32_pass_rwindow_to_system;
-extern Lisp_Object Vw32_phantom_key_code;
-extern Lisp_Object Vw32_lwindow_modifier;
-extern Lisp_Object Vw32_rwindow_modifier;
-extern Lisp_Object Vw32_apps_modifier;
-extern Lisp_Object Vw32_scroll_lock_modifier;
 extern unsigned int w32_key_to_modifier (int key);
 
 /* Event queue */
@@ -279,8 +260,6 @@ w32_kbd_patch_key (KEY_EVENT_RECORD *event)
 }
 
 
-extern const char *const lispy_function_keys[];
-
 static int faked_key = 0;
 
 /* return code -1 means that event_queue_ptr won't be incremented.
@@ -567,7 +546,7 @@ w32_console_mouse_position (FRAME_PTR *f,
                            enum scroll_bar_part *part,
                            Lisp_Object *x,
                            Lisp_Object *y,
-                           unsigned long *time)
+                           Time *time)
 {
   BLOCK_INPUT;
 
@@ -589,7 +568,7 @@ w32_console_mouse_position (FRAME_PTR *f,
 static void
 mouse_moved_to (int x, int y)
 {
-  /* If we're in the same place, ignore it */
+  /* If we're in the same place, ignore it */
   if (x != movement_pos.X || y != movement_pos.Y)
     {
       SELECTED_FRAME ()->mouse_moved = 1;
@@ -622,14 +601,63 @@ 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;
 
   if (event->dwEventFlags == MOUSE_MOVED)
     {
-      /* For movement events we just note that the mouse has moved
-        so that emacs will generate drag events.  */
-      mouse_moved_to (event->dwMousePosition.X, event->dwMousePosition.Y);
+      FRAME_PTR f = SELECTED_FRAME ();
+      Mouse_HLInfo *hlinfo = MOUSE_HL_INFO (f);
+      int mx = event->dwMousePosition.X, my = event->dwMousePosition.Y;
+
+      mouse_moved_to (mx, my);
+
+      if (f->mouse_moved)
+       {
+         if (hlinfo->mouse_face_hidden)
+           {
+             hlinfo->mouse_face_hidden = 0;
+             clear_mouse_face (hlinfo);
+           }
+
+         /* 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;
+
+         previous_help_echo_string = help_echo_string;
+         help_echo_string = help_echo_object = help_echo_window = Qnil;
+         help_echo_pos = -1;
+         note_mouse_highlight (f, mx, my);
+         /* If the contents of the global variable help_echo has
+            changed (inside note_mouse_highlight), generate a HELP_EVENT.  */
+         if (!NILP (help_echo_string) || !NILP (previous_help_echo_string))
+           gen_help_event (help_echo_string, selected_frame, help_echo_window,
+                           help_echo_object, help_echo_pos);
+       }
       return 0;
     }
 
@@ -700,7 +728,6 @@ w32_console_read_socket (struct terminal *terminal,
                          int expected,
                          struct input_event *hold_quit)
 {
-  BOOL no_events = TRUE;
   int nev, ret = 0, add;
   int isdead;
 
@@ -780,4 +807,3 @@ w32_console_read_socket (struct terminal *terminal,
   UNBLOCK_INPUT;
   return ret;
 }
-