src/w32*.c: Clean up extern declarations.
[bpt/emacs.git] / src / w32fns.c
index 96ecf43..0c899cd 100644 (file)
@@ -1,7 +1,6 @@
 /* Graphical user interface functions for the Microsoft W32 API.
-   Copyright (C) 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
-                 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2010
-                 Free Software Foundation, Inc.
+
+Copyright (C) 1989, 1992-2011  Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -61,6 +60,8 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include <dlgs.h>
 #include <imm.h>
 #define FILE_NAME_TEXT_FIELD edt1
+#define FILE_NAME_COMBO_BOX cmb13
+#define FILE_NAME_LIST lst1
 
 #include "font.h"
 #include "w32font.h"
@@ -79,121 +80,19 @@ extern void w32_menu_display_help (HWND, HMENU, UINT, UINT);
 extern void w32_free_menu_strings (HWND);
 extern const char *map_w32_filename (const char *, const char **);
 
-extern int quit_char;
-
-extern char *lispy_function_keys[];
-
-/* The colormap for converting color names to RGB values */
-Lisp_Object Vw32_color_map;
-
-/* Non nil if alt key presses are passed on to Windows.  */
-Lisp_Object Vw32_pass_alt_to_system;
-
-/* Non nil if alt key is translated to meta_modifier, nil if it is translated
-   to alt_modifier.  */
-Lisp_Object Vw32_alt_is_meta;
-
-/* If non-zero, the windows virtual key code for an alternative quit key. */
-int w32_quit_key;
-
-/* Non nil if left window key events are passed on to Windows (this only
-   affects whether "tapping" the key opens the Start menu).  */
-Lisp_Object Vw32_pass_lwindow_to_system;
-
-/* Non nil if right window key events are passed on to Windows (this
-   only affects whether "tapping" the key opens the Start menu).  */
-Lisp_Object Vw32_pass_rwindow_to_system;
-
-/* Virtual key code used to generate "phantom" key presses in order
-   to stop system from acting on Windows key events.  */
-Lisp_Object Vw32_phantom_key_code;
-
-/* Modifier associated with the left "Windows" key, or nil to act as a
-   normal key.  */
-Lisp_Object Vw32_lwindow_modifier;
-
-/* Modifier associated with the right "Windows" key, or nil to act as a
-   normal key.  */
-Lisp_Object Vw32_rwindow_modifier;
-
-/* Modifier associated with the "Apps" key, or nil to act as a normal
-   key.  */
-Lisp_Object Vw32_apps_modifier;
-
-/* Value is nil if Num Lock acts as a function key.  */
-Lisp_Object Vw32_enable_num_lock;
-
-/* Value is nil if Caps Lock acts as a function key.  */
-Lisp_Object Vw32_enable_caps_lock;
-
-/* Modifier associated with Scroll Lock, or nil to act as a normal key.  */
-Lisp_Object Vw32_scroll_lock_modifier;
-
-/* Switch to control whether we inhibit requests for synthesized bold
-   and italic versions of fonts.  */
-int w32_enable_synthesized_fonts;
-
-/* Enable palette management. */
-Lisp_Object Vw32_enable_palette;
-
-/* Control how close left/right button down events must be to
-   be converted to a middle button down event. */
-int w32_mouse_button_tolerance;
-
-/* Minimum interval between mouse movement (and scroll bar drag)
-   events that are passed on to the event loop. */
-int w32_mouse_move_interval;
-
-/* Flag to indicate if XBUTTON events should be passed on to Windows.  */
-static int w32_pass_extra_mouse_buttons_to_system;
-
-/* Flag to indicate if media keys should be passed on to Windows.  */
-static int w32_pass_multimedia_buttons_to_system;
-
-/* Non nil if no window manager is in use.  */
-Lisp_Object Vx_no_window_manager;
-
 /* If non-zero, a w32 timer that, when it expires, displays an
    hourglass cursor on all frames.  */
 static unsigned hourglass_timer = 0;
 static HWND hourglass_hwnd = NULL;
 
-#if 0 /* TODO: Mouse cursor customization.  */
-/* The background and shape of the mouse pointer, and shape when not
-   over text or in the modeline.  */
-Lisp_Object Vx_pointer_shape, Vx_nontext_pointer_shape, Vx_mode_pointer_shape;
-Lisp_Object Vx_hourglass_pointer_shape, Vx_window_horizontal_drag_shape;
-
-/* The shape when over mouse-sensitive text.  */
-
-Lisp_Object Vx_sensitive_text_pointer_shape;
-#endif
-
 #ifndef IDC_HAND
 #define IDC_HAND MAKEINTRESOURCE(32649)
 #endif
 
-/* Color of chars displayed in cursor box.  */
-Lisp_Object Vx_cursor_fore_pixel;
-
 /* Nonzero if using Windows.  */
 
 static int w32_in_use;
 
-/* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.  */
-
-Lisp_Object Vx_pixel_size_width_font_regexp;
-
-/* Alist of bdf fonts and the files that define them.  */
-Lisp_Object Vw32_bdf_filename_alist;
-
-/* A flag to control whether fonts are matched strictly or not.  */
-static int w32_strict_fontnames;
-
-/* A flag to control whether we should only repaint if GetUpdateRect
-   indicates there is an update region.  */
-static int w32_strict_painting;
-
 Lisp_Object Qnone;
 Lisp_Object Qsuppress_icon;
 Lisp_Object Qundefined_color;
@@ -208,9 +107,6 @@ Lisp_Object Qcontrol;
 Lisp_Object Qshift;
 
 
-/* The ANSI codepage.  */
-int w32_ansi_code_page;
-
 /* Prefix for system colors.  */
 #define SYSTEM_COLOR_PREFIX "System"
 #define SYSTEM_COLOR_PREFIX_LEN (sizeof (SYSTEM_COLOR_PREFIX) - 1)
@@ -245,7 +141,7 @@ struct MONITOR_INFO
 };
 
 /* Reportedly, VS 6 does not have this in its headers.  */
-#if defined(_MSC_VER) && _MSC_VER < 1300
+#if defined (_MSC_VER) && _MSC_VER < 1300
 DECLARE_HANDLE(HMONITOR);
 #endif
 
@@ -262,7 +158,6 @@ typedef BOOL (WINAPI * GetMonitorInfo_Proc)
   (IN HMONITOR monitor, OUT struct MONITOR_INFO* info);
 
 TrackMouseEvent_Proc track_mouse_event_fn = NULL;
-ClipboardSequence_Proc clipboard_sequence_fn = NULL;
 ImmGetCompositionString_Proc get_composition_string_fn = NULL;
 ImmGetContext_Proc get_ime_context_fn = NULL;
 ImmReleaseContext_Proc release_ime_context_fn = NULL;
@@ -288,27 +183,10 @@ unsigned int msh_mousewheel = 0;
 #define MENU_FREE_DELAY 1000
 static unsigned menu_free_timer = 0;
 
-/* The below are defined in frame.c.  */
-
-extern Lisp_Object Vmenu_bar_mode, Vtool_bar_mode;
-extern Lisp_Object Vwindow_system_version;
-
 #ifdef GLYPH_DEBUG
 int image_cache_refcount, dpyinfo_refcount;
 #endif
 
-
-/* From w32term.c. */
-extern int w32_num_mouse_buttons;
-extern Lisp_Object Vw32_recognize_altgr;
-
-extern HWND w32_system_caret_hwnd;
-
-extern int w32_system_caret_height;
-extern int w32_system_caret_x;
-extern int w32_system_caret_y;
-extern int w32_use_visible_system_caret;
-
 static HWND w32_visible_system_caret_hwnd;
 
 /* From w32menu.c  */
