]> code.delx.au - gnu-emacs/blobdiff - src/w32term.c
Merge from origin/emacs-25
[gnu-emacs] / src / w32term.c
index 0b8bef239f8ed26e25a04268d39f8a767215c979..74ea6b543bd75220ef79f733908c62acdc37a795 100644 (file)
@@ -1,13 +1,13 @@
 /* Implementation of GUI terminal on the Microsoft Windows API.
 
-Copyright (C) 1989, 1993-2015 Free Software Foundation, Inc.
+Copyright (C) 1989, 1993-2016 Free Software Foundation, Inc.
 
 This file is part of GNU Emacs.
 
 GNU Emacs is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
-the Free Software Foundation, either version 3 of the License, or
-(at your option) any later version.
+the Free Software Foundation, either version 3 of the License, or (at
+your option) any later version.
 
 GNU Emacs is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -23,6 +23,7 @@ along with GNU Emacs.  If not, see <http://www.gnu.org/licenses/>.  */
 #include "lisp.h"
 #include "blockinput.h"
 #include "w32term.h"
+#include "w32common.h" /* for OS version info */
 
 #include <ctype.h>
 #include <errno.h>
@@ -3210,71 +3211,85 @@ static void
 queue_notifications (struct input_event *event, W32Msg *msg, struct frame *f,
                     int *evcount)
 {
-  BYTE *p = file_notifications;
-  FILE_NOTIFY_INFORMATION *fni = (PFILE_NOTIFY_INFORMATION)p;
-  const DWORD min_size
-    = offsetof (FILE_NOTIFY_INFORMATION, FileName) + sizeof(wchar_t);
+  struct notifications_set *ns = NULL;
   Lisp_Object frame;
+  int done = 0;
 
   /* We cannot process notification before Emacs is fully initialized,
      since we need the UTF-16LE coding-system to be set up.  */
   if (!initialized)
-    {
-      notification_buffer_in_use = 0;
-      return;
-    }
+    return;
 
   XSETFRAME (frame, f);
 
-  enter_crit ();
-  if (notification_buffer_in_use)
+  while (!done)
     {
-      DWORD info_size = notifications_size;
-      Lisp_Object cs = Qutf_16le;
-      Lisp_Object obj = w32_get_watch_object (notifications_desc);
-
-      /* notifications_size could be zero when the buffer of
-        notifications overflowed on the OS level, or when the
-        directory being watched was itself deleted.  Do nothing in
-        that case.  */
-      if (info_size
-         && !NILP (obj) && CONSP (obj))
+      ns = NULL;
+
+      /* Find out if there is a record available in the linked list of
+        notifications sets.  If so, unlink the set from the linked
+        list.  Use critical section.  */
+      enter_crit ();
+      if (notifications_set_head->next != notifications_set_head)
        {
-         Lisp_Object callback = XCDR (obj);
+         ns = notifications_set_head->next;
+         ns->prev->next = ns->next;
+         ns->next->prev = ns->prev;
+       }
+      else
+       done = 1;
+      leave_crit();
 
-         while (info_size >= min_size)
+      if (ns)
+       {
+         BYTE *p = ns->notifications;
+         FILE_NOTIFY_INFORMATION *fni = (PFILE_NOTIFY_INFORMATION)p;
+         const DWORD min_size
+           = offsetof (FILE_NOTIFY_INFORMATION, FileName) + sizeof(wchar_t);
+         DWORD info_size = ns->size;
+         Lisp_Object cs = Qutf_16le;
+         Lisp_Object obj = w32_get_watch_object (ns->desc);
+
+         /* notifications size could be zero when the buffer of
+            notifications overflowed on the OS level, or when the
+            directory being watched was itself deleted.  Do nothing in
+            that case.  */
+         if (info_size
+             && !NILP (obj) && CONSP (obj))
            {
-             Lisp_Object utf_16_fn
-               = make_unibyte_string ((char *)fni->FileName,
-                                      fni->FileNameLength);
-             /* Note: mule-conf is preloaded, so utf-16le must
-                already be defined at this point.  */
-             Lisp_Object fname
-               = code_convert_string_norecord (utf_16_fn, cs, 0);
-             Lisp_Object action = lispy_file_action (fni->Action);
-
-             event->kind = FILE_NOTIFY_EVENT;
-             event->timestamp = msg->msg.time;
-             event->modifiers = 0;
-             event->frame_or_window = callback;
-             event->arg = list3 (make_pointer_integer (notifications_desc),
-                                 action, fname);
-             kbd_buffer_store_event (event);
-             (*evcount)++;
-
-             if (!fni->NextEntryOffset)
-               break;
-             p += fni->NextEntryOffset;
-             fni = (PFILE_NOTIFY_INFORMATION)p;
-             info_size -= fni->NextEntryOffset;
+             Lisp_Object callback = XCDR (obj);
+
+             while (info_size >= min_size)
+               {
+                 Lisp_Object utf_16_fn
+                   = make_unibyte_string ((char *)fni->FileName,
+                                          fni->FileNameLength);
+                 /* Note: mule-conf is preloaded, so utf-16le must
+                    already be defined at this point.  */
+                 Lisp_Object fname
+                   = code_convert_string_norecord (utf_16_fn, cs, 0);
+                 Lisp_Object action = lispy_file_action (fni->Action);
+
+                 event->kind = FILE_NOTIFY_EVENT;
+                 event->timestamp = msg->msg.time;
+                 event->modifiers = 0;
+                 event->frame_or_window = callback;
+                 event->arg = list3 (make_pointer_integer (ns->desc),
+                                     action, fname);
+                 kbd_buffer_store_event (event);
+                 (*evcount)++;
+                 if (!fni->NextEntryOffset)
+                   break;
+                 p += fni->NextEntryOffset;
+                 fni = (PFILE_NOTIFY_INFORMATION)p;
+                 info_size -= fni->NextEntryOffset;
+               }
            }
+         /* Free this notifications set. */
+         xfree (ns->notifications);
+         xfree (ns);
        }
-      notification_buffer_in_use = 0;
     }
-  else
-    DebPrint (("We were promised notifications, but in-use flag is zero!\n"));
-  leave_crit ();
-
   /* We've stuffed all the events ourselves, so w32_read_socket shouldn't.  */
   event->kind = NO_EVENT;
 }
