https://github.com/python/cpython/commit/133c1a7cdb19dd9317e7607ecf8f4fd4fb5842f6
commit: 133c1a7cdb19dd9317e7607ecf8f4fd4fb5842f6
branch: main
author: Henrik Tunedal <[email protected]>
committer: zooba <[email protected]>
date: 2024-04-28T21:10:44Z
summary:

gh-118293: Suppress mouse cursor feedback when launching Windows processes with 
multiprocessing (GH-118315)

files:
A Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst
M Doc/library/subprocess.rst
M Lib/multiprocessing/popen_spawn_win32.py
M Lib/subprocess.py
M Modules/_winapi.c

diff --git a/Doc/library/subprocess.rst b/Doc/library/subprocess.rst
index 1cd233173e85e1..bd35fda7d79225 100644
--- a/Doc/library/subprocess.rst
+++ b/Doc/library/subprocess.rst
@@ -1066,6 +1066,22 @@ The :mod:`subprocess` module exposes the following 
constants.
    Specifies that the :attr:`STARTUPINFO.wShowWindow` attribute contains
    additional information.
 
+.. data:: STARTF_FORCEONFEEDBACK
+
+   A :attr:`STARTUPINFO.dwFlags` parameter to specify that the
+   *Working in Background* mouse cursor will be displayed while a
+   process is launching. This is the default behavior for GUI
+   processes.
+
+   .. versionadded:: 3.13
+
+.. data:: STARTF_FORCEOFFFEEDBACK
+
+   A :attr:`STARTUPINFO.dwFlags` parameter to specify that the mouse
+   cursor will not be changed when launching a process.
+
+   .. versionadded:: 3.13
+
 .. data:: CREATE_NEW_CONSOLE
 
    The new process has a new console, instead of inheriting its parent's
diff --git a/Lib/multiprocessing/popen_spawn_win32.py 
b/Lib/multiprocessing/popen_spawn_win32.py
index 49d4c7eea22411..62fb0ddbf91a5d 100644
--- a/Lib/multiprocessing/popen_spawn_win32.py
+++ b/Lib/multiprocessing/popen_spawn_win32.py
@@ -3,6 +3,7 @@
 import signal
 import sys
 import _winapi
+from subprocess import STARTUPINFO, STARTF_FORCEOFFFEEDBACK
 
 from .context import reduction, get_spawning_popen, set_spawning_popen
 from . import spawn
@@ -74,7 +75,8 @@ def __init__(self, process_obj):
             try:
                 hp, ht, pid, tid = _winapi.CreateProcess(
                     python_exe, cmd,
-                    None, None, False, 0, env, None, None)
+                    None, None, False, 0, env, None,
+                    STARTUPINFO(dwFlags=STARTF_FORCEOFFFEEDBACK))
                 _winapi.CloseHandle(ht)
             except:
                 _winapi.CloseHandle(rhandle)
diff --git a/Lib/subprocess.py b/Lib/subprocess.py
index d7c7b45127104f..212fdf5b095511 100644
--- a/Lib/subprocess.py
+++ b/Lib/subprocess.py
@@ -83,6 +83,7 @@
                          STD_INPUT_HANDLE, STD_OUTPUT_HANDLE,
                          STD_ERROR_HANDLE, SW_HIDE,
                          STARTF_USESTDHANDLES, STARTF_USESHOWWINDOW,
+                         STARTF_FORCEONFEEDBACK, STARTF_FORCEOFFFEEDBACK,
                          ABOVE_NORMAL_PRIORITY_CLASS, 
BELOW_NORMAL_PRIORITY_CLASS,
                          HIGH_PRIORITY_CLASS, IDLE_PRIORITY_CLASS,
                          NORMAL_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS,
@@ -93,6 +94,7 @@
                     "STD_INPUT_HANDLE", "STD_OUTPUT_HANDLE",
                     "STD_ERROR_HANDLE", "SW_HIDE",
                     "STARTF_USESTDHANDLES", "STARTF_USESHOWWINDOW",
+                    "STARTF_FORCEONFEEDBACK", "STARTF_FORCEOFFFEEDBACK",
                     "STARTUPINFO",
                     "ABOVE_NORMAL_PRIORITY_CLASS", 
"BELOW_NORMAL_PRIORITY_CLASS",
                     "HIGH_PRIORITY_CLASS", "IDLE_PRIORITY_CLASS",
