microsoft / terminal

The new Windows Terminal and the original Windows console host, all in the same place!
MIT License
95.67k stars 8.33k forks source link

Investigate: AcrylicBlur always on in an inactive window #7158

Closed harounhajem closed 1 year ago

harounhajem commented 4 years ago

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.

zadjii-msft commented 4 years ago

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.

electronic-dk commented 4 years ago

@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 commented 4 years ago

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 commented 4 years ago

@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.

zadjii-msft commented 4 years ago

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.

0x7c13 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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.

SinanAkkoyun commented 4 years ago

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

harounhajem commented 4 years ago

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 commented 4 years ago

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

zadjii-msft commented 4 years ago

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.

SinanAkkoyun commented 4 years ago

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.

Thank you, I will see if I can make a small difference

harounhajem commented 4 years ago

@zadjii-msft Is it possible to get some guidance on where to make the changes to prohibit solid background on lost focus, as well where to read the settings values. Saw that the repo was written in C++, thought the application was an UWP and written in C#, which would have been much easier for me to start with.

zadjii-msft commented 4 years ago

If you'd like to do this, you'll need to copy the HostBackdropAcrylicBrush from here, put port the code to C++/WinRT. If you can egt the brush working as a replacement to the standard AcrylicBrush, then I can help figure out the setting later 😝

The Terminal is a C++/WinRT application, which means many of the same APIs that are available to UWP apps are availabie to use in C++, just via their C++ projection instead of the C# one.

The Terminal isn't really a "UWP" app - it uses "UWP XAML" for its UI, but typically UWP also implies some other restrictions like needing to run in an app container. The Terminal is one of a new breed of hybrid Win32/UWP applications that get to use the best of both worlds.

Also FYI UWP applications don't need to be written in C# - you could have a pure UWP app built with C++ if you wanted πŸ˜‰

driver1998 commented 4 years ago

huh, so this is actually possible on UWP? I always think this "always on faky acrylic" is only possible on desktop apps (with a bunch of undocumented DWM APIs).

zadjii-msft commented 4 years ago

I'm not sure if that's possible for a pure UWP app, but the Terminal is fortunately a desktop application, so we don't need to worry about that πŸ˜‰ Plus, the compositor APIs are pretty well documented, so it's not like Notepads is doing anything that's a particularly bad hack.

WVVxm commented 4 years ago

Interesting. I found acrylic working when terminal is inactive on remote desktop. https://webmshare.com/wZ6OJ t1 t2

reinux commented 3 years ago

Could it just paint part of the desktop wallpaper with a glass effect instead of actually using Acrylic? Or maybe have that as an option?

Some old Linux terminals in the early 2000s did a thing where it would just paint the desktop wallpaper image at reduced contrast, and it would move the source rect based on where the window was relative to the wallpaper.

This has a few advantages:

I made a mockup a couple years ago in WPF:

ezgif-7-ad2b25eee91b

I think in a real Windows app, in order for there not to be juddering, it would need to either be able to redraw as soon as the window moves (I never figured out how to do this), or just not update the background for half a second or so after the window stops moving.

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.

Even back on Vista hardware back in 2007, when there were a ton of false rumors about its resource consumption, Aero Glass being a culprit for battery consumption was ruled out by anyone who tested the theory both in benchmarks and in practical use. It was reducing battery life by less than 1%. The only modern computer I can think of that wouldn't have a GPU that could handle glass in under 0.1% of its energy consumption is a Raspberry Pi.

Chaphasilor commented 3 years ago

Just a quick thought: https://github.com/microsoft/terminal/pull/8392 introduced style settings for when the terminal is unfocused. This (probably) means that, once this feature is implemented/ported, the Enable Acrylic setting could just be duplicated to give the user more control how they want the effect to behave.
For example, I'd actually like the effect to only show when the window in unfocused, so that it "blends in" with the background.

Making use of the linked PR would enable this right away, basically without any additional overhead :)

pcone commented 3 years ago

Just chiming in with a use case beyond "it looks pretty" because I don't think it's been mentioned yet - this would be super useful combined with the 'Always on top' appearance setting to let me keep a terminal window visible without it obscuring other stuff on the same monitor. I often want to keep an eye on something running in terminal like a build while not really interacting with it much.

Ideally there would be a separate opacity setting for focused and unfocused.

Spydernaz commented 3 years ago

Hey all, is anyone currently working on this? This is something I would really love and am willing to have a go at implementing it.

zadjii-msft commented 3 years ago

No one's working on this currently, so go right ahead! You might want to take a look at

https://github.com/JasonStein/Notepads/blob/8ea2c902c1b1a35deb913503559c40e18708c9e5/src/Notepads/Brushes/HostBackdropAcrylicBrush.cs

