Skip to content

Commit aebc2b5

Browse files
authored
Fix cursor remaining busy after launching windowed app (#310)
1 parent bf5407e commit aebc2b5

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/pymanager/_launch.cpp

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -77,22 +77,6 @@ launch(
7777
(cmd_line && *cmd_line) ? L" " : L"",
7878
(cmd_line && *cmd_line) ? cmd_line + 1 : L"");
7979

80-
#if defined(_WINDOWS)
81-
/*
82-
When explorer launches a Windows (GUI) application, it displays
83-
the "app starting" (the "pointer + hourglass") cursor for a number
84-
of seconds, or until the app does something UI-ish (eg, creating a
85-
window, or fetching a message). As this launcher doesn't do this
86-
directly, that cursor remains even after the child process does these
87-
things. We avoid that by doing a simple post+get message.
88-
See http://bugs.python.org/issue17290
89-
*/
90-
MSG msg;
91-
92-
PostMessage(0, 0, 0, 0);
93-
GetMessage(&msg, 0, 0, 0);
94-
#endif
95-
9680
job = CreateJobObject(NULL, NULL);
9781
if (!job
9882
|| !QueryInformationJobObject(job, JobObjectExtendedLimitInformation, &info, sizeof(info), &info_len)
@@ -129,6 +113,23 @@ launch(
129113

130114
AssignProcessToJobObject(job, pi.hProcess);
131115
CloseHandle(pi.hThread);
116+
117+
#if PY_WINDOWED
118+
/*
119+
When explorer launches a Windows (GUI) application, it displays
120+
the "app starting" (the "pointer + hourglass") cursor for a number
121+
of seconds, or until the app does something UI-ish (eg, creating a
122+
window, or fetching a message). As this launcher doesn't do this
123+
directly, that cursor remains even after the child process does these
124+
things. We avoid that by doing a simple post+get message.
125+
See http://bugs.python.org/issue17290
126+
*/
127+
MSG msg;
128+
129+
PostMessage(0, 0, 0, 0);
130+
GetMessage(&msg, 0, 0, 0);
131+
#endif
132+
132133
WaitForSingleObjectEx(pi.hProcess, INFINITE, FALSE);
133134
if (!GetExitCodeProcess(pi.hProcess, exit_code)) {
134135
lastError = GetLastError();

0 commit comments

Comments
 (0)