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

Allow Opacity to be set differently in both focused and unfocused terminals #15974

Merged
merged 13 commits into from
Oct 13, 2023

Conversation

Jaswir
Copy link
Contributor

@Jaswir Jaswir commented Sep 16, 2023

Summary of the Pull Request

Closes #11092

Allowing opacity to be set differently in both focused and unfocused terminals

References and Relevant Issues

#11092 , references: #7158

Detailed Description of the Pull Request / Additional comments

Allowing Opacity to be set differently in both focused and unfocused terminals:

unfocused_opacity
image

jolsen

image

_runtimeFocusedOpacity

Mike also had to say something about this: #2531 (comment)

Initially I had something like _setOpacity(newAppearance->Opacity());

But with the introduction of unfocused opacity we encounter new challenges:
When Adjusting the Opacity with CTRL+SHIFT+Mouse Scroll Wheel or Set background opacity in command pallette, the Runtime opacity changes, but when we go to unfocused and back to focused the opacity changes back to focused opacity in Settings.

Also when adjusting opacity through the command palette the window becomes unfocused and then focused again after setting background opacity hence the _setOpacity(newAppearance->Opacity()); would override the changes made through command palette
runtimeFocusedOpacity

command_pallette_focusswitches

With the introduction of unfocused opacity we encounter new challenges. The runtime opacity stores both the unfocused opacity and focused opacity from settings at different moments. This all works well until we combine this with Adjusting the Opacity with CTRL+SHIFT+Mouse Scroll Wheel or Set background opacity in command pallette. This brings the need for a separate Focused Opacity. When we change the runtime opacity with scroll wheel or through command pallette this value needs to be stored separately from the one in settings. So we can change back to it when going to unfocused mode and back to focused instead of the focused opacity defined in settings.

skipUnfocusedOpacity solves Opacity going from solid to unfocused to focused bug:

skipUnfocusedOpacity_bug

Validation Steps Performed

  • Checked if unfocused Opacity works well when adjusting opacity through Mouse Scroll Wheel or Command Palette and in combination with Acrylic as mentioned in "Detailed Description of the Pull Request / Additional comments"

PR Checklist

@microsoft-github-policy-service microsoft-github-policy-service bot added Issue-Task It's a feature request, but it doesn't really need a major design. Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Product-Terminal The new Windows Terminal. labels Sep 16, 2023
@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 16, 2023

Would be handy to have tests, so many different permutations to check with Acrylic + Opacity + Mouse Scroll Wheel + Adjusting Opacity through Command Palette

@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 16, 2023

@lhecker

Made a new PR!

@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 16, 2023

Ugh there's still some bugs was sure I removed them, one sec ...
Something must have broken when reducing the function calls from 2 to 1

Copy link
Member

@carlos-zamora carlos-zamora left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks and feels great! Tested it out on my machine even :)

Here's some other feedback:

I'll approve since the comments are pretty small, but please make sure you get to them. Thanks and great work!

src/cascadia/TerminalControl/ControlCore.cpp Outdated Show resolved Hide resolved
// Skip Unfocused Opacity when EnableUnfocusedAcrylic is false
// and Acrylic is true as this results into seeing the opacity going
// from solid to unfocused to focused bug.
bool skipUnfocusedOpacity = !focused && !(!_settings->EnableUnfocusedAcrylic() && UseAcrylic());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
bool skipUnfocusedOpacity = !focused && !(!_settings->EnableUnfocusedAcrylic() && UseAcrylic());
bool skipUnfocusedOpacity = !focused && (_settings->EnableUnfocusedAcrylic() || !UseAcrylic());

Personally, I'd prefer that you De Morgan's law it haha

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea there's definitely something real weird with the way the conditionals are worded here that confuses me.

hell it might be easier to say useUnfocusedOpacity = focused && _settings->EnableUnfocusedAcrylic()... and flip the next statement around...

Copy link
Contributor Author

@Jaswir Jaswir Oct 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zadjii-msft Should be good now

Copy link
Member

@zadjii-msft zadjii-msft left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The wording of these conditionals has me scratching my head. They might need a bit of re-wording just to make the logic a bit easier to follow, but if the code works, I'm happy to ship it

// Skip Unfocused Opacity when EnableUnfocusedAcrylic is false
// and Acrylic is true as this results into seeing the opacity going
// from solid to unfocused to focused bug.
bool skipUnfocusedOpacity = !focused && !(!_settings->EnableUnfocusedAcrylic() && UseAcrylic());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yea there's definitely something real weird with the way the conditionals are worded here that confuses me.

hell it might be easier to say useUnfocusedOpacity = focused && _settings->EnableUnfocusedAcrylic()... and flip the next statement around...

// and Acrylic is true as this results into seeing the opacity going
// from solid to unfocused to focused bug.
bool skipUnfocusedOpacity = !focused && !(!_settings->EnableUnfocusedAcrylic() && UseAcrylic());
double newOpacity = skipUnfocusedOpacity ? newAppearance->Opacity() : FocusedOpacity();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually what?

If skipUnfocusedOpacity: use newAppearance->Opacity.
else, we shouldn't skip unfocused opacity, and we should use FocusedOpacity

