]> code.delx.au - gnu-emacs/blobdiff - src/w32inevt.c
*** empty log message ***
[gnu-emacs] / src / w32inevt.c
index de15f0970b29ad8b48d7a6eeaea254745d31a313..6a0b5e5f1a2f9d15c3d58f910afd6f30753a3d87 100644 (file)
@@ -23,13 +23,20 @@ Boston, MA 02111-1307, USA.
 */
 
 
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
 
 #include <stdlib.h>
 #include <stdio.h>
 #include <windows.h>
 
+#ifndef MOUSE_MOVED
+#define MOUSE_MOVED   1
+#endif
+
 #include "lisp.h"
+#include "keyboard.h"
 #include "frame.h"
 #include "blockinput.h"
 #include "termhooks.h"
@@ -110,7 +117,7 @@ fill_queue (BOOL block)
 static FRAME_PTR 
 get_frame (void)
 {
-  return selected_frame;
+  return SELECTED_FRAME ();
 }
 
 /* Translate console modifiers to emacs modifiers.  
@@ -419,7 +426,7 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
 
   if (lispy_function_keys[event->wVirtualKeyCode] == 0)
     {
-      emacs_ev->kind = ascii_keystroke;
+      emacs_ev->kind = ASCII_KEYSTROKE_EVENT;
 
       if (!NILP (Vw32_recognize_altgr)
          && (event->dwControlKeyState & LEFT_CTRL_PRESSED)
@@ -461,7 +468,7 @@ key_event (KEY_EVENT_RECORD *event, struct input_event *emacs_ev, int *isdead)
     }
   else
     {
-      emacs_ev->kind = non_ascii_keystroke;
+      emacs_ev->kind = NON_ASCII_KEYSTROKE_EVENT;
       XSETINT (emacs_ev->code, event->wVirtualKeyCode);
     }
 
@@ -479,7 +486,7 @@ w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state)
 
   if (NILP (new_state)
       || (NUMBERP (new_state)
-         && (XUINT (new_state)) & 1 != cur_state))
+         && ((XUINT (new_state)) & 1) != cur_state))
     {
       faked_key = vk_code;
 
@@ -501,9 +508,7 @@ w32_console_toggle_lock_key (int vk_code, Lisp_Object new_state)
 /* Mouse position hook.  */
 void 
 w32_console_mouse_position (FRAME_PTR *f,
-#ifndef MULE
                            int insist,
-#endif
                            Lisp_Object *bar_window,
                            enum scroll_bar_part *part,
                            Lisp_Object *x,
@@ -512,14 +517,12 @@ w32_console_mouse_position (FRAME_PTR *f,
 {
   BLOCK_INPUT;
 
-#ifndef MULE  
   insist = insist;
-#endif
 
   *f = get_frame ();
   *bar_window = Qnil;
   *part = 0;
-  selected_frame->mouse_moved = 0;
+  SELECTED_FRAME ()->mouse_moved = 0;
   
   *x = movement_pos.X;
   *y = movement_pos.Y;
@@ -535,7 +538,7 @@ mouse_moved_to (int x, int y)
   /* If we're in the same place, ignore it */
   if (x != movement_pos.X || y != movement_pos.Y)
     {
-      selected_frame->mouse_moved = 1;
+      SELECTED_FRAME ()->mouse_moved = 1;
       movement_pos.X = x;
       movement_pos.Y = y;
       movement_time = GetTickCount ();
@@ -554,9 +557,10 @@ mouse_moved_to (int x, int y)
      Right == 2
    Others increase from there.  */
 
-static int emacs_button_translation[NUM_MOUSE_BUTTONS] =
+#define NUM_TRANSLATED_MOUSE_BUTTONS 3
+static int emacs_button_translation[NUM_TRANSLATED_MOUSE_BUTTONS] =
 {
-  0, 2, 1, 3, 4,
+  0, 2, 1
 };
 
 static int 
@@ -580,23 +584,21 @@ do_mouse_event (MOUSE_EVENT_RECORD *event,
   if (event->dwButtonState == button_state)
     return 0;
   
-  emacs_ev->kind = mouse_click;
+  emacs_ev->kind = MOUSE_CLICK_EVENT;
   
   /* Find out what button has changed state since the last button event.  */
   but_change = button_state ^ event->dwButtonState;
   mask = 1;
-  for (i = 0; i < NUM_MOUSE_BUTTONS; i++, mask <<= 1)
+  for (i = 0; mask; i++, mask <<= 1)
     if (but_change & mask)
       {
-       XSETINT (emacs_ev->code, emacs_button_translation[i]);
+        if (i < NUM_TRANSLATED_MOUSE_BUTTONS)
+          XSETINT (emacs_ev->code, emacs_button_translation[i]);
+        else
+          XSETINT (emacs_ev->code, i);
        break;
       }
 
-  /* If the changed button is out of emacs' range (highly unlikely)
-     ignore this event.  */
-  if (i == NUM_MOUSE_BUTTONS)
-    return 0;
-  
   button_state = event->dwButtonState;
   emacs_ev->timestamp = GetTickCount ();
   emacs_ev->modifiers = w32_kbd_mods_to_emacs (event->dwControlKeyState, 0) |