]> code.delx.au - gnu-emacs/blobdiff - src/w32fns.c
Merge from trunk
[gnu-emacs] / src / w32fns.c
index 16a2fb4dfdd5b015f4bf720e9f65e34cf81f9c38..7f0e6d5e5bfd1b954c725c6ea7387356e132aed6 100644 (file)
@@ -26,7 +26,6 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <limits.h>
 #include <errno.h>
 #include <math.h>
-#include <setjmp.h>
 
 #include "lisp.h"
 #include "w32term.h"
@@ -84,9 +83,7 @@ extern void w32_free_menu_strings (HWND);
 extern const char *map_w32_filename (const char *, const char **);
 extern char * w32_strerror (int error_no);
 
-/* If non-zero, a w32 timer that, when it expires, displays an
-   hourglass cursor on all frames.  */
-static unsigned hourglass_timer = 0;
+/* If non-NULL, a handle to a frame where to display the hourglass cursor.  */
 static HWND hourglass_hwnd = NULL;
 
 #ifndef IDC_HAND
@@ -144,7 +141,7 @@ struct MONITOR_INFO
 };
 
 /* Reportedly, MSVC does not have this in its headers.  */
-#ifdef _MSC_VER
+#if defined (_MSC_VER) && _WIN32_WINNT < 0x0500
 DECLARE_HANDLE(HMONITOR);
 #endif
 
@@ -184,7 +181,6 @@ unsigned int msh_mousewheel = 0;
 #define MOUSE_BUTTON_ID        1
 #define MOUSE_MOVE_ID  2
 #define MENU_FREE_ID 3
-#define HOURGLASS_ID 4
 /* The delay (milliseconds) before a menu is freed after WM_EXITMENULOOP
    is received.  */
 #define MENU_FREE_DELAY 1000
@@ -400,7 +396,7 @@ if the entry is new.  */)
 
   XSETINT (rgb, RGB (XUINT (red), XUINT (green), XUINT (blue)));
 
-  BLOCK_INPUT;
+  block_input ();
 
   /* replace existing entry in w32-color-map or add new entry. */
   entry = Fassoc (name, Vw32_color_map);
@@ -415,7 +411,7 @@ if the entry is new.  */)
       Fsetcdr (entry, rgb);
     }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return (oldrgb);
 }
@@ -678,7 +674,7 @@ w32_default_color_map (void)
   colormap_t *pc = w32_color_map;
   Lisp_Object cmap;
 
-  BLOCK_INPUT;
+  block_input ();
 
   cmap = Qnil;
 
@@ -688,7 +684,7 @@ w32_default_color_map (void)
                         make_number (pc->colorref)),
                  cmap);
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return (cmap);
 }
@@ -705,7 +701,7 @@ w32_color_map_lookup (char *colorname)
 {
   Lisp_Object tail, ret = Qnil;
 
-  BLOCK_INPUT;
+  block_input ();
 
   for (tail = Vw32_color_map; CONSP (tail); tail = XCDR (tail))
     {
@@ -725,7 +721,7 @@ w32_color_map_lookup (char *colorname)
       QUIT;
     }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return ret;
 }
@@ -737,7 +733,7 @@ add_system_logical_colors_to_map (Lisp_Object *system_colors)
   HKEY colors_key;
 
   /* Other registry operations are done with input blocked.  */
-  BLOCK_INPUT;
+  block_input ();
 
   /* Look for "Control Panel/Colors" under User and Machine registry
      settings.  */
@@ -775,7 +771,7 @@ add_system_logical_colors_to_map (Lisp_Object *system_colors)
       RegCloseKey (colors_key);
     }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 }
 
 
@@ -784,7 +780,7 @@ x_to_w32_color (char * colorname)
 {
   register Lisp_Object ret = Qnil;
 
-  BLOCK_INPUT;
+  block_input ();
 
   if (colorname[0] == '#')
     {
@@ -837,7 +833,7 @@ x_to_w32_color (char * colorname)
              pos += 0x8;
              if (i == 2)
                {
-                 UNBLOCK_INPUT;
+                 unblock_input ();
                  XSETINT (ret, colorval);
                  return ret;
                }
@@ -891,7 +887,7 @@ x_to_w32_color (char * colorname)
            {
              if (*end != '\0')
                break;
-             UNBLOCK_INPUT;
+             unblock_input ();
              XSETINT (ret, colorval);
              return ret;
            }
@@ -933,7 +929,7 @@ x_to_w32_color (char * colorname)
            {
              if (*end != '\0')
                break;
-             UNBLOCK_INPUT;
+             unblock_input ();
              XSETINT (ret, colorval);
              return ret;
            }
@@ -968,7 +964,7 @@ x_to_w32_color (char * colorname)
        }
     }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
   return ret;
 }
 
