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

Investigate: AcrylicBlur always on in an inactive window #7158

Closed
harounhajem opened this issue Aug 3, 2020 · 87 comments · Fixed by #15923
Closed

Investigate: AcrylicBlur always on in an inactive window #7158

harounhajem opened this issue Aug 3, 2020 · 87 comments · Fixed by #15923
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.) Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Milestone

Comments

@harounhajem
Copy link

Proposed feature:
The option to always have AcrylicBlur turned on even when the window loses focus. I'm a power-user and understand the GPU implications if blur is always turned on, but I'm willing to pay that price for the beauty of a blurred background. I've seen it in other UWP apps so it is possible.

Terminal

Current behavior :
AcrylicBlur is turned off, it dips to the default background color, when the window(terminal) loses focus, which is "default" behavior for UWP.

@harounhajem harounhajem added the Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. label Aug 3, 2020
@ghost ghost added 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 3, 2020
@zadjii-msft
Copy link
Member

I've seen it in other UWP apps so it is possible.

Which applications have you seen this in? The system standard AcrylicBrush (the one we're using) disables acrylic when the window loses focus, which isn't something we can control.

@zadjii-msft zadjii-msft added the Needs-Author-Feedback The original author of the issue/PR needs to come back and respond to something label Aug 3, 2020
@electronic-dk
Copy link

@zadjii-msft I've definitely seen it in a couple of apps, this one comes to mind first:
https://github.com/JasonStein/Notepads

@zadjii-msft
Copy link
Member

Ah yea, that one's special though. They're not using the actual system acrylic brush. They're actually rolling their own acrylic brush, using the same combination of effects as the acrylic brush, but with the "disable when the window loses focus" effect disabled.

We absolutely could copy that mechanism (just roll our own), but we just need someone to write that code 😄 I think we've got a dupe sitting around here somewhere for that...

@harounhajem
Copy link
Author

@zadjii-msft Thanks for the quick reply. I've had the same discussion with the team working on FluentTerminal, they advised me to fork it from NotePads and make a pull-request in the FluentTerminal project. But unfortunately I didn't have the time to complete it.

However it would be an awesome feature to have and it follows Microsoft Fluent Design principles. I really hope that there is time to implement this feature in alongside this projects roadmap.

Thanks for a great terminal and we are looking forward to the upcoming releases.

@ghost ghost 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 Aug 3, 2020
@zadjii-msft
Copy link
Member

To be fair, Microsoft Fluent Design -> Style for Windows apps -> Acrylic specifically calls out not using acrylic for unfocused windows:

In addition, both background acrylic and in-app acrylic appear as a solid color:

  • When the user turns off transparency in Settings > Personalization > Color
  • When Battery Saver mode is activated
  • When the app runs on low-end hardware

In addition, only background acrylic will replace its translucency and texture with a solid color:

  • When an app window on desktop deactivates
  • When the Windows app is running on phone, Xbox, HoloLens or tablet mode
    (emph. added)

That being said, I'm gonna leave this open for now. If someone wants to add the "unfocused acrylic" brush to the terminal (behind an off-by-default global setting), I'm not really opposed to stopping them tbh.

@zadjii-msft zadjii-msft added 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.) Help Wanted We encourage anyone to jump in on these. Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. Needs-Attention The core contributors need to come back around and look at this ASAP. labels Aug 3, 2020
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Aug 3, 2020
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Aug 3, 2020
@0x7c13
Copy link
Member

0x7c13 commented Aug 3, 2020

To be fair, Microsoft Fluent Design -> Style for Windows apps -> Acrylic specifically calls out not using acrylic for unfocused windows:

In addition, both background acrylic and in-app acrylic appear as a solid color:

  • When the user turns off transparency in Settings > Personalization > Color
  • When Battery Saver mode is activated
  • When the app runs on low-end hardware

In addition, only background acrylic will replace its translucency and texture with a solid color:

  • When an app window on desktop deactivates
  • When the Windows app is running on phone, Xbox, HoloLens or tablet mode
    (emph. added)

That being said, I'm gonna leave this open for now. If someone wants to add the "unfocused acrylic" brush to the terminal (behind an off-by-default global setting), I'm not really opposed to stopping them tbh.

