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

Add support for Acrylic and Opacity in "Unfocused Appearance" #11092

Closed
jolsen71 opened this issue Aug 31, 2021 · 13 comments · Fixed by #15974
Closed

Add support for Acrylic and Opacity in "Unfocused Appearance" #11092

jolsen71 opened this issue Aug 31, 2021 · 13 comments · Fixed by #15974
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

@jolsen71
Copy link

Please add "Acrylic" setting support to unfocused appearance options being introduced in PR #10317

I'd really like to make my unfocused windows to have transparency instead of opaque. Ideally, I could make my unfocused windows more transparent than my focused window.

Right now, since unfocused windows are opaque, they appear more predominant on the desktop than the focused window appears when configured with acrylic enabled and semi-transparent.

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

You know, we don't have an issue tracking this specific task, so congratulations, this is now that thread.

We need to first do #7158 to allow unfocused windows to have acrylic at all. Once that's done, we can add it back to the Appearance object and the unfocusedAppearance settings.

@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.) Issue-Task It's a feature request, but it doesn't really need a major design. Product-Terminal The new Windows Terminal. labels Aug 31, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Aug 31, 2021
@zadjii-msft zadjii-msft added Needs-Tag-Fix Doesn't match tag requirements and removed Issue-Feature Complex enough to require an in depth planning process and actual budgeted, scheduled work. labels Aug 31, 2021
@ghost ghost removed the Needs-Tag-Fix Doesn't match tag requirements label Aug 31, 2021
@zadjii-msft zadjii-msft added this to the Terminal Backlog milestone Aug 31, 2021
@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 Oct 15, 2021
@LoneDev6

This comment was marked as off-topic.

@DHowett

This comment was marked as off-topic.

@zadjii-msft
Copy link
Member

And just #603, #11180 in general

@zadjii-msft
Copy link
Member

For testing purposes:

settings:

            {
                "commandline": "cmd.exe",
                "hidden": false,
                "name": "unfocused acrylic, 20%",
                "useAcrylic": true,
                "opacity": 20,
                "colorScheme": "Campbell",
                "background": "#00ff00",
                "unfocusedAppearance":
                {
                    "background": "#0000ff"
                }
            },
            {
                "commandline": "cmd.exe",
                "hidden": false,
                "name": "focused only acrylic, 20%",
                "useAcrylic": true,
                "opacity": 20,
                "colorScheme": "Campbell",
                "background": "#00ff00",
                "unfocusedAppearance":
                {
                    "background": "#0000ff",
                    "useAcrylic": false,
                }
            },
            {
                "commandline": "cmd.exe",
                "hidden": false,
                "name": "focused only 100%",
                "useAcrylic": true,
                "opacity": 20,
                "colorScheme": "Campbell",
                "background": "#00ff00",
                "unfocusedAppearance":
                {
                    "background": "#0000ff",
                    "opacity": 100,
                }
            }

State:

				{
					"action" : "newTab",
					"commandline" : "cmd.exe",
					"profile" : "unfocused acrylic",
					"startingDirectory" : null,
					"suppressApplicationTitle" : false,
					"tabTitle" : "unfocused acrylic"
				},
				{
					"action" : "splitPane",
					"commandline" : "cmd.exe",
					"profile" : "focused acrylic",
					"size" : 0.5,
					"split" : "right",
					"splitMode" : "manual",
					"startingDirectory" : null,
					"suppressApplicationTitle" : false,
					"tabTitle" : "focused acrylic"
				},
				{
					"action" : "splitPane",
					"commandline" : "cmd.exe",
					"profile" : "focused only 100%",
					"size" : 0.5,
					"split" : "down",
					"splitMode" : "manual",
					"startingDirectory" : null,
					"suppressApplicationTitle" : false,
					"tabTitle" : "focused only 100%"
				},
				{
					"action" : "focusPane",
					"id" : 0
				}

@zadjii-msft zadjii-msft changed the title Add support for Acrylic settings in "Unfocused Settings" Add support for Acrylic and Opacity in "Unfocused Appearance" Feb 14, 2022
@zadjii-msft zadjii-msft modified the milestones: Backlog, 22H1 Feb 14, 2022
zadjii-msft added a commit that referenced this issue Feb 14, 2022
This doesn't work, but is a good start for moving the settings around. The parent commit, 26a8447, does the real hard work. The trick is now figuing out how things like focused/unfocused acrylic works. Like, does "toggle acrylic" only affect the focused appearance? both appearances? That's a good question!

That's actually a good question for schemes too. That only applies to focused appearance, so that makes sense that acrylic would be the same.
@zadjii-msft zadjii-msft modified the milestones: 22H1, Terminal v1.15 Mar 23, 2022
@zadjii-msft zadjii-msft removed this from the Terminal v1.15 milestone Jun 6, 2022
@plastikfan
Copy link

plastikfan commented Nov 1, 2022

Yeah, I much agree with this issue. I love the transparency functionality, but seems to have been implemented the wrong way around. When the window loses focus, then I would expect transparency to become effective, becoming opaque when the window gains focus so you can see text more clearly. And perhaps we could define different opacity levels depending on focus state; so typically one would set a higher opacity level when the window gains focus.

@microsoft microsoft deleted a comment from ZeChArtiahSaher Apr 1, 2023
@zadjii-msft
Copy link
Member

zadjii-msft commented Apr 27, 2023

Note

Walkthrough

x-linking #7158 (comment). That comment basically describes how to do both of these

@Jaswir
Copy link
Contributor

Jaswir commented May 22, 2023

This is also not working for normal transparency (not acrylic)
Focussed-Unfocussed-Opacity-NotAcrylic

image

@Jaswir Jaswir mentioned this issue Sep 2, 2023
4 tasks
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>
@Jaswir
Copy link
Contributor

Jaswir commented Sep 13, 2023

A hero has arrived 😎
image

For:
image

@Jaswir
Copy link
Contributor

Jaswir commented Sep 13, 2023

Will keep you up to date with the progress!

@radonn24
Copy link

Yes!

🥳

@Jaswir
Copy link
Contributor

Jaswir commented Sep 16, 2023

Unfocused window more transparent than focused window:
unfocused_opacity

Code is buggy though, working through some bugs.

@Jaswir
Copy link
Contributor

Jaswir commented Sep 16, 2023

@jolsen71

I'd really like to make my unfocused windows to have transparency instead of opaque. Ideally, I could make my unfocused windows more transparent than my focused window.

I think this one about covers it:
jolsen

image

@microsoft-github-policy-service microsoft-github-policy-service bot added the In-PR This issue has a related PR label Sep 16, 2023
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)
@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Tag-Fix Doesn't match tag requirements label Oct 13, 2023
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
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: Done
Development

Successfully merging a pull request may close this issue.

7 participants