as a starting place. That's C#, but it'll be a fairly good reference for what needs to be done here. I'd also recommend maybe branching off of #11180, since that slightly re-works how opacity works in the Terminal

Spydernaz commented 3 years ago

@zadjii-msft, thanks for the pointers πŸ˜„ will take a look at these for some guidance. Also, it seems like the branch/PR you commented isn't passing though. Also; side note, I was building the dev branch to make sure I can but it runs super slow, is there any tricks to make the build quicker (like a --skipTests or smth in C++)

zadjii-msft commented 3 years ago

Also, it seems like the branch/PR you commented isn't passing though.

Meh yea, I forgot to build some of the test code. Don't worry too much about those ones not building, I'll go sort those out now.

Also; side note, I was building the dev branch to make sure I can but it runs super slow, is there any tricks to make the build quicker (like a --skipTests or smth in C++)

Yea, that's kinda been a crusade I've been pushing for a while. C++/WinRT code can be a real pain to build, especially the first time when it's compiling the pch.h's. My trick is only ever deploying CascadiaPackage: image

That'll skip all the test projects, and just build the Terminal. That's usually good enough for my inner loop. I had a more complicated setup too where I'd only ever build individual dll's, and then patch them into the package directory, but that's more fraught with footguns so I'll not go into details on that πŸ˜›

Spydernaz commented 3 years ago

Awesome! Thanks for the help / advice, I will have a look at pulling the branch and building it.

Yea, that's kinda been a crusade I've been pushing for a while. C++/WinRT code can be a real pain to build, especially the first time when it's compiling the pch.h's. My trick is only ever deploying CascadiaPackage:

Thanks, I'll give this a try and hope it builds quicker :)

I had a more complicated setup too where I'd only ever build individual dll's, and then patch them into the package directory, but that's more fraught with footguns so I'll not go into details on that πŸ˜›

As a newbie I will skip your perilous setup πŸ˜†

JoshuaRifareal commented 3 years ago

any updates on this?

zadjii-msft commented 3 years ago

Nope. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button? image That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️

furby-tm commented 2 years ago

Weirdly here on Windows 11 build 22509.1011, acrylic stopped working entirely both on the stable and preview releases -- so I initially went to fix that, and then additionally was able to fix the acrylic on focused and non-focused states.

Not the cleanest, at all!! But I patched this issue: https://github.com/Wabi-Studios/Windows-Always-Blurred-Terminal

Can clean it way up for an actual PR if you guys are interested. Was messing with a bunch of things when I was in there, haha.

I can provide a build when I get the chance to fix the deployment on azure.

zadjii-msft commented 2 years ago

@furby-tm Interesting. Looking through that diff is... challenging, since there's so many other random dependency updates and merges in it. But it looks like the substantial part of it boils down to

any idea why that fixes it? The BackdropMaterial.ApplyToRootOrPageBackground docs are... sparse... I was under the impression that was only supposed to work with Mica, but if that works with Acrylic too, that's a nifty discovery.

I'm a tad bit worried that the <Grid x:Name="Root" Background="{ThemeResource CustomAcrylicInAppLuminosity}"> bit is making it hard for the TermControls to be able to set their own individual colors/BG brushes, but that could probably get sorted out. I'm mostly just curious how this works. We'd obviously accept a (cleaned up 🀣) PR. This seems way simpler than the Notepads solution.

furby-tm commented 2 years ago

@zadjii-msft Oh my! Haha. You actually read through that terrible commit 🀣! I am terribly sorry -- Yes that about sums it up! And actually I don't believe applying the Mica material is of much use here, in terms of acrylic; and

Re: change any acrylic brushes we're using to BackgroundSource(AcrylicBackgroundSource::Backdrop) instead of AcrylicBackgroundSource::HostBackdrop

You are spot on with this, on top of this, I found many unnecessary bits on the usage of SolidBrush vs just using the AcrylicBrush -- especially as it pertains to the background's brush. And the only reason I implemented <Grid x:Name="Root" Background="{ThemeResource CustomAcrylicInAppLuminosity}"> was because on this Windows 11 build 22509.1011 , that acrylic is the only one working: image

As seen by the XAML Controls Gallery here ^ But that's a separate issue, haha.

But yes, I can definitely go back and make a commit less than 25 lines of code most likely.

WOW! I am so sorry you had to read through all of that 🀦

zadjii-msft commented 2 years ago

on this Windows 11 build 22509.1011 , that acrylic is the only one working

Oh jeez, you might be running into #11880, which is an OS level bug 😨

furby-tm commented 2 years ago