Hi all, notepads author here. I am glad to help if you guys don't mind.

My two cents regarding to that design principle for how to properly use acrylic effect: They are absolutely right but for apps like terminal, they can be special since they are not product for "average consumer" and I personally treat the terminal as one advanced dev tool. These kind of apps can go out of box here.

@zadjii-msft
Copy link
Member

That's totally fair, and we're already outside the box here since the body of the Terminal isn't really a "transient surface" either 😝

@electronic-dk
Copy link

I wonder if this effect really uses that much GPU so that it's explicitly requested to turn it off on all types of devices. I feel like it should work fine in background on laptops connected to AC and desktop PCs so it's only justifiable for mobile devices or if the energy saving mode is on. With that being said, I really hope WinUI team will reconsider this aspect and make it optional. Unfortunately, I can't remember if there is a ticket in the WinUI repo for this matter.

@DHowett DHowett removed the Needs-Triage It's a new issue that the core contributor team needs to triage at the next triage meeting label Aug 4, 2020
@DHowett DHowett changed the title AcrylicBlur always on in an inactive window Investigate: AcrylicBlur always on in an inactive window Aug 4, 2020
@SinanAkkoyun

This comment has been minimized.

@harounhajem
Copy link
Author

harounhajem commented Aug 6, 2020

Just do it. Everyone wants acrylic in background and blur amount settings.

If you like the idea you could join the dev. effort or like 👍 the post and spread the word so other developer can like 👍 it. The more likes a feature gets the more likely it will be develop. 😎

@SinanAkkoyun
Copy link

Yes, how hard is joining the dev team? Or can I just contribute?

@zadjii-msft
Copy link
Member

It's an open source project, and we're happy to accept community contributions. This issue is even marked "Help Wanted"
image

which means it's one of the easier tasks for a member of the community to implement.

@MitchTalmadge
Copy link

That looks fantastic. I love that configuration scheme.

@MrShortcut
Copy link

It's not a feature, @MrShortcut is making a suggestion of a hacky workaround for a fake "acrylic blur" (take a screenshot of your desktop, then blur it in e.g. Photoshop, and set it as a photo background). Not something you need to worry about. It was just a suggestion for a way to make the window still look blurred until the actual blur-while-inactive feature that you're working on was implemented.

exactly the alternative solution for me, use the powershell in full screen (ALT+ENTER), focus the terminal, take screenshot, save the screenshot, and use the screenshot as background in powershell, hacky method while the main feature unfocusedAcrilicBlur is ready an deployed.

@Jaswir
Copy link
Contributor

Jaswir commented Aug 5, 2023

@0x7c13

So are you like the actual inventor of Notepad ??? :O

@Jaswir
Copy link
Contributor

Jaswir commented Aug 7, 2023

Update: the plumbing is going well!

@MrShortcut
Copy link

with the hacky method my powershell looks like this
image

@Jaswir
Copy link
Contributor

Jaswir commented Aug 10, 2023

Got the plumbing done and working now AFAIK! Ofcourse, you'll only see it working when I apply/implement THAT functionality and send a gif of that :D

@Jaswir
Copy link
Contributor

Jaswir commented Aug 21, 2023

Thought I'd send you an update.

Acrylic focused, non acrylic unfocused:
acrylic_foc_transparent_unfo2

image

Functionality for different acrylic in focused and unfocused is there, code really ugly though ;) (also some bugs probably).

@Jaswir Jaswir mentioned this issue Sep 2, 2023
4 tasks
@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Sep 2, 2023
@Jaswir
Copy link
Contributor

Jaswir commented Sep 2, 2023

image

A hero was born 😎

It took a while but they say if you’re patient you’ll be rewarded.
Funny thing is I am not patient at all.

Anyway after 3 years there you go ;)

PS:
This PR is split up in two parts #7158 covers allowing Acrylic to be set differently in both focused and unfocused terminals. And EnableUnfocusedAcrylic Global Setting that controls if unfocused acrylic is possible so that people can disable that behavior.

#11092 will be about enabling opacity as both an appearance setting, allowing it to be set differently in both focused and unfocused terminals. The other part of this PR I will cover in 11092

@Jaswir
Copy link
Contributor

Jaswir commented Sep 7, 2023