@@ -434,8 +312,6 @@ void x_explicitly_set_name (struct frame *, Lisp_Object, Lisp_Object);
 void x_set_menu_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
 void x_set_title (struct frame *, Lisp_Object, Lisp_Object);
 void x_set_tool_bar_lines (struct frame *, Lisp_Object, Lisp_Object);
-static void x_edge_detection (struct frame *, struct image *, Lisp_Object,
-                              Lisp_Object);
 
 
 \f
@@ -475,8 +351,7 @@ DEFUN ("w32-define-rgb-color", Fw32_define_rgb_color,
 This adds or updates a named color to `w32-color-map', making it
 available for use.  The original entry's RGB ref is returned, or nil
 if the entry is new.  */)
-    (red, green, blue, name)
-    Lisp_Object red, green, blue, name;
+  (Lisp_Object red, Lisp_Object green, Lisp_Object blue, Lisp_Object name)
 {
   Lisp_Object rgb;
   Lisp_Object oldrgb = Qnil;
@@ -762,7 +637,7 @@ colormap_t w32_color_map[] =
 
 DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
        0, 0, 0, doc: /* Return the default color map.  */)
-     ()
+  (void)
 {
   int i;
   colormap_t *pc = w32_color_map;
@@ -783,25 +658,6 @@ DEFUN ("w32-default-color-map", Fw32_default_color_map, Sw32_default_color_map,
   return (cmap);
 }
 
-static Lisp_Object
-w32_to_x_color (Lisp_Object rgb)
-{
-  Lisp_Object color;
-
-  CHECK_NUMBER (rgb);
-
-  BLOCK_INPUT;
-
-  color = Frassq (rgb, Vw32_color_map);
-
-  UNBLOCK_INPUT;
-
-  if (!NILP (color))
-    return (Fcar (color));
-  else
-    return Qnil;
-}
-
 static Lisp_Object
 w32_color_map_lookup (char *colorname)
 {
@@ -1329,7 +1185,10 @@ x_set_foreground_color (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
   if (FRAME_W32_WINDOW (f) != 0)
     {
       if (x->cursor_pixel == old_fg)
-       x->cursor_pixel = fg;
+       {
+         x->cursor_pixel = fg;
+         x->cursor_gc->background = fg;
+       }
 
       update_face_from_frame_parameter (f, Qforeground_color, arg);
       if (FRAME_VISIBLE_P (f))
@@ -1636,11 +1495,11 @@ x_set_icon_name (struct frame *f, Lisp_Object arg, Lisp_Object oldval)
   BLOCK_INPUT;
 
   result = x_text_icon (f,
-                       (char *) SDATA ((!NILP (f->icon_name)
-                                        ? f->icon_name
-                                        : !NILP (f->title)
-                                        ? f->title
-                                        : f->name)));
+                       SSDATA ((!NILP (f->icon_name)
+                                ? f->icon_name
+                                : !NILP (f->title)
+                                ? f->title
+                                : f->name)));
 
   if (result)
     {
@@ -1885,7 +1744,6 @@ x_set_title (struct frame *f, Lisp_Object name, Lisp_Object old_name)
     }
 }
 
-
 void
 x_set_scroll_bar_default_width (struct frame *f)
 {
@@ -1915,7 +1773,7 @@ w32_load_cursor (LPCTSTR name)
   return cursor;
 }
 
-extern LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM);
+static LRESULT CALLBACK w32_wnd_proc (HWND, UINT, WPARAM, LPARAM);
 
 static BOOL
 w32_init_class (HINSTANCE hinst)
@@ -2687,7 +2545,7 @@ post_character_message (HWND hwnd, UINT msg,
 
 /* Main window procedure */
 
-LRESULT CALLBACK
+static LRESULT CALLBACK
 w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   struct frame *f;
@@ -3123,9 +2981,6 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
          HIMC context;
          struct window *w;
 
-         if (!context)
-           break;
-
          f = x_window_to_frame (dpyinfo, hwnd);
          w = XWINDOW (FRAME_SELECTED_WINDOW (f));
 
@@ -3143,6 +2998,10 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
                                - WINDOW_MODE_LINE_HEIGHT (w));
 
          context = get_ime_context_fn (hwnd);
+
+         if (!context)
+           break;
+
          set_ime_composition_window_fn (context, &form);
          release_ime_context_fn (hwnd, context);
        }
@@ -3932,7 +3791,6 @@ w32_wnd_proc (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
       return DefWindowProc (hwnd, msg, wParam, lParam);
     }
 
-
   /* The most common default return code for handled messages is 0.  */
   return 0;
 }
@@ -4007,7 +3865,7 @@ w32_window (struct frame *f, long window_prompting, int minibuffer_only)
      Elsewhere we specify the window name for the window manager.  */
 
   {
-    char *str = (char *) SDATA (Vx_resource_name);
+    char *str = SSDATA (Vx_resource_name);
     f->namebuf = (char *) xmalloc (strlen (str) + 1);
     strcpy (f->namebuf, str);
   }
@@ -4073,9 +3931,9 @@ x_icon (struct frame *f, Lisp_Object parms)
         ? IconicState
         : NormalState));
 
-  x_text_icon (f, (char *) SDATA ((!NILP (f->icon_name)
-                                    ? f->icon_name
-                                    : f->name)));
+  x_text_icon (f, SSDATA ((!NILP (f->icon_name)
+                          ? f->icon_name
+                          : f->name)));
 #endif
 
   UNBLOCK_INPUT;
@@ -4191,8 +4049,7 @@ then `default-minibuffer-frame' must be a frame whose minibuffer can
 be shared by the new frame.
 
 This function is an internal primitive--use `make-frame' instead.  */)
-  (parameters)
-     Lisp_Object parameters;
+  (Lisp_Object parameters)
 {
   struct frame *f;
   Lisp_Object frame, tem;
@@ -4361,8 +4218,6 @@ This function is an internal primitive--use `make-frame' instead.  */)
                       "background", "Background", RES_TYPE_STRING);
   x_default_parameter (f, parameters, Qmouse_color, build_string ("black"),
                       "pointerColor", "Foreground", RES_TYPE_STRING);
-  x_default_parameter (f, parameters, Qcursor_color, build_string ("black"),
-                      "cursorColor", "Foreground", RES_TYPE_STRING);
   x_default_parameter (f, parameters, Qborder_color, build_string ("black"),
                       "borderColor", "BorderColor", RES_TYPE_STRING);
   x_default_parameter (f, parameters, Qscreen_gamma, Qnil,
@@ -4374,7 +4229,6 @@ This function is an internal primitive--use `make-frame' instead.  */)
   x_default_parameter (f, parameters, Qright_fringe, Qnil,
                       "rightFringe", "RightFringe", RES_TYPE_NUMBER);
 
-
   /* Init faces before x_default_parameter is called for scroll-bar
      parameters because that function calls x_set_scroll_bar_width,
      which calls change_frame_size, which calls Fset_window_buffer,
@@ -4484,9 +4338,9 @@ This function is an internal primitive--use `make-frame' instead.  */)
   /* Initialize `default-minibuffer-frame' in case this is the first
      frame on this terminal.  */
   if (FRAME_HAS_MINIBUF_P (f)
-      && (!FRAMEP (kb->Vdefault_minibuffer_frame)
-          || !FRAME_LIVE_P (XFRAME (kb->Vdefault_minibuffer_frame))))
-    kb->Vdefault_minibuffer_frame = frame;
+      && (!FRAMEP (KVAR (kb, Vdefault_minibuffer_frame))
+          || !FRAME_LIVE_P (XFRAME (KVAR (kb, Vdefault_minibuffer_frame)))))
+    KVAR (kb, Vdefault_minibuffer_frame) = frame;
 
   /* All remaining specified parameters, which have not been "used"
      by x_get_arg and friends, now go in the misc. alist of the frame.  */
