-
Notifications
You must be signed in to change notification settings - Fork 8.5k
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
Show indicator of bell in tab #8637
Conversation
First of all, love the work, as always. Second, I think we should revisit the "hide bell after 1 second" design. In iTerm2, I observed the following behaviour:
This design should help people easily find what the actual tab is causing the bell. But if it just disappears automatically, then people might still be confused about it. |
I think that makes sense, thanks for the suggestion!
This will bear some thinking about what entails as an interaction |
My definition of “interaction” so far is just typing something. That is the most common way user would interact with a terminal, I think. But I can’t say for sure that’s the only way to make bell indicator disappears.
获取 Outlook for iOS<https://aka.ms/o0ukef>
|
Had a chat with @DHowett, we will implement this as: the bell indicator goes away when the tab receives focus, and if the tab was already focused when the bell was raised then the indicator goes away after a small amount of time. We are choosing this implementation for now because of the dubiousness of what an interaction means (aside from typing there's also clicking a link for example) and also because of edge cases such as the tab key-up from alt tabbing into the tab being considered a key press. |
Thanks @PankajBhojwani for the thoughtful implementation. Personally I do not use speakers that much so I’m really looking forward to this feature. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay my initial feedback is regarding this discussion: Should we put the bell on the right of the tab title? I don't love that it causes the whole string to jump back and forth |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay this is all reasonable to me. I guess my biggest concern is on the bell placement. I really think it should be on the right.
🌛
💪 💪
👖
In a follow-up, we could have the bell "fade out", like it does in browsers, as opposed to just immediately hiding.
In browsers if you have sound coming from a tab the bell/speaker icon shows up on the left though! Since we chose the progress ring placement to match how browsers do it, should we do the same for the bell? |
left! left! left! |
TBH I’m OK with both placement. Wait, you can dismiss a review? How many features GitHub has added?... |
auto weakThis{ get_weak() }; | ||
|
||
if (auto tab{ weakThis.get() }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will always pass. Since you constructed the event handler (line 290) with a weak reference, c++/winrt automatically ensures that you have a strong living reference inside this function. You can safely use this
or just.. use unqualified members.
if (auto tab{ weakThis.get() }) | ||
{ | ||
tab->ShowBellIndicator(false); | ||
tab->_bellIndicatorTimer.value().Stop(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tab->_bellIndicatorTimer.value().Stop(); | |
tab->_bellIndicatorTimer->Stop(); |
tab->_UpdateActivePane(sender); | ||
tab->_RecalculateAndApplyTabColor(); | ||
} | ||
tab->_focusState = WUX::FocusState::Programmatic; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i hope this is right! what else is _focusState
being used for?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only other places (before this PR) _focusState
was being checked/updated: TerminalTab::_RefreshVisualState
and TerminalTab::Focus
However, without this addition, the tab does not know when the app itself loses focus (by alt-tab/minimize etc) so it used to still think it is focused even though the app itself and the underlying control(s) are all unfocused.
if (tab) | ||
{ | ||
// update this tab's focus state | ||
tab->_focusState = WUX::FocusState::Unfocused; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just to be sure - there will be a moment, when you move from pane A to pane B, that the tab thinks it does not have focus?
if (auto tab{ weakThis.get() }) | ||
{ | ||
DispatcherTimer bellIndicatorTimer; | ||
bellIndicatorTimer.Interval(std::chrono::milliseconds(2000)); | ||
bellIndicatorTimer.Tick({ get_weak(), &TerminalTab::_BellIndicatorTimerTick }); | ||
bellIndicatorTimer.Start(); | ||
tab->_bellIndicatorTimer.emplace(std::move(bellIndicatorTimer)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can an application DOS us by spamming bell? it will make us start a huge number of timers, and keep overwriting the optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(we'll waste memory for up to 2 seconds at which point they'll start to fire)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yes good catch! We now only create a new timer if the optional doesn't have a value
In PowerShell, try this: "`a"*1000 You will be rewarded with...
This also happens during normal belling, unfortunately. It doesn't take a thousand, that just made it quite reproable. 😄 |
Hello @DHowett! Because this pull request has the p.s. you can customize the way I help with merging this pull request, such as holding this pull request until a specific person approves. Simply @mention me (
|
When we emit a BEL (visual or audible), show an indicator in the tab header If the tab the BEL is coming from is not focused when the BEL is raised, the indicator in its header will be removed when the tab gains focus. If the tab was already focused when the BEL was emitted, then the indicator goes away after 2 seconds. Closes microsoft#8106
When we emit a BEL (visual or audible), show an indicator in the tab
header
If the tab the BEL is coming from is not focused when the BEL is raised,
the indicator in its header will be removed when the tab gains focus. If
the tab was already focused when the BEL was emitted, then the indicator
goes away after 2 seconds.
Closes #8106