So there's 2 brushes to make the terminal Acrylic: Backdrop and HostBackDrop.
The Backdrop brush is used to make the unfocused terminal have Acrylic.

I noticed they're somewhat different the HostBackdrop one is brighter and it's more transparent sometimes in the edges. This is the default behaviour of the brushes not much I can do about it. But can use the Backdrop only for unfocused terminals

Which one you like better? I posted them below so you can vote.

@mpusch88
Copy link

mpusch88 commented Sep 7, 2023

HostBackdrop looks better in my opinion - I take it there is no way to implement that for unfocused as well?

Keep up the good work!

@Jaswir
Copy link
Contributor

Jaswir commented Sep 7, 2023

A: has HostBackdrop for focused and Backdrop to make unfocused Acrylic work
edgecase_backdrop_acrylic

@Jaswir
Copy link
Contributor

Jaswir commented Sep 7, 2023

B: has Backdrop for focused and unfocused
edgecase_backdrop_acrylic_option_old

@Jaswir
Copy link
Contributor

Jaswir commented Sep 7, 2023

HostBackdrop looks better in my opinion - I take it there is no way to implement that for unfocused as well?

Keep up the good work!

No

zadjii-msft added a commit that referenced this issue Sep 7, 2023
## Summary of the Pull Request
Closes #7158 

Enabling Acrylic as both an appearance setting (with all the plumbing),
allowing it to be set differently in both focused and unfocused
terminals. EnableUnfocusedAcrylic Global Setting that controls if
unfocused acrylic is possible so that people can disable that behavior.

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

## Detailed Description of the Pull Request / Additional comments

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

#### A