@@ -1107,7 +1103,7 @@ gamma_correct (struct frame *f, COLORREF *color)
    If ALLOC is nonzero, allocate a new colormap cell.  */
 
 int
-w32_defined_color (FRAME_PTR f, char *color, XColor *color_def, int alloc)
+w32_defined_color (FRAME_PTR f, const char *color, XColor *color_def, int alloc)
 {
   register Lisp_Object tem;
   COLORREF w32_color_ref;
@@ -1271,7 +1267,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
     f->output_data.w32->mouse_pixel = FRAME_FOREGROUND_PIXEL (f);
 
 #if 0 /* TODO : Mouse cursor customization.  */
-  BLOCK_INPUT;
+  block_input ();
 
   /* It's not okay to crash if the user selects a screwy cursor.  */
   count = x_catch_errors (FRAME_W32_DISPLAY (f));
@@ -1394,7 +1390,7 @@ x_set_mouse_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
   f->output_data.w32->hand_cursor = hand_cursor;
 
   XFlush (FRAME_W32_DISPLAY (f));
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   update_face_from_frame_parameter (f, Qmouse_color, arg);
 #endif /* TODO */
@@ -1426,12 +1422,12 @@ x_set_cursor_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 
   if (FRAME_W32_WINDOW (f) != 0)
     {
-      BLOCK_INPUT;
+      block_input ();
       /* Update frame's cursor_gc.  */
       f->output_data.w32->cursor_gc->foreground = fore_pixel;
       f->output_data.w32->cursor_gc->background = pixel;
 
-      UNBLOCK_INPUT;
+      unblock_input ();
 
       if (FRAME_VISIBLE_P (f))
        {
@@ -1502,16 +1498,16 @@ x_set_icon_type (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
   if (SYMBOLP (arg) && SYMBOLP (oldval) && EQ (arg, oldval))
     return;
 
-  BLOCK_INPUT;
+  block_input ();
 
   result = x_bitmap_icon (f, arg);
   if (result)
     {
-      UNBLOCK_INPUT;
+      unblock_input ();
       error ("No icon window available");
     }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 }
 
 void
@@ -1531,7 +1527,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
   if (f->output_data.w32->icon_bitmap != 0)
     return;
 
-  BLOCK_INPUT;
+  block_input ();
 
   result = x_text_icon (f,
                        SSDATA ((!NILP (f->icon_name)
@@ -1542,7 +1538,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
 
   if (result)
     {
-      UNBLOCK_INPUT;
+      unblock_input ();
       error ("No icon window available");
     }
 
@@ -1557,7 +1553,7 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
     }
 
   XFlush (FRAME_W32_DISPLAY (f));
-  UNBLOCK_INPUT;
+  unblock_input ();
 #endif
 }
 
@@ -1659,13 +1655,13 @@ x_set_tool_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
       int width = FRAME_PIXEL_WIDTH (f);
       int y = nlines * FRAME_LINE_HEIGHT (f);
 
-      BLOCK_INPUT;
+      block_input ();
       {
         HDC hdc = get_frame_dc (f);
         w32_clear_area (f, hdc, 0, y, width, height);
         release_frame_dc (f, hdc);
       }
-      UNBLOCK_INPUT;
+      unblock_input ();
 
       if (WINDOWP (f->tool_bar_window))
        clear_glyph_matrix (XWINDOW (f->tool_bar_window)->current_matrix);
@@ -1733,9 +1729,9 @@ x_set_name (struct frame *f, Lisp_Object name, int explicit)
       if (STRING_MULTIBYTE (name))
        name = ENCODE_SYSTEM (name);
 
-      BLOCK_INPUT;
+      block_input ();
       SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
-      UNBLOCK_INPUT;
+      unblock_input ();
     }
 }
 
@@ -1779,9 +1775,9 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
       if (STRING_MULTIBYTE (name))
        name = ENCODE_SYSTEM (name);
 
-      BLOCK_INPUT;
+      block_input ();
       SetWindowText (FRAME_W32_WINDOW (f), SDATA (name));
-      UNBLOCK_INPUT;
+      unblock_input ();
     }
 }
 
