Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

First call of PtyProcess.spawn creates a visible terminal window stealing focus of invocating app. #483

Open
deathaxe opened this issue Dec 16, 2024 · 0 comments

Comments

@deathaxe
Copy link

deathaxe commented Dec 16, 2024

If PtyProcess.spawn() is called from a GUI app, it creates a visible forground terminal window, which is then closed or hidden right after.

Thus the calling application looses focus.

On Windows OS CLI proceess need to be started with special startupinfo structure to ensure they are started in a hidden unfocused background window to avoid that effect.

Related python code to start such process is:

startupinfo = None
if WIN32:
    startupinfo = subprocess.STARTUPINFO()
    startupinfo.dwFlags |= subprocess.SW_HIDE | subprocess.STARTF_USESHOWWINDOW

proc = subprocess.Popen(
    args=args,
    startupinfo=startupinfo,
)

It seems related Rust code does not properly set those window attributes when starting a CLI process.

originally reported at sublimehq/sublime_text#6550


btw: Please provide a fix as python 3.8 wheel so Sublime Text can make use of it.

kaste added a commit to kaste/channel that referenced this issue Dec 16, 2024
pywinpty dropped support for python 3.8 but all current versions have
important issues.

- andfoy/pywinpty#463
- andfoy/pywinpty#484
- andfoy/pywinpty#483
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant