]> code.delx.au - gnu-emacs/commitdiff
Merge branch 'master' of git.savannah.gnu.org:/srv/git/emacs
authorEli Zaretskii <eliz@gnu.org>
Tue, 12 Jul 2016 13:19:18 +0000 (16:19 +0300)
committerEli Zaretskii <eliz@gnu.org>
Tue, 12 Jul 2016 13:19:18 +0000 (16:19 +0300)
src/w32fns.c

index 0eb720e1cbe1824db3dcbf91f583fb071ed21a63..f5e5b33556c77133bb5732bac9007995f4b68647 100644 (file)
@@ -276,6 +276,8 @@ static struct
 } kbdhook;
 typedef HWND (WINAPI *GetConsoleWindow_Proc) (void);
 
+typedef BOOL (WINAPI *IsDebuggerPresent_Proc) (void);
+
 /* stdin, from w32console.c */
 extern HANDLE keyboard_handle;
 
@@ -2303,6 +2305,19 @@ setup_w32_kbdhook (void)
 {
   kbdhook.hook_count++;
 
+  /* This hook gets in the way of debugging, since when Emacs stops,
+     its input thread stops, and there's nothing to process keyboard
+     events, whereas this hook is global, and is invoked in the
+     context of the thread that installed it.  So we don't install the
+     hook if the process is being debugged. */
+  if (w32_kbdhook_active)
+    {
+      IsDebuggerPresent_Proc is_debugger_present = (IsDebuggerPresent_Proc)
+       GetProcAddress (GetModuleHandle ("kernel32.dll"), "IsDebuggerPresent");
+      if (is_debugger_present && is_debugger_present ())
+       return;
+    }
+
   /* Hooking is only available on NT architecture systems, as
      indicated by the w32_kbdhook_active variable.  */
   if (kbdhook.hook_count == 1 && w32_kbdhook_active)