@@ -2334,13 +2330,39 @@ w32_name_of_message (UINT msg)
 }
 #endif /* EMACSDEBUG */
 
+/* Here's an overview of how Emacs input works on MS-Windows.
+
+   System messages are read and processed by w32_msg_pump below.  This
+   function runs in a separate thread.  It handles a small number of
+   custom WM_EMACS_* messages (posted by the main thread, look for
+   PostMessage calls), and dispatches the rest to w32_wnd_proc, which
+   is the main window procedure for the entire Emacs application.
+
+   w32_wnd_proc also runs in the same separate input thread.  It
+   handles some messages, mostly those that need GDI calls, by itself.
+   For the others, it calls my_post_msg, which inserts the messages
+   into the input queue serviced by w32_read_socket.
+
+   w32_read_socket runs in the main (a.k.a. "Lisp") thread, and is
+   called synchronously from keyboard.c when it is known or suspected
+   that some input is available.  w32_read_socket either handles
+   messages immediately, or converts them into Emacs input events and
+   stuffs them into kbd_buffer, where kbd_buffer_get_event can get at
+   them and process them when read_char and its callers require
+   input.
+
+   Under Cygwin with the W32 toolkit, the use of /dev/windows with
+   select(2) takes the place of w32_read_socket.
+
+   */
+
 /* Main message dispatch loop. */
 
 static void
 w32_msg_pump (deferred_msg * msg_buf)
 {
   MSG msg;
-  int result;
+  WPARAM result;
   HWND focus_window;
 
   msh_mousewheel = RegisterWindowMessage (MSH_MOUSEWHEEL);
@@ -2368,17 +2390,17 @@ w32_msg_pump (deferred_msg * msg_buf)
               CoInitialize (NULL);
              w32_createwindow ((struct frame *) msg.wParam);
              if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
-               abort ();
+               emacs_abort ();
              break;
            case WM_EMACS_SETLOCALE:
              SetThreadLocale (msg.wParam);
              /* Reply is not expected.  */
              break;
            case WM_EMACS_SETKEYBOARDLAYOUT:
-             result = (int) ActivateKeyboardLayout ((HKL) msg.wParam, 0);
+             result = (WPARAM) ActivateKeyboardLayout ((HKL) msg.wParam, 0);
              if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
                                      result, 0))
-               abort ();
+               emacs_abort ();
              break;
            case WM_EMACS_REGISTER_HOT_KEY:
              focus_window = GetFocus ();
@@ -2399,7 +2421,7 @@ w32_msg_pump (deferred_msg * msg_buf)
                  GC.  */
              XSETCAR ((Lisp_Object) ((EMACS_INT) msg.lParam), Qnil);
              if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
-               abort ();
+               emacs_abort ();
              break;
            case WM_EMACS_TOGGLE_LOCK_KEY:
              {
@@ -2431,7 +2453,7 @@ w32_msg_pump (deferred_msg * msg_buf)
                  }
                if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE,
                                        cur_state, 0))
-                 abort ();
+                 emacs_abort ();
              }
              break;
 #ifdef MSG_DEBUG
