summaryrefslogtreecommitdiff
path: root/src/w32proc.c
diff options
context:
space:
mode:
authorEli Zaretskii <eliz@gnu.org>2017-09-05 20:33:40 +0300
committerEli Zaretskii <eliz@gnu.org>2017-09-05 20:33:40 +0300
commit25a49f64963d1c2a392ebaa66676042b55e0e3c1 (patch)
tree92a1470e48e900c3f5907a3fb86e2d66bbcc2a61 /src/w32proc.c
parent4eae60395c6270ed69b0d311e68382d2c723cb9a (diff)
downloademacs-25a49f64963d1c2a392ebaa66676042b55e0e3c1.tar.gz
Avoid losing Ctrl-C keystrokes in compilation mode on MS-Windows
* src/w32proc.c (sys_kill): Preserve the up/down state of the Ctrl key across the simulated Ctrl-C keystroke. (Bug#28348)
Diffstat (limited to 'src/w32proc.c')
-rw-r--r--src/w32proc.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/w32proc.c b/src/w32proc.c
index 71bd28d3c24..085995df58a 100644
--- a/src/w32proc.c
+++ b/src/w32proc.c
@@ -2638,6 +2638,12 @@ sys_kill (pid_t pid, int sig)
/* Set the foreground window to the child. */
if (SetForegroundWindow (cp->hwnd))
{
+ /* Record the state of the Ctrl key: the user could
+ have it depressed while we are simulating Ctrl-C,
+ in which case we will have to leave the state of
+ Ctrl depressed when we are done. */
+ short ctrl_state = GetKeyState (VK_CONTROL) & 0x8000;
+
/* Generate keystrokes as if user had typed Ctrl-Break or
Ctrl-C. */
keybd_event (VK_CONTROL, control_scan_code, 0, 0);
@@ -2654,6 +2660,9 @@ sys_kill (pid_t pid, int sig)
Sleep (100);
SetForegroundWindow (foreground_window);
+ /* If needed, restore the state of Ctrl. */
+ if (ctrl_state != 0)
+ keybd_event (VK_CONTROL, control_scan_code, 0, 0);
}
/* Detach from the foreground and child threads now that
the foreground switching is over. */