]> code.delx.au - gnu-emacs/blobdiff - src/w32fns.c
Anoter fix for problematic merge from emacs-25
[gnu-emacs] / src / w32fns.c
index f2d286d6364726516989cf899603c0513e1293d8..a5018ae9d30d798e34694df01c2527a0e35347bf 100644 (file)
@@ -1,6 +1,6 @@
 /* Graphical user interface functions for the Microsoft Windows API.
 
-Copyright (C) 1989, 1992-2015 Free Software Foundation, Inc.
+Copyright (C) 1989, 1992-2016 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
@@ -1666,10 +1666,7 @@ x_set_menu_bar_lines (struct frame *f, Lisp_Object value, Lisp_Object oldval)
   FRAME_MENU_BAR_LINES (f) = 0;
   FRAME_MENU_BAR_HEIGHT (f) = 0;
   if (nlines)
-    {
-      FRAME_EXTERNAL_MENU_BAR (f) = 1;
-      windows_or_buffers_changed = 23;
-    }
+    FRAME_EXTERNAL_MENU_BAR (f) = 1;
   else
     {
       if (FRAME_EXTERNAL_MENU_BAR (f) == 1)
@@ -4620,8 +4617,7 @@ my_create_tip_window (struct frame *f)
   rect.right = FRAME_PIXEL_WIDTH (f);
   rect.bottom = FRAME_PIXEL_HEIGHT (f);
 
-  AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
-                   FRAME_EXTERNAL_MENU_BAR (f));
+  AdjustWindowRect (&rect, f->output_data.w32->dwStyle, false);
 
   tip_window = FRAME_W32_WINDOW (f)
     = CreateWindow (EMACS_CLASS,
@@ -6381,7 +6377,7 @@ compute_tip_xy (struct frame *f,
   if (INTEGERP (left))
     *root_x = XINT (left);
   else if (INTEGERP (right))
-    *root_y = XINT (right) - width;
+    *root_x = XINT (right) - width;
   else if (*root_x + XINT (dx) <= min_x)
     *root_x = 0; /* Can happen for negative dx */
   else if (*root_x + XINT (dx) + width <= max_x)
@@ -6681,8 +6677,7 @@ Text larger than the specified size is clipped.  */)
     rect.left = rect.top = 0;
     rect.right = width;
     rect.bottom = height;
-    AdjustWindowRect (&rect, f->output_data.w32->dwStyle,
-                     FRAME_EXTERNAL_MENU_BAR (f));
+    AdjustWindowRect (&rect, f->output_data.w32->dwStyle, false);
 
     /* Position and size tooltip, and put it in the topmost group.
        The add-on of FRAME_COLUMN_WIDTH to the 5th argument is a
@@ -6989,12 +6984,12 @@ value of DIR as in previous invocations; this is standard Windows behavior.  */)
            if (errno == ENOENT && filename_buf_w[MAX_PATH - 1] != 0)
              report_file_error ("filename too long", default_filename);
          }
-       len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+       len = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                                    SSDATA (prompt), -1, NULL, 0);
        if (len > 32768)
          len = 32768;
        prompt_w = alloca (len * sizeof (wchar_t));
-       pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+       pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                              SSDATA (prompt), -1, prompt_w, len);
       }
     else
@@ -7007,12 +7002,12 @@ value of DIR as in previous invocations; this is standard Windows behavior.  */)
            if (errno == ENOENT && filename_buf_a[MAX_PATH - 1] != 0)
              report_file_error ("filename too long", default_filename);
          }
-       len = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+       len = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                                    SSDATA (prompt), -1, NULL, 0);
        if (len > 32768)
          len = 32768;
        prompt_w = alloca (len * sizeof (wchar_t));
-       pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+       pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                              SSDATA (prompt), -1, prompt_w, len);
        len = pWideCharToMultiByte (CP_ACP, 0, prompt_w, -1, NULL, 0, NULL, NULL);
        if (len > 32768)
@@ -7494,10 +7489,10 @@ a ShowWindow flag:
   current_dir = ENCODE_FILE (current_dir);
   /* Cannot use filename_to_utf16/ansi with DOCUMENT, since it could
      be a URL that is not limited to MAX_PATH chararcters.  */
-  doclen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+  doclen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                                 SSDATA (document), -1, NULL, 0);
   doc_w = xmalloc (doclen * sizeof (wchar_t));