?

That doesn't really seem to make sense, at least not literally.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@zadjii-msft Should be good now

@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 Sep 19, 2023
@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 21, 2023

@zadjii-msft

Hey Mike,
How was your Hackathon week? Hope it was nice.

I was wondering if you got a chance yet to answer my question:
#2531 (comment)

But to be honest I'd really like you to answer this question:
It keeps me kinda distracted from focusing on this to not have it answered yet.
#2531 (comment)

@microsoft-github-policy-service microsoft-github-policy-service bot added Needs-Attention The core contributors need to come back around and look at this ASAP. and removed Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something labels Sep 21, 2023
@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 21, 2023

Looks and feels great! Tested it out on my machine even :)

Here's some other feedback:

I'll approve since the comments are pretty small, but please make sure you get to them. Thanks and great work!

Thanks Carlos.

"Looks and feels great!"

xD, I am glad you say that. I actually used to be one of the best (1000) game designers in The Netherlands if I say so myself in 2018, 2019 and there's this concept called Game Feel which is a lot about how things feel. Usually needs lots of player testing before it's good. Glad you like it! Hope the users will like it as well. If you like Game Feel and want to see a fun presentation about it see this: https://www.youtube.com/watch?v=AJdEqssNZ-U
Obviously this concept is not limited to just games and very much also applicable for the windows terminal.

I'll look into the docs and comments. Not sure what to add to the docs, let me try something..

@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 21, 2023

@zadjii-msft @carlos-zamora

I think my expectations of you guys may be wrong. I expected Microsoft Engineers would like go over all the possible scenario's when reviewing. in this case try all the various permutations of UseAcrylic , Opacity in Unfocused and Focused mode + all other combinations with Adjust Opacity in Command Palette and Scroll Wheel, etc. Maybe come up with things I missed, like edgecases about the feature (not code stuff). But didn't notice this in 7158 or this one.

It seems like your reviewing process is mostly aimed at the code quality?
What is the reviewing process of code like at Microsoft? I guess this differs per team?

@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 22, 2023

@carlos-zamora @zadjii-msft
Having some trouble making the code clear to you / other developers for this project.
I reworded the code this should be good. Let me know if it's not!

      bool useFocusedRuntimeOpacity = focused || (!_settings->EnableUnfocusedAcrylic() && UseAcrylic());
      double newOpacity = useFocusedRuntimeOpacity ?
                              FocusedOpacity() :
                              newAppearance->Opacity();
      _setOpacity(newOpacity, focused);

But not sure how to make this clear in a concise way with comments.
@zadjii-msft @carlos-zamora Let me know what is clear to you.

Essentially there are 2 special things going on that I want to communicate somehow with the comments to make it more clear.

  1. Incase the window goes from unfocused to focused it should always use the runtime focused opacity and not the focused opacity in settings because of what I explain in the PR Description in _runtimeFocusedOpacity
  2. Incase EnableUnfocusedAcrylic is disabled and Focused Acrylic is set to true, the terminal should not use the unfocused opacity, but ignore it and use focused runtime opacity. as described in PR description in skipUnfocusedOpacity

So now here's where it get's unclear for me
I could comment at 3 locations:

About the first one
image

I think it woud be good to mention something like that this prevents a bug from happening / covers an edge case.
That focused runtime Opacity should be used when EnableUnfocusedAcrylic is false and Acrylic is true because otherwise there's a bug where you see the opacity going from solid to unfocused to focused when switching from unfocused to focused.

Second, Third:
image

This could also be mentioned here:
image

Also I could tell about how EnableUnfocusedAcrylic and Focused and Unfocused Acrylic and Opacity in the docs and provide more clearance there?

@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 22, 2023

@carlos-zamora @zadjii-msft
Ok I reworded the conditionals and added a function description like with some of the other functions to describe what the new parameter does and adapted my comments to make things more clear for other developers hopefully.

Let me know what you think! I'd be happy to adapt it if needed. Still working on the docs

DHowett added a commit that referenced this pull request Sep 22, 2023
@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 25, 2023

@zadjii-msft

Hi Mike,

This might be a silly way to do this.
I'll just come up straight with it.
I am looking for a referral for Microsoft.
Can you give me a referral?

Solving 7158 boosted my confidence to start seriously applying to Big Tech Jobs. Can you give me a referral? I rather have a referral from you then someone that doesn’t know me.

Also, are there any relevant opportunities at Microsoft that would let me work on this project or similar ones to it?

PS: I'll be continuing with the docs part and making a PR for that probably later this week

@DHowett @lhecker @carlos-zamora @j4james @PankajBhojwani
I am not sure how to approach this situation hence I put this in the group with you more Senior Experienced Engineers.

@DHowett
Copy link
Member

DHowett commented Sep 26, 2023

@Jaswir sorry for the silence! We are all heads down preparing for our release on Tuesday. We'll have some more mental bandwidth as a team for discussions and PR reviews after that 🙂

@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 26, 2023

@DHowett

@Jaswir sorry for the silence! We are all heads down preparing for our release on Tuesday. We'll have some more mental bandwidth as a team for discussions and PR reviews after that 🙂

