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

Make it possible to tell if a tab currently has focus #17689

Closed
dgl opened this issue Aug 9, 2024 · 4 comments
Closed

Make it possible to tell if a tab currently has focus #17689

dgl opened this issue Aug 9, 2024 · 4 comments
Labels
Area-VT Virtual Terminal sequence support Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. Product-Terminal The new Windows Terminal.

Comments

@dgl
Copy link

dgl commented Aug 9, 2024

Description of the new feature/enhancement

It would be useful for a program running in a terminal to be able to tell whether it currently has focus. My use case for this is after a command finishes, I sometimes want my shell to ring the bell, which makes me notice the terminal, but this is annoying if I currently have the window focused.

The FocusIn/FocusOut reporting alone isn't enough, as that needs a focus change to happen and it's not always possible to have reporting on when running an arbitrary program.

Proposed technical implementation details (optional)

There is some discussion on https://unix.stackexchange.com/questions/480052/how-do-i-detect-whether-my-terminal-has-focus-in-the-gui-from-a-shell-script

Apparently GNOME based terminals (VTE) send an event immediately when FocusIn/FocusOut reporting is turned on. In some ways this would be the easiest way to implement this, as other terminals do already do it, so programs have to handle this. If other terminals weren't doing it, I would be against it, but given they are programs have to deal with it anyway.

Alternatively maybe wt.exe could allow querying for whether a $WT_SESSION currently has focus (although the details of that seem harder, some X11 terminals have a $WINDOWID which directly corresponds to the X11 window ID, I don't know how to go from the guid session ID to anything useful).

@dgl dgl added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Aug 9, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Tag-Fix Doesn't match tag requirements Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting labels Aug 9, 2024
@carlos-zamora carlos-zamora added Area-VT Virtual Terminal sequence support Product-Terminal The new Windows Terminal. and removed Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting Needs-Tag-Fix Doesn't match tag requirements labels Aug 14, 2024
@carlos-zamora
Copy link
Member

Thanks for filing this! The VT approach is probably best. @j4james what do you think?

@carlos-zamora carlos-zamora added this to the Backlog milestone Aug 14, 2024
@j4james
Copy link
Collaborator

j4james commented Aug 15, 2024

It seems like a reasonable extension, but this is xterm's protocol, so it should be up to Thomas to decide whether it's OK to change or not. If xterm decides to support the extension, then I'd be OK with us adopting it too. Otherwise I'd be hesitant to encourage what could be a breaking change so someone else's protocol.

@zadjii-msft
Copy link
Member

Taking a step back: if your goal is ultimately:

My use case for this is after a command finishes, I sometimes want my shell to ring the bell, which makes me notice the terminal, but this is annoying if I currently have the window focused

#7955 has quite a bit of related discussion. Especially in #7955 (comment). I believe the "$profile.notifyOnNextPrompt": "audible" would basically be what you're looking for/?

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 20, 2024
Copy link
Contributor

This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment.

@microsoft-github-policy-service microsoft-github-policy-service bot added the No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. label Aug 24, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot removed this from the Backlog milestone Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-VT Virtual Terminal sequence support Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something No-Recent-Activity This issue/PR is going stale and may be auto-closed without further activity. Product-Terminal The new Windows Terminal.
Projects
None yet
Development

No branches or pull requests

4 participants