@zadjii-msft Yep! Haha I live and work out of my terminal and could not stand another second of opaqueness, so I needed to solve it ASAP. And while I was at it, it seemed simple enough to figure out a solution to the extremely annoying "unblur" when moving off focus, and it sure was!

So maybe thank goodness for the occasional OS level bug to start thinking outside the box a little bit πŸ˜‰

I do have a job, so you should see a polished PR by sometime late tonight - and as well as my temporary workaround to get acrylic working on build 22509.1011 if a OS patch isn't expected anytime soon.

7158 #11880

Who doesn't like killing two birds with one stone?


Quick update, been a busy week. But have not forgotten and am still planning on making a PR when I get some down time. @zadjii-msft just keep me posted if someone gets to fixing this before I get a chance to, much appreciated!

LuigiImVector commented 2 years ago

@furby-tm maybe you could join your solution with the "Unfocused Appearance" menu available in Terminal Preview (PR #10317) by also solving #11092

PabloRuizCuevas commented 2 years ago

@furby-tm Is your current version "always blurred terminal" good/stable enough for installing it instead of the original one? I can't stand much more time in opaqueness too, Thanks in advance!

furby-tm commented 2 years ago

Yes funny enough I actually have been using that build as my daily driver. And sorry guys! I've been super busy!! You guys still want that build? Cleaned up pr?

zadjii-msft commented 2 years ago

I would still love to see a (cleaned up πŸ˜‰) PR

PabloRuizCuevas commented 2 years ago

Sure! and thanks for your reply @furby-tm! It would be amazing to have this feature implemented! Count on me if you need some help testing, or something.

peos3 commented 2 years ago

@furby-tm Could you provide a working build? I cloned and built your repository, however, I was not able to reproduce the Acrylic Blur effect with an unfocused window. I tried it on Windows 10 (build 19043.1466) and with a recent Windows 11 installation. Do I have to pay attention to anything in particular? Interestingly, the whole thing works when I connect to the respective machine via RDP.

zadjii-msft commented 2 years ago

FWIW, when I looked through @furby-tm's fork, I didn't find anything that I would expect to actually fix this. I'm still under the impression that we'd need to roll our own fork of the acrylic brush, in the same way that Notepads does.

I have seen situations in debugging VMs where acrylic was always on (focused or not), but that seemed to be an artifact of the VM, and not something reproducible on a real machine. Perhaps that artifact is what made that fork seemingly work? Only way to know for sure is to get a PR going and test it put locally πŸ˜‰

zadjii-msft commented 2 years ago

Just some notes as we punt this one out:

If someone would like to help sort these things out all at once, we'd definitely appreciate the help.


Note

Walkthrough

I think that's it?

trry-hub commented 1 year ago

Is there a solution now?

fer1s commented 1 year ago

Some updates?

zadjii-msft commented 1 year ago

Nope, nothing to add. We'll make sure to update this thread when there is. In the meantime, might I recommend the Subscribe button? image That way you'll be notified of any updates to this thread, without needlessly pinging everyone on this thread ☺️

We basically just need someone to take the notes I outlined above, and just do it. There hasn't been any time for us on the team to do it in the last year. I could write up more specific notes if someone was really interested on doing this themselves. Though, I'd caution - it'll likely be 95% annoying plumbing work, and 5% "just switch the backdrop to in-app acrylic"

MrShortcut commented 1 year ago

I am also an advanced user and I agree with everyone here, you want to at least keep the behavior when unfocused keep the acrilyc effect at least

St3fanBC commented 1 year ago

+1 on the "I would really like this feature" and make it a per user setting please.

AbdullahAlmanei commented 1 year ago

Hey @zadjii-msft! I am really interested in giving this a shot. I would love some tips and notes, as I am not extremely familiar with the Terminal repository. I have read the notes you shared earlier, and I believe I have a good idea of how to start. However, I would appreciate notes on what to look out for as I start working on this. Thanks!

Jaswir commented 1 year ago

Having things in Gifs describing the issue helps me. Maybe it'll help get this solved faster:

Focussed-Unfocussed-Opacity

zadjii-msft commented 1 year ago

@AbdullahAlmanei Sorry, got bogged down with Build prep. Honestly, I think the notes just about cover it. The core implementation point of this (switching the AcrylicBrush in the TermControl from hostBackdrop to in-app acrylic) I think is a pretty straightforward change, it's just the plumbing of the settings that might be a bit tedious.

If I'm wrong though and you hit any snags, please feel free to ping me!

MrShortcut commented 1 year ago

@Jaswir The same behavior can be simulated if you make a cutout of the background when it is in acrylic, then in the active settings the background when the focus is not there, the only bad thing is that if you change the background of the desktop it will not have the same effect.