Thanks for letting me know! Will unfocused Acrylic be in the release ??? Lots of users want that and would be happy with that, including me.

@Jaswir
Copy link
Contributor Author

Jaswir commented Sep 26, 2023

@carlos-zamora Updated the docs

@Jaswir Jaswir requested a review from zadjii-msft October 4, 2023 00:19
@Jaswir
Copy link
Contributor Author

Jaswir commented Oct 12, 2023

@zadjii-msft Did you get a chance to rereview it yet? It's blocking #15717

@zadjii-msft zadjii-msft merged commit 27e1081 into microsoft:main Oct 13, 2023
@Jaswir
Copy link
Contributor Author

Jaswir commented Oct 25, 2023

@DHowett

Hey Dustin, when it's convenient for you. Could you please add this to the next release? I want this in my default windows preview terminal. It would make me very happy :D If it wouldn't be too much effort for you I'd really appreciate it.

Thanks in advance.

DHowett pushed a commit that referenced this pull request Oct 26, 2023
…minals (#15974)

## Summary of the Pull Request
Closes #11092

Allowing `opacity `to be set differently in both focused and unfocused
terminals

## References and Relevant Issues
#11092 , references: #7158

## Detailed Description of the Pull Request / Additional comments

### Allowing Opacity to be set differently in both focused and unfocused
terminals:

![unfocused_opacity](https://github.com/microsoft/terminal/assets/15957528/1c38e40b-4678-43ec-b328-ad79d222579f)

![image](https://github.com/microsoft/terminal/assets/15957528/3e3342a8-7908-41db-9c37-26c89f7f2456)

![jolsen](https://github.com/microsoft/terminal/assets/15957528/68553507-d29e-4513-89ce-b1cd305d28b7)

![image](https://github.com/microsoft/terminal/assets/15957528/18864f60-91d0-4159-87da-2b2ee1637a4c)

## `_runtimeFocusedOpacity`

Mike also had to say something about this:
#2531 (comment)

Initially I had something like ` _setOpacity(newAppearance->Opacity());`

But with the introduction of unfocused opacity we encounter new
challenges:
When Adjusting the Opacity with **CTRL+SHIFT+Mouse Scroll Wheel** or
**Set background opacity** in command pallette, the Runtime opacity
changes, but when we go to unfocused and back to focused the opacity
changes back to focused opacity in Settings.

Also when adjusting opacity through the command palette the window
becomes unfocused and then focused again after setting background
opacity hence the ` _setOpacity(newAppearance->Opacity());` would
override the changes made through command palette

![runtimeFocusedOpacity](https://github.com/microsoft/terminal/assets/15957528/4de63057-d658-4b5e-99ad-7db050834ade)

![command_pallette_focusswitches](https://github.com/microsoft/terminal/assets/15957528/372526eb-cf0c-40f8-a4e5-a0739f1f0e05)

With the introduction of unfocused opacity we encounter new challenges.
The runtime opacity stores both the unfocused opacity and focused
opacity from settings at different moments. This all works well until we
combine this with Adjusting the Opacity with **CTRL+SHIFT+Mouse Scroll
Wheel** or **Set background opacity** in command pallette. This brings
the need for a separate Focused Opacity. When we change the runtime
opacity with scroll wheel or through command pallette this value needs
to be stored separately from the one in settings. So we can change back
to it when going to unfocused mode and back to focused instead of the
focused opacity defined in settings.

## `skipUnfocusedOpacity` solves Opacity going from solid to unfocused
to focused bug:

![skipUnfocusedOpacity_bug](https://github.com/microsoft/terminal/assets/15957528/ecc06dcf-fbef-4fef-a40f-68278fdbfb12)

## Validation Steps Performed

- Checked if unfocused Opacity works well when adjusting opacity through
Mouse Scroll Wheel or Command Palette and in combination with Acrylic as
mentioned in "Detailed Description of the Pull Request / Additional
comments"

## PR Checklist

- [x] Closes #11092
- [ ] Tests added/passed
- [x] Documentation updated
- If checked, please file a pull request on [our docs
repo](https://github.com/MicrosoftDocs/terminal) and link it
here:(MicrosoftDocs/terminal#714)
- [ ] Schema updated (if necessary)

(cherry picked from commit 27e1081)
Service-Card-Id: 90949918
Service-Version: 1.19
mattwojo added a commit to MicrosoftDocs/terminal that referenced this pull request May 29, 2024
Added Enable Unfocused Acrylic Global Setting 

Updated Opacity and Acrylic. 
No more OS limitations!

microsoft/terminal#15974

---------

Co-authored-by: Matt Wojciakowski <mattwoj@microsoft.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Settings Issues related to settings and customizability, for console or terminal Area-TerminalControl Issues pertaining to the terminal control (input, selection, keybindings, mouse interaction, etc.) Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Attention The core contributors need to come back around and look at this ASAP. Product-Terminal The new Windows Terminal. zBugBash-Consider
Projects
Development

Successfully merging this pull request may close these issues.

Add support for Acrylic and Opacity in "Unfocused Appearance"
4 participants