@@ -2486,11 +2508,11 @@ send_deferred_msg (deferred_msg * msg_buf,
 {
   /* Only input thread can send deferred messages.  */
   if (GetCurrentThreadId () != dwWindowsThreadId)
-    abort ();
+    emacs_abort ();
 
   /* It is an error to send a message that is already deferred.  */
   if (find_deferred_msg (hwnd, msg) != NULL)
-    abort ();
+    emacs_abort ();
 
   /* Enforced synchronization is not needed because this is the only
      function that alters deferred_msg_head, and the following critical
@@ -2563,7 +2585,7 @@ w32_msg_worker (void *arg)
   PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE);
 
   if (!PostThreadMessage (dwMainThreadId, WM_EMACS_DONE, 0, 0))
-    abort ();
+    emacs_abort ();
 
   memset (&dummy_buf, 0, sizeof (dummy_buf));
   dummy_buf.w32msg.msg.hwnd = NULL;
@@ -3224,7 +3246,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                msg = WM_MBUTTONUP;
                button_state &= ~MMOUSE;
 
-               if (button_state) abort ();
+               if (button_state) emacs_abort ();
              }
            else
              return 0;
@@ -3402,12 +3424,6 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
               menubar_in_use = 0;
            }
        }
-      else if (wParam == hourglass_timer)
-       {
-         KillTimer (hwnd, hourglass_timer);
-         hourglass_timer = 0;
-         w32_show_hourglass (x_window_to_frame (dpyinfo, hwnd));
-       }
       return 0;
 
     case WM_NCACTIVATE:
@@ -3455,7 +3471,7 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
        /* Detect if message has already been deferred; in this case
           we cannot return any sensible value to ignore this.  */
        if (find_deferred_msg (hwnd, msg) != NULL)
-         abort ();
+         emacs_abort ();
 
         menubar_in_use = 1;
 
@@ -3930,7 +3946,7 @@ my_create_window (struct frame * f)
   MSG msg;
 
   if (!PostThreadMessage (dwWindowsThreadId, WM_EMACS_CREATEWINDOW, (WPARAM)f, 0))
-    abort ();
+    emacs_abort ();
   GetMessage (&msg, NULL, WM_EMACS_DONE, WM_EMACS_DONE);
 }
 
@@ -3985,7 +4001,7 @@ my_create_tip_window (struct frame *f)
 static void
 w32_window (struct frame *f, long window_prompting, int minibuffer_only)
 {
-  BLOCK_INPUT;
+  block_input ();
 
   /* Use the resource name as the top-level window name
      for looking up resources.  Make a non-Lisp copy
@@ -4017,7 +4033,7 @@ w32_window (struct frame *f, long window_prompting, int minibuffer_only)
     x_set_name (f, name, explicit);
   }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   if (!minibuffer_only && FRAME_EXTERNAL_MENU_BAR (f))
     initialize_frame_menubar (f);
@@ -4048,7 +4064,7 @@ x_icon (struct frame *f, Lisp_Object parms)
   else if (!EQ (icon_x, Qunbound) || !EQ (icon_y, Qunbound))
     error ("Both left and top icon corners of icon must be specified");
 
-  BLOCK_INPUT;
+  block_input ();
 
   if (! EQ (icon_x, Qunbound))
     x_wm_set_icon_position (f, XINT (icon_x), XINT (icon_y));
@@ -4065,7 +4081,7 @@ x_icon (struct frame *f, Lisp_Object parms)
                           : f->name)));
 #endif
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 }
 
 
@@ -4074,7 +4090,7 @@ x_make_gc (struct frame *f)
 {
   XGCValues gc_values;
 
-  BLOCK_INPUT;
+  block_input ();
 
   /* Create the GC's of this frame.
      Note that many default values are used.  */
@@ -4094,7 +4110,7 @@ x_make_gc (struct frame *f)
   f->output_data.w32->white_relief.gc = 0;
   f->output_data.w32->black_relief.gc = 0;
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 }
 
 
@@ -4440,9 +4456,9 @@ This function is an internal primitive--use `make-frame' instead.  */)
   /* Tell the server what size and position, etc, we want, and how
      badly we want them.  This should be done after we have the menu
      bar so that its size can be taken into account.  */
-  BLOCK_INPUT;
+  block_input ();
   x_wm_set_size_hint (f, window_prompting, 0);
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   /* Make the window appear on the frame and enable display, unless
      the caller says not to.  However, with explicit parent, Emacs
@@ -4892,12 +4908,21 @@ terminate Emacs if we can't open the connection.
   unsigned char *xrm_option;
   struct w32_display_info *dpyinfo;
 
+  CHECK_STRING (display);
+
+  /* Signal an error in order to encourage correct use from callers.
+   * If we ever support multiple window systems in the same Emacs,
+   * we'll need callers to be precise about what window system they
+   * want.  */
+
+  if (strcmp (SSDATA (display), "w32") != 0)
+    error ("The name of the display in this Emacs must be \"w32\"");
+
   /* If initialization has already been done, return now to avoid
      overwriting critical parts of one_w32_display_info.  */
   if (w32_in_use)
     return Qnil;
 
-  CHECK_STRING (display);
   if (! NILP (xrm_string))
     CHECK_STRING (xrm_string);
 
@@ -4982,11 +5007,11 @@ If DISPLAY is nil, that stands for the selected frame's display.  */)
   if (dpyinfo->reference_count > 0)
     error ("Display still has frames on it");
 
-  BLOCK_INPUT;
+  block_input ();
   x_destroy_all_bitmaps (dpyinfo);
 
   x_delete_display (dpyinfo);
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return Qnil;
 }
@@ -5055,7 +5080,7 @@ FRAME.  Default is to change on the edit X window.  */)
   CHECK_STRING (prop);
   CHECK_STRING (value);
 
-  BLOCK_INPUT;
+  block_input ();
   prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
   XChangeProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
                   prop_atom, XA_STRING, 8, PropModeReplace,
@@ -5063,7 +5088,7 @@ FRAME.  Default is to change on the edit X window.  */)
 
   /* Make sure the property is set when we return.  */
   XFlush (FRAME_W32_DISPLAY (f));
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return value;
 }
@@ -5079,13 +5104,13 @@ FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
   Atom prop_atom;
 
   CHECK_STRING (prop);
-  BLOCK_INPUT;
+  block_input ();
   prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
   XDeleteProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f), prop_atom);
 
   /* Make sure the property is removed when we return.  */
   XFlush (FRAME_W32_DISPLAY (f));
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return prop;
 }
@@ -5121,7 +5146,7 @@ no value of TYPE (always string in the MS Windows case).  */)
   unsigned long actual_size, bytes_remaining;
 
   CHECK_STRING (prop);
-  BLOCK_INPUT;
+  block_input ();
   prop_atom = XInternAtom (FRAME_W32_DISPLAY (f), SDATA (prop), False);
   rc = XGetWindowProperty (FRAME_W32_DISPLAY (f), FRAME_W32_WINDOW (f),
                           prop_atom, 0, 0, False, XA_STRING,
@@ -5146,7 +5171,7 @@ no value of TYPE (always string in the MS Windows case).  */)
       XFree (tmp_data);
     }
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   return prop_value;
 
@@ -5160,66 +5185,50 @@ no value of TYPE (always string in the MS Windows case).  */)
                                Busy cursor
  ***********************************************************************/
 
-/* Default number of seconds to wait before displaying an hourglass
-   cursor.  Duplicated from xdisp.c, but cannot use the version there
-   due to lack of atimers on w32.  */
-#define DEFAULT_HOURGLASS_DELAY 1
-
-/* Cancel a currently active hourglass timer, and start a new one.  */
-
 void
-start_hourglass (void)
+w32_note_current_window (void)
 {
-  DWORD delay;
-  int secs, msecs = 0;
   struct frame * f = SELECTED_FRAME ();
 
-  /* No cursors on non GUI frames.  */
   if (!FRAME_W32_P (f))
     return;
 
-  cancel_hourglass ();
-
-  if (INTEGERP (Vhourglass_delay)
-      && XINT (Vhourglass_delay) > 0)
-    secs = XFASTINT (Vhourglass_delay);
-  else if (FLOATP (Vhourglass_delay)
-          && XFLOAT_DATA (Vhourglass_delay) > 0)
-    {
-      Lisp_Object tem;
-      tem = Ftruncate (Vhourglass_delay, Qnil);
-      secs = XFASTINT (tem);
-      msecs = (XFLOAT_DATA (Vhourglass_delay) - secs) * 1000;
-    }
-  else
-    secs = DEFAULT_HOURGLASS_DELAY;
-
-  delay = secs * 1000 + msecs;
   hourglass_hwnd = FRAME_W32_WINDOW (f);
-  hourglass_timer = SetTimer (hourglass_hwnd, HOURGLASS_ID, delay, NULL);
 }
 
-
-/* Cancel the hourglass cursor timer if active, hide an hourglass
-   cursor if shown.  */
-
 void
-cancel_hourglass (void)
+show_hourglass (struct atimer *timer)
 {
-  if (hourglass_timer)
-    {
-      KillTimer (hourglass_hwnd, hourglass_timer);
-      hourglass_timer = 0;
-    }
+  struct frame *f;
 
-  if (hourglass_shown_p)
-    w32_hide_hourglass ();
+  hourglass_atimer = NULL;
+
+  block_input ();
+  f = x_window_to_frame (&one_w32_display_info,
+                                      hourglass_hwnd);
+
+  if (f)
+    f->output_data.w32->hourglass_p = 0;
+  else
+    f = SELECTED_FRAME ();
+
+  if (!FRAME_W32_P (f))
+    return;
+
+  w32_show_hourglass (f);
+  unblock_input ();
 }
 
+void
+hide_hourglass (void)
+{
+  block_input ();
+  w32_hide_hourglass ();
+  unblock_input ();
+}
 
-/* Timer function of hourglass_timer.
 
-   Display an hourglass cursor.  Set the hourglass_p flag in display info
+/* Display an hourglass cursor.  Set the hourglass_p flag in display info
    to indicate that an hourglass cursor is shown.  */
 
 static void
@@ -5469,9 +5478,9 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   f->left_fringe_width = 0;
   f->right_fringe_width = 0;
 
-  BLOCK_INPUT;
+  block_input ();
   my_create_tip_window (f);
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   x_make_gc (f);
 
@@ -5577,11 +5586,11 @@ compute_tip_xy (struct frame *f,
       max_x = x_display_pixel_width (FRAME_W32_DISPLAY_INFO (f));
       max_y = x_display_pixel_height (FRAME_W32_DISPLAY_INFO (f));
 
-      BLOCK_INPUT;
+      block_input ();
       GetCursorPos (&pt);
       *root_x = pt.x;
       *root_y = pt.y;
-      UNBLOCK_INPUT;
+      unblock_input ();
 
       /* If multiple monitor support is available, constrain the tip onto
         the current monitor. This improves the above by allowing negative
@@ -5716,7 +5725,7 @@ Text larger than the specified size is clipped.  */)
              call1 (Qcancel_timer, timer);
            }
 
-         BLOCK_INPUT;
+         block_input ();
          compute_tip_xy (f, parms, dx, dy, FRAME_PIXEL_WIDTH (f),
                          FRAME_PIXEL_HEIGHT (f), &root_x, &root_y);
 
@@ -5730,7 +5739,7 @@ Text larger than the specified size is clipped.  */)
                        0, 0, 0, 0,
                        SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
 
-         UNBLOCK_INPUT;
+         unblock_input ();
          goto start_timer;
        }
     }
@@ -5757,7 +5766,7 @@ Text larger than the specified size is clipped.  */)
 
   /* Block input until the tip has been fully drawn, to avoid crashes
      when drawing tips in menus.  */
-  BLOCK_INPUT;
+  block_input ();
 
   /* Create a frame for the tooltip, and record it in the global
      variable tip_frame.  */
@@ -5929,7 +5938,7 @@ Text larger than the specified size is clipped.  */)
   w->must_be_updated_p = 1;
   update_single_window (w, 1);
 
-  UNBLOCK_INPUT;
+  unblock_input ();
 
   /* Restore original current buffer.  */
   set_buffer_internal_1 (old_buffer);
@@ -6069,7 +6078,7 @@ Use a file selection dialog.  Select DEFAULT-FILENAME in the dialog's file
 selection box, if specified.  If MUSTMATCH is non-nil, the returned file
 or directory must exist.
 
-This function is only defined on MS Windows, and X Windows with the
+This function is only defined on NS, MS Windows, and X Windows with the
 Motif or Gtk toolkits.  With the Motif toolkit, ONLY-DIR-P is ignored.
 Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
   (Lisp_Object prompt, Lisp_Object dir, Lisp_Object default_filename, Lisp_Object mustmatch, Lisp_Object only_dir_p)
@@ -6207,7 +6216,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
     {
       int count = SPECPDL_INDEX ();
       specbind (Qinhibit_redisplay, Qt);
-      BLOCK_INPUT;
+      block_input ();
       file_details->lpfnHook = file_dialog_callback;
 
 #ifdef NTGUI_UNICODE
@@ -6215,7 +6224,7 @@ Otherwise, if ONLY-DIR-P is non-nil, the user can only select directories.  */)
 #else /* !NTGUI_UNICODE */
       file_opened = GetOpenFileNameA (file_details);
 #endif /* NTGUI_UNICODE */
-      UNBLOCK_INPUT;
+      unblock_input ();
       unbind_to (count, Qnil);
     }
 
@@ -6481,7 +6490,7 @@ w32_parse_hot_key (Lisp_Object key)
       lisp_modifiers = XINT (Fcar (Fcdr (c)));
       c = Fcar (c);
       if (!SYMBOLP (c))
-       abort ();
+       emacs_abort ();
       vk_code = lookup_vk_code (SDATA (SYMBOL_NAME (c)));
     }
   else if (INTEGERP (c))
@@ -7605,7 +7614,6 @@ only be necessary if the default setting causes problems.  */);
 
   check_window_system_func = check_w32;
 
-  hourglass_timer = 0;
   hourglass_hwnd = NULL;
 
   defsubr (&Sx_show_tip);
@@ -7676,10 +7684,8 @@ globals_of_w32fns (void)
   syms_of_w32uniscribe ();
 }
 
-#undef abort
-
 void
-w32_abort (void)
+emacs_abort (void)
 {
   int button;
   button = MessageBox (NULL,