@@ -4520,8 +4374,7 @@ x_get_focus_frame (struct frame *frame)
 
 DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
        doc: /* Give FRAME input focus, raising to foreground if necessary.  */)
-  (frame)
-     Lisp_Object frame;
+  (Lisp_Object frame)
 {
   x_focus_on_frame (check_x_frame (frame));
   return Qnil;
@@ -4529,9 +4382,9 @@ DEFUN ("x-focus-frame", Fx_focus_frame, Sx_focus_frame, 1, 1, 0,
 
 \f
 DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
-       doc: /* Internal function called by `color-defined-p', which see.  */)
-  (color, frame)
-     Lisp_Object color, frame;
+       doc: /* Internal function called by `color-defined-p', which see.
+\(Note that the Nextstep version of this function ignores FRAME.)  */)
+  (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
   FRAME_PTR f = check_x_frame (frame);
@@ -4546,8 +4399,7 @@ DEFUN ("xw-color-defined-p", Fxw_color_defined_p, Sxw_color_defined_p, 1, 2, 0,
 
 DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
        doc: /* Internal function called by `color-values', which see.  */)
-  (color, frame)
-     Lisp_Object color, frame;
+  (Lisp_Object color, Lisp_Object frame)
 {
   XColor foo;
   FRAME_PTR f = check_x_frame (frame);
@@ -4567,8 +4419,7 @@ DEFUN ("xw-color-values", Fxw_color_values, Sxw_color_values, 1, 2, 0,
 
 DEFUN ("xw-display-color-p", Fxw_display_color_p, Sxw_display_color_p, 0, 1, 0,
        doc: /* Internal function called by `display-color-p', which see.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
@@ -4585,8 +4436,7 @@ Note that color displays do support shades of gray.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
@@ -4602,8 +4452,7 @@ DEFUN ("x-display-pixel-width", Fx_display_pixel_width,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
@@ -4616,8 +4465,7 @@ DEFUN ("x-display-pixel-height", Fx_display_pixel_height,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
@@ -4630,8 +4478,7 @@ DEFUN ("x-display-planes", Fx_display_planes, Sx_display_planes,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
@@ -4644,8 +4491,7 @@ DEFUN ("x-display-color-cells", Fx_display_color_cells, Sx_display_color_cells,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
   HDC hdc;
@@ -4674,8 +4520,7 @@ DEFUN ("x-server-max-request-size", Fx_server_max_request_size,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
@@ -4687,8 +4532,7 @@ DEFUN ("x-server-vendor", Fx_server_vendor, Sx_server_vendor, 0, 1, 0,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   return build_string ("Microsoft Corp.");
 }
@@ -4702,8 +4546,7 @@ release number.  See also the function `x-server-vendor'.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   return Fcons (make_number (w32_major_version),
                Fcons (make_number (w32_minor_version),
@@ -4715,8 +4558,7 @@ DEFUN ("x-display-screens", Fx_display_screens, Sx_display_screens, 0, 1, 0,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   return make_number (1);
 }
@@ -4727,8 +4569,7 @@ DEFUN ("x-display-mm-height", Fx_display_mm_height,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
   HDC hdc;
@@ -4748,8 +4589,7 @@ DEFUN ("x-display-mm-width", Fx_display_mm_width, Sx_display_mm_width, 0, 1, 0,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
 
@@ -4772,8 +4612,7 @@ The value may be `always', `when-mapped', or `not-useful'.
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   return intern ("not-useful");
 }
@@ -4787,8 +4626,7 @@ The value is one of the symbols `static-gray', `gray-scale',
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-       (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
   Lisp_Object result = Qnil;
@@ -4811,8 +4649,7 @@ DEFUN ("x-display-save-under", Fx_display_save_under,
 The optional argument DISPLAY specifies which display to ask about.
 DISPLAY should be either a frame or a display name (a string).
 If omitted or nil, that stands for the selected frame's display.  */)
-  (display)
-     Lisp_Object display;
+  (Lisp_Object display)
 {
   return Qnil;
 }
@@ -4874,7 +4711,7 @@ x_display_info_for_name (Lisp_Object name)
   validate_x_resource_name ();
 
   dpyinfo = w32_term_init (name, (unsigned char *)0,
-                            (char *) SDATA (Vx_resource_name));
+                          SSDATA (Vx_resource_name));
 
   if (dpyinfo == 0)
     error ("Cannot connect to server %s", SDATA (name));
@@ -4886,13 +4723,13 @@ x_display_info_for_name (Lisp_Object name)
 }
 
 DEFUN ("x-open-connection", Fx_open_connection, Sx_open_connection,
-       1, 3, 0, doc: /* Open a connection to a server.
+       1, 3, 0, doc: /* Open a connection to a display server.
 DISPLAY is the name of the display to connect to.
 Optional second arg XRM-STRING is a string of resources in xrdb format.
 If the optional third arg MUST-SUCCEED is non-nil,
-terminate Emacs if we can't open the connection.  */)
-  (display, xrm_string, must_succeed)
-     Lisp_Object display, xrm_string, must_succeed;
+terminate Emacs if we can't open the connection.
+\(In the Nextstep version, the last two arguments are currently ignored.)  */)
+  (Lisp_Object display, Lisp_Object xrm_string, Lisp_Object must_succeed)
 {
   unsigned char *xrm_option;
   struct w32_display_info *dpyinfo;
@@ -4937,7 +4774,7 @@ terminate Emacs if we can't open the connection.  */)
   add_system_logical_colors_to_map (&Vw32_color_map);
 
   if (! NILP (xrm_string))
-    xrm_option = (unsigned char *) SDATA (xrm_string);
+    xrm_option = SDATA (xrm_string);
   else
     xrm_option = (unsigned char *) 0;
 
@@ -4958,7 +4795,7 @@ terminate Emacs if we can't open the connection.  */)
   /* This is what opens the connection and sets x_current_display.
      This also initializes many symbols, such as those used for input.  */
   dpyinfo = w32_term_init (display, xrm_option,
-                            (char *) SDATA (Vx_resource_name));
+                          SSDATA (Vx_resource_name));
 
   if (dpyinfo == 0)
     {
@@ -4980,8 +4817,7 @@ DEFUN ("x-close-connection", Fx_close_connection,
        doc: /* Close the connection to DISPLAY's server.
 For DISPLAY, specify either a frame or a display name (a string).
 If DISPLAY is nil, that stands for the selected frame's display.  */)
-  (display)
-  Lisp_Object display;
+  (Lisp_Object display)
 {
   struct w32_display_info *dpyinfo = check_x_display_info (display);
   int i;
@@ -5000,7 +4836,7 @@ If DISPLAY is nil, that stands for the selected frame's display.  */)
 
 DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
        doc: /* Return the list of display names that Emacs has connections to.  */)
-  ()
+  (void)
 {
   Lisp_Object tail, result;
 
@@ -5012,9 +4848,18 @@ DEFUN ("x-display-list", Fx_display_list, Sx_display_list, 0, 0, 0,
 }
 
 DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
-       doc: /* This is a noop on W32 systems.  */)
-     (on, display)
-     Lisp_Object display, on;
+       doc: /* If ON is non-nil, report X errors as soon as the erring request is made.
+This function only has an effect on X Windows.  With MS Windows, it is
+defined but does nothing.
+
+If ON is nil, allow buffering of requests.
+Turning on synchronization prohibits the Xlib routines from buffering
+requests and seriously degrades performance, but makes debugging much
+easier.
+The optional second argument TERMINAL specifies which display to act on.
+TERMINAL should be a terminal object, a frame or a display name (a string).
+If TERMINAL is omitted or nil, that stands for the selected frame's display.  */)
+  (Lisp_Object on, Lisp_Object display)
 {
   return Qnil;
 }