![A](https://github.com/microsoft/terminal/assets/15957528/c43965f2-f458-46ae-af1c-a2107dac981a)

#### B

![B](https://github.com/microsoft/terminal/assets/15957528/e84ef1a8-8f4c-467a-99c2-9427061b3e3e)

#### C

![C](https://github.com/microsoft/terminal/assets/15957528/63fd35ba-a55a-4c1a-8b1c-5b571aa902ed)

#### D

![D](https://github.com/microsoft/terminal/assets/15957528/05108166-1c6e-406e-aec0-80023fc3f57c)

``` json
"profiles":
{
    "list":
    [
        {
            "commandline": "pwsh.exe",
            "name": "A",
            "unfocusedAppearance":
            {
                "useAcrylic": true,
            },
            "useAcrylic": true,
        },
        {
            "commandline": "pwsh.exe",
            "name": "B",
            "unfocusedAppearance":
            {
                "useAcrylic": false,
            },
            "useAcrylic": true,
        },
        {
            "commandline": "pwsh.exe",
            "name": "C",
            "unfocusedAppearance":
            {
                "useAcrylic": true,
            },
            "useAcrylic": false,
        },
        {
            "commandline": "pwsh.exe",
            "name": "D",
            "unfocusedAppearance":
            {
            },
            "useAcrylic": false,
        },
    ]
}
```

- **A**: AcrylicBlur always on
- **B**: Acrylic when focused, not acrylic when unfocused
- **C**: Why the hell not. Not Acrylic when focused, Acrylic when
unfocused.
- **D:**  Possible today by not using Acrylic. 

### EnableUnfocusedACrylic global setting that controls if unfocused
acrylic is possible
So that people can disable that behavior:

![256926990-3c42d99a-67de-4145-bf41-ce3995035136](https://github.com/microsoft/terminal/assets/15957528/eef62c14-d2bd-4737-b86e-dcb3588eb8f7)

### Alternate approaches I considered: 
Using `_InitializeBackgroundBrush` call instead of
`_changeBackgroundColor(bg) in
``TermControl::_UpdateAppearanceFromUIThread`. Comments in this function
mentioned:

``` *.cs'
// In the future, this might need to be changed to a
// _InitializeBackgroundBrush call instead, because we may need to
// switch from a solid color brush to an acrylic one.
```
I considered using this to tackle to problem, but don't see the benefit.
The only time we need to update the brush is when the user changes the
`EnableUnfocusedAcrylic ` setting which is already covered by
`fire_and_forget TermControl::UpdateControlSettings`
        
### Supporting different Opacity in Focused and Unfocused Appearance???
This PR is split up in two parts #7158 covers allowing Acrylic to be set
differently in both focused and unfocused terminals. And
EnableUnfocusedAcrylic Global Setting that controls if unfocused acrylic
is possible so that people can disable that behavior.

#11092 will be about enabling opacity as both an appearance setting,
allowing it to be set differently in both focused and unfocused
terminals.

### Skipping the XAML for now:
“I actually think we may want to skip the XAML on this one for now.
We've been having some discussions about compatibility settings, global
settings, stuff like this, and it might be _more- confusing to have you
do something here. We can always add it in post when we decide where to
put it.”
-- Mike Griese

## Validation Steps Performed

#### When Scrolling Mouse , opacity changes appropriately, on opacity
100 there are no gray lines or artefacts

![edgecase_scrollwheel](https://github.com/microsoft/terminal/assets/15957528/29a1b11e-05b8-4626-abd2-4f084ae94a8d)


![image](https://github.com/microsoft/terminal/assets/15957528/c05ea435-8867-4804-bcdc-2074df08cec1)

#### When Adjusting Opacity through command palette, opacity changes
appropriately, on opacity 100 there are no gray lines or artefacts

![edgecase_adjustopacity](https://github.com/microsoft/terminal/assets/15957528/a59b4d6d-f12e-48da-96bb-3eb333ac4637)


![image](https://github.com/microsoft/terminal/assets/15957528/c05ea435-8867-4804-bcdc-2074df08cec1)

#### When opening command palette state goes to unfocused, the acrylic
and color change appropriately

![edge_case_command_palette](https://github.com/microsoft/terminal/assets/15957528/ec0cd8b5-676e-4235-8231-a10a5689c0b8)


![image](https://github.com/microsoft/terminal/assets/15957528/4300df70-f64b-4001-8731-b3b69471ea78)

#### Stumbled upon a new bug when performing validation steps #15913

![264637964-494d4417-6a35-450a-89f7-52085ef9b546](https://github.com/microsoft/terminal/assets/15957528/fee59c4a-400b-4e40-912b-ea8c638fc979)

## PR Checklist

- [x] Closes #7158
- [X] 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: #xxx
- [x] Schema updated (if necessary)

---------

Co-authored-by: Mike Griese <migrie@microsoft.com>
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Sep 7, 2023
@ADPenrose
Copy link

So, this was already merged. May be a bit of a dumb question, but, do we need to wait for an update so that this is available, or can we just take some code and slap it into the settings.json file?

@Jaswir
Copy link
Contributor

Jaswir commented Sep 8, 2023

@ADPenrose

You can always git clone the developer version from here: https://github.com/microsoft/terminal
And build and run it using the READMe.md. If you really wanna try it out.

For more information about when the update will be available exactly in the Terminal Preview version @zadjii-msft can help with that and @DHowett too I think .

@vlxjack
Copy link

vlxjack commented Sep 11, 2023

Amazing! Thank you! Great Work!

@Jaswir
Copy link
Contributor

Jaswir commented Sep 13, 2023

For updates on allowing opacity to be set differently in both focused and unfocused terminals.
I suggest subscribing to:
#11092

@Jaswir
Copy link
Contributor

Jaswir commented Sep 26, 2023

@ADPenrose
Guess what's going to be released today! :
https://github.com/microsoft/terminal/releases

@ADPenrose
Copy link

@Jaswir You just made my day haha! Thanks a lot c:

zadjii-msft pushed a commit that referenced this issue Oct 13, 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)
DHowett pushed a commit that referenced this issue 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
@schm1dtmac
Copy link

schm1dtmac commented Jan 27, 2024

@Jaswir Any idea if these changes could also be extended to tab-row Acrylic, or would that require a substantial amount of additional work beyond what was already implemented for window background Acrylic? (Not sure whether this would go in a separate issue or not though)

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.) Help Wanted We encourage anyone to jump in on these. In-PR This issue has a related PR Issue-Task It's a feature request, but it doesn't really need a major design. Needs-Tag-Fix Doesn't match tag requirements Product-Terminal The new Windows Terminal.
Projects
Status: Work completed (without spec)
Status: Done
Development

Successfully merging a pull request may close this issue.