-  pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+  pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                        SSDATA (document), -1, doc_w, doclen);
   if (use_unicode)
     {
@@ -7512,12 +7507,12 @@ a ShowWindow flag:
          int len;
 
          parameters = ENCODE_SYSTEM (parameters);
-         len = pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
+         len = pMultiByteToWideChar (CP_ACP, multiByteToWideCharFlags,
                                      SSDATA (parameters), -1, NULL, 0);
          if (len > 32768)
            len = 32768;
          params_w = alloca (len * sizeof (wchar_t));
-         pMultiByteToWideChar (CP_ACP, MB_ERR_INVALID_CHARS,
+         pMultiByteToWideChar (CP_ACP, multiByteToWideCharFlags,
                                SSDATA (parameters), -1, params_w, len);
          params_w[len - 1] = 0;
        }
@@ -8098,11 +8093,22 @@ The coordinates X and Y are interpreted in pixels relative to a position
 (0, 0) of the selected frame's display.  */)
   (Lisp_Object x, Lisp_Object y)
 {
+  UINT trail_num = 0;
+  BOOL ret = false;
+
   CHECK_TYPE_RANGED_INTEGER (int, x);
   CHECK_TYPE_RANGED_INTEGER (int, y);
 
   block_input ();
+  /* When "mouse trails" are in effect, moving the mouse cursor
+     sometimes leaves behind an annoying "ghost" of the pointer.
+     Avoid that by momentarily switching off mouse trails.  */
+  if (os_subtype == OS_NT
+      && w32_major_version + w32_minor_version >= 6)
+    ret = SystemParametersInfo (SPI_GETMOUSETRAILS, 0, &trail_num, 0);
   SetCursorPos (XINT (x), XINT (y));
+  if (ret)
+    SystemParametersInfo (SPI_SETMOUSETRAILS, trail_num, NULL, 0);
   unblock_input ();
 
   return Qnil;
@@ -8953,7 +8959,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip,
         later versions support up to 128.  */
       if (nidw.cbSize == MYNOTIFYICONDATAW_V1_SIZE)
        {
-         tiplen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+         tiplen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                                         tip, utf8_mbslen_lim (tip, 63),
                                         tipw, 64);
          if (tiplen >= 63)
@@ -8961,7 +8967,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip,
        }
       else
        {
-         tiplen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+         tiplen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                                         tip, utf8_mbslen_lim (tip, 127),
                                         tipw, 128);
          if (tiplen >= 127)
@@ -8980,7 +8986,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip,
        {
          int slen;
 
-         slen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+         slen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                                             msg, utf8_mbslen_lim (msg, 255),
                                             msgw, 256);
          if (slen >= 255)
@@ -8993,7 +8999,7 @@ add_tray_notification (struct frame *f, const char *icon, const char *tip,
            }
          wcscpy (nidw.szInfo, msgw);
          nidw.uTimeout = timeout;
-         slen = pMultiByteToWideChar (CP_UTF8, MB_ERR_INVALID_CHARS,
+         slen = pMultiByteToWideChar (CP_UTF8, multiByteToWideCharFlags,
                                       title, utf8_mbslen_lim (title, 63),
                                       titlew, 64);
          if (slen >= 63)
@@ -9111,13 +9117,6 @@ The following parameters are supported:
                     parameter (see below) is also specified and is a
                     string.
 
-:timeout TIMEOUT -- TIMEOUT is the time in seconds after which the
-                    notification disappears.  The value can be integer
-                    or floating-point.  This is ignored on Vista and
-                    later systems, where the duration is fixed at 9 sec
-                    and can only be customized via system-wide
-                    Accessibility settings.
-
 :title TITLE     -- The title of the notification.  If TITLE is a string,
                     it is displayed in a larger font immediately above
                     the body text.  The title text can be up to 63
@@ -9179,13 +9178,6 @@ usage: (w32-notification-notify &rest PARAMS)  */)
   else
     severity = Ni_Info;
 
-  /* Timeout.  */
-  lres = Fplist_get (arg_plist, QCtimeout);
-  if (NUMBERP (lres))
-    timeout = 1000 * (INTEGERP (lres) ? XINT (lres) : XFLOAT_DATA (lres));
-  else
-    timeout = 0;
-
   /* Title.  */
   lres = Fplist_get (arg_plist, QCtitle);
   if (STRINGP (lres))
@@ -9300,7 +9292,6 @@ syms_of_w32fns (void)
   DEFSYM (QClevel, ":level");
   DEFSYM (Qinfo, "info");
   DEFSYM (Qwarning, "warning");
-  DEFSYM (QCtimeout, ":timeout");
   DEFSYM (QCtitle, ":title");
   DEFSYM (QCbody, ":body");
 #endif
@@ -9679,6 +9670,12 @@ static PVOID except_addr;
 
 /* Stack overflow recovery.  */
 
+/* MinGW headers don't declare this (should be in malloc.h).  Also,
+   the function is not present pre-W2K, so make the call through
+   a function pointer.  */
+typedef int (__cdecl *_resetstkoflw_proc) (void);
+static _resetstkoflw_proc resetstkoflw;
+
 /* Re-establish the guard page at stack limit.  This is needed because
    when a stack overflow is detected, Windows removes the guard bit
    from the guard page, so if we don't re-establish that protection,
@@ -9686,12 +9683,14 @@ static PVOID except_addr;
 void
 w32_reset_stack_overflow_guard (void)
 {
-  /* MinGW headers don't declare this (should be in malloc.h).  */
-  _CRTIMP int __cdecl _resetstkoflw (void);
-
+  if (resetstkoflw == NULL)
+    resetstkoflw =
+      (_resetstkoflw_proc)GetProcAddress (GetModuleHandle ("msvcrt.dll"),
+                                         "_resetstkoflw");
   /* We ignore the return value.  If _resetstkoflw fails, the next
      stack overflow will crash the program.  */
-  (void)_resetstkoflw ();
+  if (resetstkoflw != NULL)
+    (void)resetstkoflw ();
 }
 
 static void
@@ -9922,6 +9921,7 @@ globals_of_w32fns (void)
   except_addr = 0;
 #ifndef CYGWIN
   prev_exception_handler = SetUnhandledExceptionFilter (my_exception_handler);
+  resetstkoflw = NULL;
 #endif
 
   DEFVAR_INT ("w32-ansi-code-page",
@@ -9940,10 +9940,6 @@ globals_of_w32fns (void)
   InitCommonControls ();
 
   syms_of_w32uniscribe ();
-
-  /* Needed for recovery from C stack overflows in batch mode.  */
-  if (noninteractive)
-    dwMainThreadId = GetCurrentThreadId ();
 }
 
 #ifdef NTGUI_UNICODE