@@ -5028,11 +4873,12 @@ DEFUN ("x-synchronize", Fx_synchronize, Sx_synchronize, 1, 2, 0,
 DEFUN ("x-change-window-property", Fx_change_window_property,
        Sx_change_window_property, 2, 6, 0,
        doc: /* Change window property PROP to VALUE on the X window of FRAME.
-VALUE may be a string or a list of conses, numbers and/or strings.
-If an element in the list is a string, it is converted to
-an Atom and the value of the Atom is used.  If an element is a cons,
-it is converted to a 32 bit number where the car is the 16 top bits and the
-cdr is the lower 16 bits.
+PROP must be a string.  VALUE may be a string or a list of conses,
+numbers and/or strings.  If an element in the list is a string, it is
+converted to an atom and the value of the Atom is used.  If an element
+is a cons, it is converted to a 32 bit number where the car is the 16
+top bits and the cdr is the lower 16 bits.
+
 FRAME nil or omitted means use the selected frame.
 If TYPE is given and non-nil, it is the name of the type of VALUE.
 If TYPE is not given or nil, the type is STRING.
@@ -5040,11 +4886,8 @@ FORMAT gives the size in bits of each element if VALUE is a list.
 It must be one of 8, 16 or 32.
 If VALUE is a string or FORMAT is nil or not given, FORMAT defaults to 8.
 If OUTER_P is non-nil, the property is changed for the outer X window of
-FRAME.  Default is to change on the edit X window.
-
-Value is VALUE.  */)
-     (prop, value, frame, type, format, outer_p)
-     Lisp_Object prop, value, frame, type, format, outer_p;
+FRAME.  Default is to change on the edit X window.  */)
+  (Lisp_Object prop, Lisp_Object value, Lisp_Object frame, Lisp_Object type, Lisp_Object format, Lisp_Object outer_p)
 {
 #if 0 /* TODO : port window properties to W32 */
   struct frame *f = check_x_frame (frame);
@@ -5073,8 +4916,7 @@ DEFUN ("x-delete-window-property", Fx_delete_window_property,
        Sx_delete_window_property, 1, 2, 0,
        doc: /* Remove window property PROP from X window of FRAME.
 FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
-  (prop, frame)
-     Lisp_Object prop, frame;
+  (Lisp_Object prop, Lisp_Object frame)
 {
 #if 0 /* TODO : port window properties to W32 */
 
@@ -5098,11 +4940,21 @@ FRAME nil or omitted means use the selected frame.  Value is PROP.  */)
 DEFUN ("x-window-property", Fx_window_property, Sx_window_property,
        1, 2, 0,
        doc: /* Value is the value of window property PROP on FRAME.
-If FRAME is nil or omitted, use the selected frame.  Value is nil
-if FRAME hasn't a property with name PROP or if PROP has no string
-value.  */)
-  (prop, frame)
-     Lisp_Object prop, frame;
+If FRAME is nil or omitted, use the selected frame.
+
+On MS Windows, this function only accepts the PROP and FRAME arguments.
+
+On X Windows, the following optional arguments are also accepted:
+If TYPE is nil or omitted, get the property as a string.
+Otherwise TYPE is the name of the atom that denotes the type expected.
+If SOURCE is non-nil, get the property on that window instead of from
+FRAME.  The number 0 denotes the root window.
+If DELETE_P is non-nil, delete the property after retreiving it.
+If VECTOR_RET_P is non-nil, don't return a string but a vector of values.
+
+Value is nil if FRAME hasn't a property with name PROP or if PROP has
+no value of TYPE (always string in the MS Windows case).  */)
+  (Lisp_Object prop, Lisp_Object frame)
 {
 #if 0 /* TODO : port window properties to W32 */
 
@@ -5159,8 +5011,6 @@ value.  */)
    cursor.  Duplicated from xdisp.c, but cannot use the version there
    due to lack of atimers on w32.  */
 #define DEFAULT_HOURGLASS_DELAY 1
-extern Lisp_Object Vhourglass_delay;
-
 /* Return non-zero if houglass timer has been started or hourglass is shown.  */
 /* PENDING: if W32 can use atimers (atimer.[hc]) then the common impl in
            xdisp.c could be used. */
@@ -5292,10 +5142,6 @@ Window tip_window;
 
 Lisp_Object last_show_tip_args;
 
-/* Maximum size for tooltips; a cons (COLUMNS . ROWS).  */
-
-Lisp_Object Vx_max_tooltip_size;
-
 
 static Lisp_Object
 unwind_create_tip_frame (Lisp_Object frame)
@@ -5369,7 +5215,7 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   Fset_window_buffer (FRAME_ROOT_WINDOW (f), buffer, Qnil);
   old_buffer = current_buffer;
   set_buffer_internal_1 (XBUFFER (buffer));
-  current_buffer->truncate_lines = Qnil;
+  BVAR (current_buffer, truncate_lines) = Qnil;
   specbind (Qinhibit_read_only, Qt);
   specbind (Qinhibit_modification_hooks, Qt);
   Ferase_buffer ();
@@ -5502,9 +5348,8 @@ x_create_tip_frame (struct w32_display_info *dpyinfo,
   change_frame_size (f, height, width, 1, 0, 0);
 
   /* Add `tooltip' frame parameter's default value. */
-  if (NILP (Fframe_parameter (frame, intern ("tooltip"))))
-    Fmodify_frame_parameters (frame, Fcons (Fcons (intern ("tooltip"), Qt),
-                                           Qnil));
+  if (NILP (Fframe_parameter (frame, Qtooltip)))
+    Fmodify_frame_parameters (frame, Fcons (Fcons (Qtooltip, Qt), Qnil));
 
   /* Set up faces after all frame parameters are known.  This call
      also merges in face attributes specified for new frames.
@@ -5670,15 +5515,14 @@ DY added (default is -10).
 
 A tooltip's maximum size is specified by `x-max-tooltip-size'.
 Text larger than the specified size is clipped.  */)
-  (string, frame, parms, timeout, dx, dy)
-     Lisp_Object string, frame, parms, timeout, dx, dy;
+  (Lisp_Object string, Lisp_Object frame, Lisp_Object parms, Lisp_Object timeout, Lisp_Object dx, Lisp_Object dy)
 {
   struct frame *f;
   struct window *w;
   int root_x, root_y;
   struct buffer *old_buffer;
   struct text_pos pos;
-  int i, width, height;
+  int i, width, height, seen_reversed_p;
   struct gcpro gcpro1, gcpro2, gcpro3, gcpro4;
   int old_windows_or_buffers_changed = windows_or_buffers_changed;
   int count = SPECPDL_INDEX ();
@@ -5801,14 +5645,14 @@ Text larger than the specified size is clipped.  */)
   /* Display the tooltip text in a temporary buffer.  */
   old_buffer = current_buffer;
   set_buffer_internal_1 (XBUFFER (XWINDOW (FRAME_ROOT_WINDOW (f))->buffer));