@@ -3615,8 +3630,8 @@ w32_set_horizontal_scroll_bar_thumb (struct scroll_bar *bar,
   si.fMask = SIF_PAGE | SIF_POS | SIF_RANGE;
   si.nMin = 0;
   si.nMax = whole;
-  /* Allow nPage to be one larger than nPos so we don't allow to scroll
-     an already fully visible buffer.  */
+  /* Allow nPage to be one larger than nPos so we don't allow the scrolling
+     of an already fully visible buffer.  */
   si.nPage = min (portion, si.nMax) + 1;
   si.nPos = min (position, si.nMax);
   SetScrollInfo (w, SB_CTL, &si, TRUE);
@@ -6230,6 +6245,8 @@ x_set_window_size (struct frame *f, bool change_gravity,
     }
 
   unblock_input ();
+
+  do_pending_window_change (false);
 }
 \f
 /* Mouse warping.  */
@@ -6237,6 +6254,8 @@ x_set_window_size (struct frame *f, bool change_gravity,
 void
 frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
 {
+  UINT trail_num = 0;
+  BOOL ret = false;
   RECT rect;
   POINT pt;
 
@@ -6247,7 +6266,15 @@ frame_set_mouse_pixel_position (struct frame *f, int pix_x, int pix_y)
   pt.y = rect.top + pix_y;
   ClientToScreen (FRAME_W32_WINDOW (f), &pt);
 
+  /* 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 (pt.x, pt.y);
+  if (ret)
+    SystemParametersInfo (SPI_SETMOUSETRAILS, trail_num, NULL, 0);
 
   unblock_input ();
 }
@@ -6938,6 +6965,8 @@ w32_init_main_thread (void)
   DuplicateHandle (GetCurrentProcess (), GetCurrentThread (),
                   GetCurrentProcess (), &hMainThread, 0, TRUE,
                   DUPLICATE_SAME_ACCESS);
+
+
 }
 
 DWORD WINAPI w32_msg_worker (void * arg);