diff --git 
a/Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst 
b/Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst
new file mode 100644
index 00000000000000..7383a2b32d7240
--- /dev/null
+++ b/Misc/NEWS.d/next/Windows/2024-04-26-14-23-07.gh-issue-118293.ohhPtW.rst
@@ -0,0 +1,2 @@
+The ``multiprocessing`` module now passes the ``STARTF_FORCEOFFFEEDBACK``
+flag when spawning processes to tell Windows not to change the mouse cursor.
diff --git a/Modules/_winapi.c b/Modules/_winapi.c
index 57b8bdc7ea2448..23e3c0d87f0319 100644
--- a/Modules/_winapi.c
+++ b/Modules/_winapi.c
@@ -72,9 +72,45 @@
 #ifndef STARTF_USESHOWWINDOW
 #define STARTF_USESHOWWINDOW 0x00000001
 #endif
+#ifndef STARTF_USESIZE
+#define STARTF_USESIZE 0x00000002
+#endif
+#ifndef STARTF_USEPOSITION
+#define STARTF_USEPOSITION 0x00000004
+#endif
+#ifndef STARTF_USECOUNTCHARS
+#define STARTF_USECOUNTCHARS 0x00000008
+#endif
+#ifndef STARTF_USEFILLATTRIBUTE
+#define STARTF_USEFILLATTRIBUTE 0x00000010
+#endif
+#ifndef STARTF_RUNFULLSCREEN
+#define STARTF_RUNFULLSCREEN 0x00000020
+#endif
+#ifndef STARTF_FORCEONFEEDBACK
+#define STARTF_FORCEONFEEDBACK 0x00000040
+#endif
+#ifndef STARTF_FORCEOFFFEEDBACK
+#define STARTF_FORCEOFFFEEDBACK 0x00000080
+#endif
 #ifndef STARTF_USESTDHANDLES
 #define STARTF_USESTDHANDLES 0x00000100
 #endif
+#ifndef STARTF_USEHOTKEY
+#define STARTF_USEHOTKEY 0x00000200
+#endif
+#ifndef STARTF_TITLEISLINKNAME
+#define STARTF_TITLEISLINKNAME 0x00000800
+#endif
+#ifndef STARTF_TITLEISAPPID
+#define STARTF_TITLEISAPPID 0x00001000
+#endif
+#ifndef STARTF_PREVENTPINNING
+#define STARTF_PREVENTPINNING 0x00002000
+#endif
+#ifndef STARTF_UNTRUSTEDSOURCE
+#define STARTF_UNTRUSTEDSOURCE 0x00008000
+#endif
 
 typedef struct {
     PyTypeObject *overlapped_type;
@@ -3061,7 +3097,19 @@ static int winapi_exec(PyObject *m)
     WINAPI_CONSTANT(F_DWORD, SEC_RESERVE);
     WINAPI_CONSTANT(F_DWORD, SEC_WRITECOMBINE);
     WINAPI_CONSTANT(F_DWORD, STARTF_USESHOWWINDOW);
+    WINAPI_CONSTANT(F_DWORD, STARTF_USESIZE);
+    WINAPI_CONSTANT(F_DWORD, STARTF_USEPOSITION);
+    WINAPI_CONSTANT(F_DWORD, STARTF_USECOUNTCHARS);
+    WINAPI_CONSTANT(F_DWORD, STARTF_USEFILLATTRIBUTE);
+    WINAPI_CONSTANT(F_DWORD, STARTF_RUNFULLSCREEN);
+    WINAPI_CONSTANT(F_DWORD, STARTF_FORCEONFEEDBACK);
+    WINAPI_CONSTANT(F_DWORD, STARTF_FORCEOFFFEEDBACK);
     WINAPI_CONSTANT(F_DWORD, STARTF_USESTDHANDLES);
+    WINAPI_CONSTANT(F_DWORD, STARTF_USEHOTKEY);
+    WINAPI_CONSTANT(F_DWORD, STARTF_TITLEISLINKNAME);
+    WINAPI_CONSTANT(F_DWORD, STARTF_TITLEISAPPID);
+    WINAPI_CONSTANT(F_DWORD, STARTF_PREVENTPINNING);
+    WINAPI_CONSTANT(F_DWORD, STARTF_UNTRUSTEDSOURCE);
     WINAPI_CONSTANT(F_DWORD, STD_INPUT_HANDLE);
     WINAPI_CONSTANT(F_DWORD, STD_OUTPUT_HANDLE);
     WINAPI_CONSTANT(F_DWORD, STD_ERROR_HANDLE);

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to