-  current_buffer->truncate_lines = Qnil;
+  BVAR (current_buffer, truncate_lines) = Qnil;
   clear_glyph_matrix (w->desired_matrix);
   clear_glyph_matrix (w->current_matrix);
   SET_TEXT_POS (pos, BEGV, BEGV_BYTE);
-  try_window (FRAME_ROOT_WINDOW (f), pos, 0);
+  try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
 
   /* Compute width and height of the tooltip.  */
-  width = height = 0;
+  width = height = seen_reversed_p = 0;
   for (i = 0; i < w->desired_matrix->nrows; ++i)
     {
       struct glyph_row *row = &w->desired_matrix->rows[i];
@@ -5822,25 +5666,81 @@ Text larger than the specified size is clipped.  */)
       /* Let the row go over the full width of the frame.  */
       row->full_width_p = 1;
 
-#ifdef TODO /* Investigate why some fonts need more width than is
-              calculated for some tooltips.  */
-      /* There's a glyph at the end of rows that is use to place
-        the cursor there.  Don't include the width of this glyph.  */
+      row_width = row->pixel_width;
       if (row->used[TEXT_AREA])
        {
-         last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
-         row_width = row->pixel_width - last->pixel_width;
+         if (!row->reversed_p)
+           {
+             /* There's a glyph at the end of rows that is used to
+                place the cursor there.  Don't include the width of
+                this glyph.  */
+             last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+             if (INTEGERP (last->object))
+               row_width -= last->pixel_width;
+           }
+         else
+           {
+             /* There could be a stretch glyph at the beginning of R2L
+                rows that is produced by extend_face_to_end_of_line.
+                Don't count that glyph.  */
+             struct glyph *g = row->glyphs[TEXT_AREA];
+
+             if (g->type == STRETCH_GLYPH && INTEGERP (g->object))
+               {
+                 row_width -= g->pixel_width;
+                 seen_reversed_p = 1;
+               }
+           }
        }
-      else
-#endif
-       row_width = row->pixel_width;
 
-      /* TODO: find why tips do not draw along baseline as instructed.  */
       height += row->height;
       width = max (width, row_width);
     }
 
-  /* Add the frame's internal border to the width and height the X
+  /* If we've seen partial-length R2L rows, we need to re-adjust the
+     tool-tip frame width and redisplay it again, to avoid over-wide
+     tips due to the stretch glyph that extends R2L lines to full
+     width of the frame.  */
+  if (seen_reversed_p)
+    {
+      /* w->total_cols and FRAME_TOTAL_COLS want the width in columns,
+        not in pixels.  */
+      width /= WINDOW_FRAME_COLUMN_WIDTH (w);
+      w->total_cols = make_number (width);
+      FRAME_TOTAL_COLS (f) = width;
+      adjust_glyphs (f);
+      w->pseudo_window_p = 1;
+      clear_glyph_matrix (w->desired_matrix);
+      clear_glyph_matrix (w->current_matrix);
+      try_window (FRAME_ROOT_WINDOW (f), pos, TRY_WINDOW_IGNORE_FONTS_CHANGE);
+      width = height = 0;
+      /* Recompute width and height of the tooltip.  */
+      for (i = 0; i < w->desired_matrix->nrows; ++i)
+       {
+         struct glyph_row *row = &w->desired_matrix->rows[i];
+         struct glyph *last;
+         int row_width;
+
+         if (!row->enabled_p || !row->displays_text_p)
+           break;
+         row->full_width_p = 1;
+         row_width = row->pixel_width;
+         if (row->used[TEXT_AREA] && !row->reversed_p)
+           {
+             last = &row->glyphs[TEXT_AREA][row->used[TEXT_AREA] - 1];
+             if (INTEGERP (last->object))
+               row_width -= last->pixel_width;
+           }
+
+         height += row->height;
+         width = max (width, row_width);
+       }
+    }
+
+  /* Round up the height to an integral multiple of FRAME_LINE_HEIGHT.  */
+  if (height % FRAME_LINE_HEIGHT (f) != 0)
+    height += FRAME_LINE_HEIGHT (f) - height % FRAME_LINE_HEIGHT (f);
+  /* Add the frame's internal border to the width and height the w32
      window should have.  */
   height += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
   width += 2 * FRAME_INTERNAL_BORDER_WIDTH (f);
@@ -5859,11 +5759,13 @@ Text larger than the specified size is clipped.  */)
                      FRAME_EXTERNAL_MENU_BAR (f));
 
     /* Position and size tooltip, and put it in the topmost group.
-       The add-on of 3 to the 5th argument is a kludge: without it,
-       some fonts cause the last character of the tip to be truncated,
-       for some obscure reason.  */
+       The add-on of FRAME_COLUMN_WIDTH to the 5th argument is a
+       peculiarity of w32 display: without it, some fonts cause the
+       last character of the tip to be truncated or wrapped around to
+       the next line.  */
     SetWindowPos (FRAME_W32_WINDOW (f), HWND_TOPMOST,
-                 root_x, root_y, rect.right - rect.left + 3,
+                 root_x, root_y,
+                 rect.right - rect.left + FRAME_COLUMN_WIDTH (f),
                  rect.bottom - rect.top, SWP_NOACTIVATE);
 
     /* Ensure tooltip is on top of other topmost windows (eg menus).  */
@@ -5900,7 +5802,7 @@ Text larger than the specified size is clipped.  */)
 DEFUN ("x-hide-tip", Fx_hide_tip, Sx_hide_tip, 0, 0, 0,
        doc: /* Hide the current tooltip window, if there is any.
 Value is t if tooltip was open, nil otherwise.  */)
-  ()
+  (void)
 {
   int count;
   Lisp_Object deleted, frame, timer;
@@ -5937,14 +5839,13 @@ Value is t if tooltip was open, nil otherwise.  */)
 /***********************************************************************
                        File selection dialog
  ***********************************************************************/
-extern Lisp_Object Qfile_name_history;
 
 /* Callback for altering the behavior of the Open File dialog.
    Makes the Filename text field contain "Current Directory" and be
    read-only when "Directories" is selected in the filter.  This
    allows us to work around the fact that the standard Open File
    dialog does not support directories.  */
-UINT CALLBACK
+static UINT CALLBACK
 file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 {
   if (msg == WM_NOTIFY)
@@ -5956,13 +5857,37 @@ file_dialog_callback (HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
        {
          HWND dialog = GetParent (hwnd);
          HWND edit_control = GetDlgItem (dialog, FILE_NAME_TEXT_FIELD);
+         HWND list = GetDlgItem (dialog, FILE_NAME_LIST);
 
-         /* Directories is in index 2.  */
+         /* At least on Windows 7, the above attempt to get the window handle
+            to the File Name Text Field fails.  The following code does the
+            job though.  Note that this code is based on my examination of the
+            window hierarchy using Microsoft Spy++.  bk */
+         if (edit_control == NULL)
+           {
+             HWND tmp = GetDlgItem (dialog, FILE_NAME_COMBO_BOX);
+             if (tmp)
+               {
+                 tmp = GetWindow (tmp, GW_CHILD);
+                 if (tmp)
+                   edit_control = GetWindow (tmp, GW_CHILD);
+               }
+           }
+
+         /* Directories is in index 2.  */
          if (notify->lpOFN->nFilterIndex == 2)
            {
              CommDlg_OpenSave_SetControlText (dialog, FILE_NAME_TEXT_FIELD,
                                               "Current Directory");
              EnableWindow (edit_control, FALSE);
+             /* Note that at least on Windows 7, the above call to EnableWindow
+                disables the window that would ordinarily have focus.  If we
+                do not set focus to some other window here, focus will land in
+                no man's land and the user will be unable to tab through the
+                dialog box (pressing tab will only result in a beep).
+                Avoid that problem by setting focus to the list here.  */
+             if (notify->hdr.code == CDN_INITDONE)
+               SetFocus (list);
            }
          else
            {
@@ -5992,12 +5917,14 @@ typedef struct
 
 DEFUN ("x-file-dialog", Fx_file_dialog, Sx_file_dialog, 2, 5, 0,
        doc: /* Read file name, prompting with PROMPT in directory DIR.
-Use a file selection dialog.
-Select DEFAULT-FILENAME in the dialog's file selection box, if
-specified.  Ensure that file exists if MUSTMATCH is non-nil.
-If ONLY-DIR-P is non-nil, the user can only select directories.  */)
-  (prompt, dir, default_filename, mustmatch, only_dir_p)
-     Lisp_Object prompt, dir, default_filename, mustmatch, only_dir_p;
+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
+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)
 {
   struct frame *f = SELECTED_FRAME ();
   Lisp_Object file = Qnil;
@@ -6037,6 +5964,13 @@ If ONLY-DIR-P is non-nil, the user can only select directories.  */)
   else
     filename[0] = '\0';
 
+  /* The code in file_dialog_callback that attempts to set the text
+     of the file name edit window when handling the CDN_INITDONE
+     WM_NOTIFY message does not work.  Setting filename to "Current
+     Directory" in the only_dir_p case here does work however.  */
+  if (filename[0] == 0 && ! NILP (only_dir_p))
+    strcpy (filename, "Current Directory");
+
   {
     NEWOPENFILENAME new_file_details;
     BOOL file_opened = FALSE;
@@ -6125,8 +6059,7 @@ If ONLY-DIR-P is non-nil, the user can only select directories.  */)
 DEFUN ("system-move-file-to-trash", Fsystem_move_file_to_trash,
        Ssystem_move_file_to_trash, 1, 1, 0,
        doc: /* Move file or directory named FILENAME to the recycle bin.  */)
-     (filename)
-     Lisp_Object filename;
+  (Lisp_Object filename)
 {
   Lisp_Object handler;
   Lisp_Object encoded_file;
@@ -6188,8 +6121,7 @@ to activate the menubar for keyboard access.  #xf140 activates the
 screen saver if defined.
 
 If optional parameter FRAME is not specified, use selected frame.  */)
-  (command, frame)
-     Lisp_Object command, frame;
+  (Lisp_Object command, Lisp_Object frame)
 {
   FRAME_PTR f = check_x_frame (frame);
 
@@ -6242,8 +6174,7 @@ an integer representing a ShowWindow flag:
   1 - start normally
   3 - start maximized
   6 - start minimized  */)
-  (operation, document, parameters, show_flag)
-     Lisp_Object operation, document, parameters, show_flag;
+  (Lisp_Object operation, Lisp_Object document, Lisp_Object parameters, Lisp_Object show_flag)
 {
   Lisp_Object current_dir;
   char *errstr;
@@ -6251,7 +6182,7 @@ an integer representing a ShowWindow flag:
   CHECK_STRING (document);
 
   /* Encode filename, current directory and parameters.  */
-  current_dir = ENCODE_FILE (current_buffer->directory);
+  current_dir = ENCODE_FILE (BVAR (current_buffer, directory));
   document = ENCODE_FILE (document);
   if (STRINGP (parameters))
     parameters = ENCODE_SYSTEM (parameters);
@@ -6275,7 +6206,7 @@ an integer representing a ShowWindow flag:
        code_convert_string_norecord (make_unibyte_string (errstr,
                                                           strlen (errstr)),
                                      Vlocale_coding_system, 0);
-      errstr = (char *)SDATA (decoded);
+      errstr = SSDATA (decoded);
     }
   error ("ShellExecute failed: %s", errstr);
 }
@@ -6380,8 +6311,7 @@ modifier is interpreted as Alt if `w32-alt-is-meta' is t, and hyper
 is always interpreted as the Windows modifier keys.
 
 The return value is the hotkey-id if registered, otherwise nil.  */)
-  (key)
-     Lisp_Object key;
+  (Lisp_Object key)
 {
   key = w32_parse_hot_key (key);
 
@@ -6413,8 +6343,7 @@ The return value is the hotkey-id if registered, otherwise nil.  */)
 DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key,
        Sw32_unregister_hot_key, 1, 1, 0,
        doc: /* Unregister KEY as a hot-key combination.  */)
-  (key)
-     Lisp_Object key;
+  (Lisp_Object key)
 {
   Lisp_Object item;
 
@@ -6446,7 +6375,7 @@ DEFUN ("w32-unregister-hot-key", Fw32_unregister_hot_key,
 DEFUN ("w32-registered-hot-keys", Fw32_registered_hot_keys,
        Sw32_registered_hot_keys, 0, 0, 0,
        doc: /* Return list of registered hot-key IDs.  */)
-  ()
+  (void)
 {
   return Fdelq (Qnil, Fcopy_sequence (w32_grabbed_keys));
 }
@@ -6455,8 +6384,7 @@ DEFUN ("w32-reconstruct-hot-key", Fw32_reconstruct_hot_key,
        Sw32_reconstruct_hot_key, 1, 1, 0,
        doc: /* Convert hot-key ID to a lisp key combination.
 usage: (w32-reconstruct-hot-key ID)  */)
-  (hotkeyid)
-     Lisp_Object hotkeyid;
+  (Lisp_Object hotkeyid)
 {
   int vk_code, w32_modifiers;
   Lisp_Object key;
@@ -6490,8 +6418,7 @@ DEFUN ("w32-toggle-lock-key", Fw32_toggle_lock_key,
 KEY can be `capslock', `kp-numlock', or `scroll'.
 If the optional parameter NEW-STATE is a number, then the state of KEY
 is set to off if the low bit of NEW-STATE is zero, otherwise on.  */)
-  (key, new_state)
-     Lisp_Object key, new_state;
+  (Lisp_Object key, Lisp_Object new_state)
 {
   int vk_code;
 
@@ -6527,8 +6454,7 @@ DEFUN ("w32-window-exists-p", Fw32_window_exists_p, Sw32_window_exists_p,
        doc: /* Return non-nil if a window exists with the specified CLASS and NAME.
 
 This is a direct interface to the Windows API FindWindow function.  */)
-  (class, name)
-     Lisp_Object class, name;
+  (Lisp_Object class, Lisp_Object name)
 {
   HWND hnd;
 
@@ -6557,7 +6483,7 @@ The following %-sequences are provided:
 %m Remaining time (to charge or discharge) in minutes
 %h Remaining time (to charge or discharge) in hours
 %t Remaining time (to charge or discharge) in the form `h:min'  */)
-  ()
+  (void)
 {
   Lisp_Object status = Qnil;
 
@@ -6661,8 +6587,7 @@ Value is a list of floats (TOTAL FREE AVAIL), where TOTAL is the total
 storage of the file system, FREE is the free storage, and AVAIL is the
 storage available to a non-superuser.  All 3 numbers are in bytes.
 If the underlying system call fails, value is nil.  */)
-  (filename)
-  Lisp_Object filename;
+  (Lisp_Object filename)
 {
   Lisp_Object encoded, value;
 
@@ -6754,7 +6679,7 @@ If the underlying system call fails, value is nil.  */)
 \f
 DEFUN ("default-printer-name", Fdefault_printer_name, Sdefault_printer_name,
        0, 0, 0, doc: /* Return the name of Windows default printer device.  */)
-     ()
+  (void)
 {
   static char pname_buf[256];
   int err;
@@ -6863,6 +6788,7 @@ frame_parm_handler w32_frame_parm_handlers[] =
   x_set_font_backend,
   x_set_alpha,
   0, /* x_set_sticky */
+  0, /* x_set_tool_bar_position */
 };
 
 void
@@ -6902,28 +6828,28 @@ syms_of_w32fns (void)
   staticpro (&w32_grabbed_keys);
   w32_grabbed_keys = Qnil;
 
-  DEFVAR_LISP ("w32-color-map", &Vw32_color_map,
+  DEFVAR_LISP ("w32-color-map", Vw32_color_map,
               doc: /* An array of color name mappings for Windows.  */);
   Vw32_color_map = Qnil;
 
-  DEFVAR_LISP ("w32-pass-alt-to-system", &Vw32_pass_alt_to_system,
+  DEFVAR_LISP ("w32-pass-alt-to-system", Vw32_pass_alt_to_system,
               doc: /* Non-nil if Alt key presses are passed on to Windows.
 When non-nil, for example, Alt pressed and released and then space will
 open the System menu.  When nil, Emacs processes the Alt key events, and
 then silently swallows them.  */);
   Vw32_pass_alt_to_system = Qnil;
 
-  DEFVAR_LISP ("w32-alt-is-meta", &Vw32_alt_is_meta,
+  DEFVAR_LISP ("w32-alt-is-meta", Vw32_alt_is_meta,
               doc: /* Non-nil if the Alt key is to be considered the same as the META key.
 When nil, Emacs will translate the Alt key to the ALT modifier, not to META.  */);
   Vw32_alt_is_meta = Qt;
 
-  DEFVAR_INT ("w32-quit-key", &w32_quit_key,
+  DEFVAR_INT ("w32-quit-key", w32_quit_key,
               doc: /* If non-zero, the virtual key code for an alternative quit key.  */);
   w32_quit_key = 0;
 
   DEFVAR_LISP ("w32-pass-lwindow-to-system",
-              &Vw32_pass_lwindow_to_system,
+              Vw32_pass_lwindow_to_system,
               doc: /* If non-nil, the left \"Windows\" key is passed on to Windows.
 
 When non-nil, the Start menu is opened by tapping the key.
@@ -6938,7 +6864,7 @@ the doc string of `w32-phantom-key-code'.  */);
   Vw32_pass_lwindow_to_system = Qt;
 
   DEFVAR_LISP ("w32-pass-rwindow-to-system",
-              &Vw32_pass_rwindow_to_system,
+              Vw32_pass_rwindow_to_system,
               doc: /* If non-nil, the right \"Windows\" key is passed on to Windows.
 
 When non-nil, the Start menu is opened by tapping the key.
@@ -6953,7 +6879,7 @@ the doc string of `w32-phantom-key-code'.  */);
   Vw32_pass_rwindow_to_system = Qt;
 
   DEFVAR_LISP ("w32-phantom-key-code",
-              &Vw32_phantom_key_code,
+              Vw32_phantom_key_code,
               doc: /* Virtual key code used to generate \"phantom\" key presses.
 Value is a number between 0 and 255.
 
@@ -6965,19 +6891,19 @@ acting on \"Windows\" key events when `w32-pass-lwindow-to-system' or
   XSETINT (Vw32_phantom_key_code, 255);
 
   DEFVAR_LISP ("w32-enable-num-lock",
-              &Vw32_enable_num_lock,
+              Vw32_enable_num_lock,
               doc: /* If non-nil, the Num Lock key acts normally.
 Set to nil to handle Num Lock as the `kp-numlock' key.  */);
   Vw32_enable_num_lock = Qt;
 
   DEFVAR_LISP ("w32-enable-caps-lock",
-              &Vw32_enable_caps_lock,
+              Vw32_enable_caps_lock,
               doc: /* If non-nil, the Caps Lock key acts normally.
 Set to nil to handle Caps Lock as the `capslock' key.  */);
   Vw32_enable_caps_lock = Qt;
 
   DEFVAR_LISP ("w32-scroll-lock-modifier",
-              &Vw32_scroll_lock_modifier,
+              Vw32_scroll_lock_modifier,
               doc: /* Modifier to use for the Scroll Lock ON state.
 The value can be hyper, super, meta, alt, control or shift for the
 respective modifier, or nil to handle Scroll Lock as the `scroll' key.
@@ -6985,7 +6911,7 @@ Any other value will cause the Scroll Lock key to be ignored.  */);
   Vw32_scroll_lock_modifier = Qnil;
 
   DEFVAR_LISP ("w32-lwindow-modifier",
-              &Vw32_lwindow_modifier,
+              Vw32_lwindow_modifier,
               doc: /* Modifier to use for the left \"Windows\" key.
 The value can be hyper, super, meta, alt, control or shift for the
 respective modifier, or nil to appear as the `lwindow' key.
@@ -6993,7 +6919,7 @@ Any other value will cause the key to be ignored.  */);
   Vw32_lwindow_modifier = Qnil;
 
   DEFVAR_LISP ("w32-rwindow-modifier",
-              &Vw32_rwindow_modifier,
+              Vw32_rwindow_modifier,
               doc: /* Modifier to use for the right \"Windows\" key.
 The value can be hyper, super, meta, alt, control or shift for the
 respective modifier, or nil to appear as the `rwindow' key.
@@ -7001,23 +6927,23 @@ Any other value will cause the key to be ignored.  */);
   Vw32_rwindow_modifier = Qnil;
 
   DEFVAR_LISP ("w32-apps-modifier",
-              &Vw32_apps_modifier,
+              Vw32_apps_modifier,
               doc: /* Modifier to use for the \"Apps\" key.
 The value can be hyper, super, meta, alt, control or shift for the
 respective modifier, or nil to appear as the `apps' key.
 Any other value will cause the key to be ignored.  */);
   Vw32_apps_modifier = Qnil;
 
-  DEFVAR_BOOL ("w32-enable-synthesized-fonts", &w32_enable_synthesized_fonts,
+  DEFVAR_BOOL ("w32-enable-synthesized-fonts", w32_enable_synthesized_fonts,
               doc: /* Non-nil enables selection of artificially italicized and bold fonts.  */);
   w32_enable_synthesized_fonts = 0;
 
-  DEFVAR_LISP ("w32-enable-palette", &Vw32_enable_palette,
+  DEFVAR_LISP ("w32-enable-palette", Vw32_enable_palette,
               doc: /* Non-nil enables Windows palette management to map colors exactly.  */);
   Vw32_enable_palette = Qt;
 
   DEFVAR_INT ("w32-mouse-button-tolerance",
-             &w32_mouse_button_tolerance,
+             w32_mouse_button_tolerance,
              doc: /* Analogue of double click interval for faking middle mouse events.
 The value is the minimum time in milliseconds that must elapse between
 left and right button down events before they are considered distinct events.
@@ -7026,7 +6952,7 @@ button down event is generated instead.  */);
   w32_mouse_button_tolerance = GetDoubleClickTime () / 2;
 
   DEFVAR_INT ("w32-mouse-move-interval",
-             &w32_mouse_move_interval,
+             w32_mouse_move_interval,
              doc: /* Minimum interval between mouse move events.
 The value is the minimum time in milliseconds that must elapse between
 successive mouse move (or scroll bar drag) events before they are
@@ -7034,7 +6960,7 @@ reported as lisp events.  */);
   w32_mouse_move_interval = 0;
 
   DEFVAR_BOOL ("w32-pass-extra-mouse-buttons-to-system",
-              &w32_pass_extra_mouse_buttons_to_system,
+              w32_pass_extra_mouse_buttons_to_system,
               doc: /* If non-nil, the fourth and fifth mouse buttons are passed to Windows.
 Recent versions of Windows support mice with up to five buttons.
 Since most applications don't support these extra buttons, most mouse
@@ -7044,7 +6970,7 @@ system to handle them.  */);
   w32_pass_extra_mouse_buttons_to_system = 0;
 
   DEFVAR_BOOL ("w32-pass-multimedia-buttons-to-system",
-               &w32_pass_multimedia_buttons_to_system,
+               w32_pass_multimedia_buttons_to_system,
                doc: /* If non-nil, media buttons are passed to Windows.
 Some modern keyboards contain buttons for controlling media players, web
 browsers and other applications.  Generally these buttons are handled on a
@@ -7067,7 +6993,7 @@ bass-down, bass-boost, bass-up, treble-down, treble-up  */);
   w32_pass_multimedia_buttons_to_system = 1;
 
 #if 0 /* TODO: Mouse cursor customization.  */
-  DEFVAR_LISP ("x-pointer-shape", &Vx_pointer_shape,
+  DEFVAR_LISP ("x-pointer-shape", Vx_pointer_shape,
               doc: /* The shape of the pointer when over text.
 Changing the value does not affect existing frames
 unless you set the mouse color.  */);
@@ -7077,37 +7003,37 @@ unless you set the mouse color.  */);
 
   Vx_mode_pointer_shape = Qnil;
 
-  DEFVAR_LISP ("x-hourglass-pointer-shape", &Vx_hourglass_pointer_shape,
+  DEFVAR_LISP ("x-hourglass-pointer-shape", Vx_hourglass_pointer_shape,
               doc: /* The shape of the pointer when Emacs is busy.
 This variable takes effect when you create a new frame
 or when you set the mouse color.  */);
   Vx_hourglass_pointer_shape = Qnil;
 
   DEFVAR_LISP ("x-sensitive-text-pointer-shape",
-              &Vx_sensitive_text_pointer_shape,
+              Vx_sensitive_text_pointer_shape,
               doc: /* The shape of the pointer when over mouse-sensitive text.
 This variable takes effect when you create a new frame
 or when you set the mouse color.  */);
   Vx_sensitive_text_pointer_shape = Qnil;
 
   DEFVAR_LISP ("x-window-horizontal-drag-cursor",
-              &Vx_window_horizontal_drag_shape,
+              Vx_window_horizontal_drag_shape,
               doc: /* Pointer shape to use for indicating a window can be dragged horizontally.
 This variable takes effect when you create a new frame
 or when you set the mouse color.  */);
   Vx_window_horizontal_drag_shape = Qnil;
 #endif
 
-  DEFVAR_LISP ("x-cursor-fore-pixel", &Vx_cursor_fore_pixel,
+  DEFVAR_LISP ("x-cursor-fore-pixel", Vx_cursor_fore_pixel,
               doc: /* A string indicating the foreground color of the cursor box.  */);
   Vx_cursor_fore_pixel = Qnil;
 
-  DEFVAR_LISP ("x-max-tooltip-size", &Vx_max_tooltip_size,
+  DEFVAR_LISP ("x-max-tooltip-size", Vx_max_tooltip_size,
               doc: /* Maximum size for tooltips.
-Value is a pair (COLUMNS . ROWS). Text larger than this is clipped.  */);
+Value is a pair (COLUMNS . ROWS).  Text larger than this is clipped.  */);
   Vx_max_tooltip_size = Fcons (make_number (80), make_number (40));
 
-  DEFVAR_LISP ("x-no-window-manager", &Vx_no_window_manager,
+  DEFVAR_LISP ("x-no-window-manager", Vx_no_window_manager,
               doc: /* Non-nil if no window manager is in use.
 Emacs doesn't try to figure this out; this is always nil
 unless you set it to something else.  */);
@@ -7116,7 +7042,7 @@ unless you set it to something else.  */);
   Vx_no_window_manager = Qnil;
 
   DEFVAR_LISP ("x-pixel-size-width-font-regexp",
-              &Vx_pixel_size_width_font_regexp,
+              Vx_pixel_size_width_font_regexp,
               doc: /* Regexp matching a font name whose width is the same as `PIXEL_SIZE'.
 
 Since Emacs gets width of a font matching with this regexp from
@@ -7126,12 +7052,12 @@ Chinese, Japanese, and Korean.  */);
   Vx_pixel_size_width_font_regexp = Qnil;
 
   DEFVAR_LISP ("w32-bdf-filename-alist",
-               &Vw32_bdf_filename_alist,
+               Vw32_bdf_filename_alist,
                doc: /* List of bdf fonts and their corresponding filenames.  */);
   Vw32_bdf_filename_alist = Qnil;
 
   DEFVAR_BOOL ("w32-strict-fontnames",
-               &w32_strict_fontnames,
+               w32_strict_fontnames,
               doc: /* Non-nil means only use fonts that are exact matches for those requested.
 Default is nil, which allows old fontnames that are not XLFD compliant,
 and allows third-party CJK display to work by specifying false charset
@@ -7141,7 +7067,7 @@ fontsets are automatically created.  */);
   w32_strict_fontnames = 0;
 
   DEFVAR_BOOL ("w32-strict-painting",
-               &w32_strict_painting,
+               w32_strict_painting,
               doc: /* Non-nil means use strict rules for repainting frames.
 Set this to nil to get the old behavior for repainting; this should
 only be necessary if the default setting causes problems.  */);
@@ -7232,9 +7158,6 @@ globals_of_w32fns (void)
   */
   track_mouse_event_fn = (TrackMouseEvent_Proc)
     GetProcAddress (user32_lib, "TrackMouseEvent");
-  /* ditto for GetClipboardSequenceNumber.  */
-  clipboard_sequence_fn = (ClipboardSequence_Proc)
-    GetProcAddress (user32_lib, "GetClipboardSequenceNumber");
 
   monitor_from_point_fn = (MonitorFromPoint_Proc)
     GetProcAddress (user32_lib, "MonitorFromPoint");
@@ -7253,7 +7176,7 @@ globals_of_w32fns (void)
       GetProcAddress (imm32_lib, "ImmSetCompositionWindow");
   }
   DEFVAR_INT ("w32-ansi-code-page",
-             &w32_ansi_code_page,
+             w32_ansi_code_page,
              doc: /* The ANSI code page used by the system.  */);
   w32_ansi_code_page = GetACP ();
 
@@ -7298,6 +7221,3 @@ w32_last_error (void)
 {
   return GetLastError ();
 }
-
-/* arch-tag: 707589ab-b9be-4638-8cdd-74629cc9b446
-   (do not change this comment) */