microsoft / terminal

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

Add a key binding to set or toggle acrylic #2531

Open moonunit9 opened 4 years ago

moonunit9 commented 4 years ago

Ability to quickly toggle opacity on/off through keystrokes. It would switch between 100% and custom setting in properties.

Jaswir commented 11 months ago

@zadjii-msft

Hey Mike! Look what I got! Did some plumbing and this is what I got so far: plumbing_global_done_maybe_share_92

However I am kinda confused, probably missing something. image

I don't know what moving the acrylic from CONTROL_SETTINGSto CONTROL_APPEARANCE_SETTINGS is for. And also yeah moving it in profile settings.

What is it for?

Also this one: image

I don't get, what global setting are you talking about? Is CONTROL_APPEARANCE_SETTINGS Global variant of CONTROL SETTINGS? Are you talking about using the enableUnfocusedAcryl there? I currently added _EnableUnfocusedAcrylic = globalSettings.EnableUnfocusedAcrylic(); to _ApplyGlobalSettings with the other global settings

zadjii-msft commented 11 months ago

Sorry for any confusion! This is probably a side-effect of #11092 and #7158 evolving organically in parallel, instead of me consolidating everything into one thread.

I don't know what moving the acrylic from CONTROL_SETTINGSto CONTROL_APPEARANCE_SETTINGS is for. And also yeah moving it in profile settings

Ah, that is ultimately the crux of the feature here! The TermControl can have different sets of "appearance" settings, based on if the control is focused or not. Acrylic was never a part of the "appearance" settings before, because it couldn't be applied when unfocused. Now it can! So it should get moved there. I think opacity looks like it is, at least in IControlAppearance.

I think these docs might make more sense.

So basically, there's one new setting, and one moved setting:

Jaswir commented 11 months ago

@zadjii-msft

Ah I think I get it, in order to use acrylic in unfocused appearance settings , useAcrylic needs to be moved to CONTROL_APPEARANCE_SETTINGS.

That's what you mean right?

Also last time I checked Opacity was also missing from Unfocused Appearance, see: https://github.com/microsoft/terminal/issues/11092#issuecomment-1557024462

Btw how do you want me to deliver these PR's to you? Since there are 2 issues 7158 and 11092

I figure 11092 is basically about https://github.com/microsoft/terminal/issues/11092#issuecomment-1557024462 enabling opacity as both an appearance setting, allowing it to be set differently in both focused and unfocused terminals.

And 7158 global useAcrylic, and allowing it to be set differently in both focused and unfocused terminals?

Or 7158 could be just the global useAcrylic boolean. And 11092 about , allowing Acrylic and Opacity be set differently in both focused and unfocused terminals. At least that's how I interpreted 11092.

Jaswir commented 11 months ago

@zadjii-msft

I don't know where the RetroTerminalEffect is changed when the terminal becomes unfocused or focused help. I looked at ProfileViewModel, but breakpoints couldn't be triggered there or something?

image

And ControlCore.cpp -> ColorScheme breakpoint doesn't get hit which I expected it would activate when focus changed

TermControl::_LostFocusHandler is the closest thing I found

I've set up UseAcrylic2 with ControlAppearances.idl, CONTROL_APPEARANCE_SETTINGS and ControlCore and basically got that part of the application working with UseAcrylic2, I demolished ControlCore., ControlProps, ControlSettings.Idl, TerminalSettings.h that part out which useUseAcrylic and that part seems to be working now of the App with the UseAcrylic2 pipes in plumbing terms (UseAcrylic2 is connected to "useAcrylic" json key) . Only have to get the ProfileViewModel Part working which I believe is basically this: image part I think.

and that'll be the plumbing done I think

When demolishing ProfileViewModel things I bump to some issues that I am working on. I'll ask question if I get stuck.

zadjii-msft commented 11 months ago

Alrighty so a lot of points here, I'll surely miss something:

Okay this might not be an easy starter issue at all. Now we've got this awkward interaction between the runtime changing of opacity, and whether or not the focused or unfocused appearance is applied. RUNTIME_SETTING doesn't really work with that idea so well.

We probably need to also make changes so that:

Or maybe it could be changed to

RUNTIME_SETTING(double, FocusedOpacity, FocusedAppearance().Opacity());
RUNTIME_SETTING(double, UnfocusedOpacity, UnfocusedAppearance().Opacity());

and then choose the right value accordingly in TermControl::_InitializeBackgroundBrush.

Jaswir commented 11 months ago

@zadjii-msft

Just wanted to mention before I go to sleep late, that the plumbing is going well! have to make some switches and it should be good.

Jaswir commented 11 months ago

@zadjii-msft

Okay this might not be an easy starter issue at all

I like a challenge ๐Ÿ˜

Jaswir commented 11 months ago

@zadjii-msft

I think I might be missing something in the plumbing. So I am switching UseAcrylic2 that is configured to work as ControlAppearance to UseAcrylic. And there's 1 file that I am adding something manually to, which makes it work, but I am not sure this is how it's supposed to be done. Maybe I am missing some .idl here. I gotIControlAppearance.idl and IAppearanceConfig.idl

The file in question is ControlSettings.h

I am talking about manually adding this piece of code to: CONTROL_APPEARANCE_SETTINGS(APPEARANCE_GEN)

       bool UseAcrylic() const noexcept
        {
            return _focusedAppearance->UseAcrylic();
        }
        void UseAcrylic(const bool& value) noexcept
        {
            _focusedAppearance->UseAcrylic(value);
        }

Is it supposed to be added in manually like this or am I missing something? I am coding quite a lot on my intuition.

I'd suspect that the CONTROL_APPEARANCE_SETTINGS(X) insideControlProperties.h would impact ControlSettings.h somehow since the Macro says:

CONTROL_APPEARANCE_SETTINGS(APPEARANCE_GEN)

and

#define APPEARANCE_GEN(type, name, ...)    \
    type name() const noexcept             \
    {                                      \
        return _focusedAppearance->name(); \
    }                                      \
    void name(const type& value) noexcept  \
    {                                      \
        _focusedAppearance->name(value);   \
    }

So it would automatically add it inside ControlSettings.h, once added to the macro in ControlProperties.h . But when I remove it from ControlSeting.h, clean and rebuild it doesn't reappear in ControlSettings.h

zadjii-msft commented 11 months ago

FWIW I don't think you need to touch ControlSettings.h. That file is full of macros that automatically build up the ControlSettings class at compile time based on the contents of ControlProperties.h. Just sticking the property into CONTROL_APPEARANCE_SETTINGS and IControlAppearance.idl should be enough for it to populate into the _focusedAppearance/_unfocusedAppearance objects

Jaswir commented 11 months ago

FWIW I don't think you need to touch ControlSettings.h. That file is full of macros that automatically build up the ControlSettings class at compile time based on the contents of ControlProperties.h. Just sticking the property into CONTROL_APPEARANCE_SETTINGS and IControlAppearance.idl should be enough for it to populate into the _focusedAppearance/_unfocusedAppearance objects

I don't know why it isn't working, help. When you add something new to CONTROL_APPEARANCE_SETTINGS in ControlProperties.h and IControlAppearance.idl , does something automatically appear in the ControlSettings.h for you? It doesn't for me.

zadjii-msft commented 11 months ago

does something automatically appear in the ControlSettings.h for you

Nope. That file is all just C macros. Nothing about that file changes, but when the compiler actually evaluates that file, it's gonna macro expand everything in there, combined with the macros in ControlProperties.h, to generate definitions for everything automatically.

It's a pretty heavy use of X macros, which are some crazy C concept that I only learned about a few years ago. It's great for boilerplate code like this.

Jaswir commented 11 months ago

@zadjii-msft

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

Not sure what the difference is between Macro's and XMacros but , I think Macros are pretty cool, have only seen it in c++ so far, which surprises me its really awesome for lazy people like me. I think I solved the Controlsettings.h issue, I had to manually rewrite the macro as CONTROL_APPEARANCE_SETTINGS(APPEARANCE_GEN) and then it worked probably at some point I opened it (expanded inline to see what is inside it) edited something and then saved and commited that and forgot and the compiler thing wouldn't happen anymore.

Jaswir commented 11 months ago
  • Ultimately, the most interesting one is TermControl::_InitializeBackgroundBrush, which sets up the background brush (which is what we care about here).

_Initialize only get's called upon initialization, but we want to fire some function everytime the focus state is changed. See gif, everytime I click on the folder and back to terminal: run_code_focus_switch

And update the acrylic and opacity everytime it's changed. I thought if I find the place where RetroTerminalEffect gets updated I can just add that code for acrylic and opacity to that location. But couldn't find it. Is that somewhere deep inside _UpdateAppearanceFromUIThread?

Feel confident about implementing the other thing you mentioned with

RUNTIME_SETTING(double, FocusedOpacity, FocusedAppearance().Opacity());
RUNTIME_SETTING(double, UnfocusedOpacity, UnfocusedAppearance().Opacity());

After plumbing ControlCore

I guess I can get just get the code working at some inappropriate place for now

Jaswir commented 11 months ago
  • I think the appearance settings get re-applied in TermControl::UpdateAppearance (which calls through to _ApplyUISettings). Ultimately, the most interesting one is TermControl::_InitializeBackgroundBrush, which sets up the background brush (which is what we care about here).

I checked it. And the TermControl::UpdateAppearance gets fired continuously it seems, but it doesn't call through to _ApplyUISettings

Jaswir commented 11 months ago

The Toggle Acrylic function from 2531 would probably be useful here aswell

Jaswir commented 11 months ago

Played around a bit:

Acrylic unfocused more transparent:

unfocused_more_transparent

Opacity unfocused more transparent (my current favorite) opacity_jaswir_style

Cool stuff (you know this one might become my favorite actually) cool_stuff

D: Why the hell not. Fully transparent when focused, "fully transparent acrylic" when unfocused. D_mike_whythehellnot

@zadjii-msft I could post this in the future in 7158 and then include A,B,C,D that would complement your permutation comment nicely could be a good teamwork move. Let me know, what do you think about that?

The code is really ugly though ;)

Jaswir commented 10 months ago

@zadjii-msft

Questions:

  1. I could post some gifs fitting your A,B,C,D example that would complement your permutation comment nicely could be a good teamwork move. Let me know, what do you think about that?

  2. So what's the idea about the PR's for 7158 and 11092? I am getting close to PR's it's big and complicated, splitting it up makes things easier for me and for you as well.

I understand 11092 will be: image

Just Opacity right?

And then 7158 about enabling Acrylic as both an appearance setting (with all the plumbing), allowing it to be set differently in both focused and unfocused terminals plus the EnableUnfocusedAcrylic Global Setting right?

  1. What are ๐Ÿ‘ถ OOF Fridays? Does it mean you are free fridays now because off the baby and stuff? Or Only on Friday, you only work on fridays now??
zadjii-msft commented 10 months ago
  1. Great, go for it (as you already did ๐Ÿ˜). It's your contribution, feel free to demo it however you feel is good.
  2. Meh, if it's easier, just do it all as one PR. It can't be as big as the last three PRs I've reviewed ๐Ÿ˜… If it's easier to break it up, then do it that way. I don't really mind one way or the other.
  3. "OOF" is apparently a Microsoft-ism that means "out of office"[^1]. Basically, I'm still taking a bunch of Fridays off to burn my last paternity leave days (rather than just take the last two weeks in a single chunk). A little easier for my family this way ๐Ÿ˜„

[^1]: and I was today years old when I realized that OOF is not the abbreviation of "Out Of Office". I've literally never thought of it for the last 8 years I've been here.

Jaswir commented 10 months ago

@zadjii-msft

Questions:

  1. Made A PR for 7158, spend some extra time on writing the description of the PR, making the description quite extensive. I heard somewhere good Engineers spend more time on submitting code for review resulting in less iterations of reviewing and improving the code.

image https://www.youtube.com/watch?v=ZaZj7XJMJv0

Could you provide me feedback please if you think this added value to my PR in your opinion? Would like to improve become a Great Engineer. Thanks in advance.

  1. Opacity defaults to 50 when UseAcrylic is true??? image It doesn't seem to default to 50 to me? image
Jaswir commented 10 months ago

@zadjii-msft I notice that acrylic.BackgroundSource(Media::AcrylicBackgroundSource::Backdrop); is different from acrylic.BackgroundSource(Media::AcrylicBackgroundSource::HostBackdrop);

Not sure if it's a problem, seems to be the default behaviour of Backdrop, there's a see through at the edge where it's somewhat transparent instead of acrylic. image

and it seems a nit bit less bright, can you spot it? Both are at 0 Opacity btw image

image

zadjii-msft commented 10 months ago

Oh, I'm sure that's fine. In-app acrylic (Backdrop) was never really meant to be used with a transparent window background. That's a happy side effect of us being able to drop out our window background (which most UWPs can't). We're firmly in unexplored territory of the app platform ๐Ÿ˜„

Jaswir commented 10 months ago

@zadjii-msft I don't know how I can check whether the command palette is open? Help

I want to _setOpacity(newAppearance->Opacity()); in ControlCore::ApplyAppearance so the opacity changes according to unfocused opacity and focused opacity.

But as you can see below the windows becomes unfocused when opening the command palette and focused when closing it so then the adjust opacity's _setOpacity gets overridden by the one in ControlCore::ApplyAppearance

check_command_pallette

zadjii-msft commented 10 months ago

Hmm that's got shades of #11571 in it, though we went through a pretty major settings re-write after that... Don't think I'll have time to dig in this week before I leave, and I'll be ignoring mail all week next week.

I'd say file a follow-up that we can get to now that we're merging #15923

Jaswir commented 10 months ago

@zadjii-msft

Hey Mike, I've been contributing here for a while now.

How do you think I am doing? Do you maybe have general feedback, anything I can improve on?

Let me know when you're back.

Jaswir commented 10 months ago

@ianjoneill Awesome that you completed this: https://github.com/microsoft/terminal/pull/14999 I remember you helping me out here when I just started: https://github.com/microsoft/terminal/issues/15127

Thanks again!

Carrying on your legacy now xD image

Hope you're well.

Jaswir commented 10 months ago

@DHowett @DHowett-MSFT

I'd say file a follow-up that we can get to now that we're merging https://github.com/microsoft/terminal/pull/15923

What does Mike mean with this? Is he suggesting to make a PR for 11092 for the team to look at?

Jaswir commented 9 months ago

@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: I've been contributing here for a while now.

How do you think I am doing? Do you maybe have general feedback, anything I can improve on?

Jaswir commented 9 months ago

@zadjii-msft

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.

Has there been other contributors that youโ€™ve given referrals for Microsoft Applications? What are you guys like? Do you give referrals to contributors?

Jaswir commented 9 months ago

@zadjii-msft

Hi Mike,

How are you? Haven't heard from you in a while. I am worried.

I hope you'll respond. Thanks,

Have a good weekend!

Jaswir commented 9 months ago

@zadjii-msft

Hey Mike,

Some Questions.

There are a couple problems I find interesting to work towards:

  1. https://github.com/microsoft/terminal/issues/3158 Can you point me to some like easy issue to get familiar with CWD, manipulating it and stuff?

  2. https://github.com/microsoft/terminal/issues/2664 https://github.com/microsoft/terminal/issues/190

    I have a feeling that both of these have to do with DX engine and Atlas Engine (since they are both kinda fonts) Is that right?

  3. https://github.com/microsoft/terminal/issues/2664

    Can you point me to some easy issues to get familiar with DX Engine, Atlas Engine?

Ugh, I tagged the issues again ...

zadjii-msft commented 9 months ago

First off, lemme level with you: Those are truly some of the gnarliest issues on our repo. There's a reason they're still open despite the number of upvotes on them.

Ugh, I tagged the issues again

Meh, don't worry about it. Folks don't get emails when threads are linked, so no one usually notices or cares.

Jaswir commented 8 months ago

@zadjii-msft

I am considering the next steps in my career, I am looking into startups (at my current job I do Web Dev). I could either go in the direction of AI / C++ or Mobile Development or both? But the jobs I've been looking at seem to be either AI/C++ or Embedded System/C++ sometimes combined with Javascript for Web Dev of the company or Only Mobile Dev with React Native but no C++.

I am worried to go in the direction of C++/AI. It seems to me like a small fraction of jobs involve C++ development. Most involve mobile development since the market for it is bigger, around 80% of internet traffic is from Mobile. That being said right now we have entered the Era of AI and so maybe the future market is AI and C++?

I want experience that allows to apply to a wide range of jobs and don't want to get stuck in a box where I can't transition easily anymore. I've been in that before with Game Dev where I pretty much dug my own grave well at least the more I did it the more I felt like I couldn't get out of it anymore since I knew so much about it. I don't know if that makes sense. If I do Mobile Dev with e.g. react native it seems like there will be tons of companies to go to so I can be flexible and don't have to worry about getting stuck at a company since there are so many other companies I could go to if things don't work out or something.

But seriously though - I've been working through re-writes of the Console codebase for 8 years now. I helped design the architecture of the Terminal codebase itself. That's been my 9-5 for years, at this point, it's just instinct.

As someone that has been doing C++ development for the past 8 years of their live. How valuable is C++ development in the long run? It seems to me it's mostly build for programming machines, so embedded systems and with AI for programming the GPU with Cuda or Compiler engineering, to increase AI performance. Which to me seems like a small fraction of the job market. Maybe in the future it will boom with AI though.

Do you feel like you are kinda stuck in terms of jobs? Like you dug your own grave? Like can't translate easily to other companies because you don't have xp with web or mobile development. For example one thing I always wondered about like this is like desktop development, but some people build backend with C++. I don't know if you've done web development before with c++? But do you think your C++ knowledge would be valuable to a company that uses C++ primarily for backend development?

From my perspective I can't see that, since I am not that good at C++ when applying before I'd apply to C# jobs for backend with desktop development experience in C# only. And I couldn't see it either what the value was of that for backend C# cause I wasn't that good at C#. But I think you might see it?

Also do you think in the future C++ will take a bigger share of the market cause of AI and become the new Mobile Dev hype? So like majority of jobs will ask for C++?

Also what do you think knowledge of C++ is worth? How valuable do you think it is?

zadjii-msft commented 8 months ago

Alright I probably don't have enough time to share everything I'd like to, but I'll try to add some quick notes:

Honestly, C# probably strikes good balance place - widespread enough that there are tons of careers. Close enough to Java/whatever's going on at Apple these days that moving to those would be easy. TS is pretty similar too, so again, not the most painful move. And of course, transitioning down to C++ wouldn't be the end of the world from C++.

[^1]: that's a lie, JS is an abomination. TS is nice though

Jaswir commented 8 months ago

@zadjii-msft

Made a sideproject you might like, that being said I kinda assume you know every cmd command and powershell command by head now, well at least the ones that are most used and rarely lookup commands anymore. Maybe it's more for different audience. Anyway thought I'd share it with you as well.

Made an AI Powershell Plugin - Which-Command GPT. Reduce time looking for commands, increase performance at work. Which command to use in Terminal for Windows? - Which-Command GPT - AI PowerShell Plugin - Answers that for you.

which-command_gif

Features:

:point_right: Answers which command to use :point_right: Copy and paste the command directly in your terminal

Try it out yourself: https://jaswirraghoe.blogspot.com/2023/10/which-command-gpt.html

Jaswir commented 8 months ago

@zadjii-msft

There's nothing I like writing less than C++ Wait I understand you don't like writing C++ and would much rather write something else? Do you feel like you are kinda stuck ? Like you dug your own grave? Like can't translate easily to other companies / roles, like you have to do C++/Rust now forever?

Jaswir commented 8 months ago

@zadjii-msft

What function tells me whether the command palette is currently open? command_palette_open

When the palette is open window becomes unfocused. It shouldn't image

zadjii-msft commented 8 months ago

Wait I understand you don't like writing C++ and would much rather write something else?

Absolutely. Working in C++ is just a pain compared to literally any modern programming language. Compiler messages are terrible, tooling is terrible, stl is bizarre at times, package management is nonexistent. Just a dumpster fire. Fast though, lots of examples, and used ubiquitously in the OS.

Do you feel like you are kinda stuck

Not even remotely. I'm confident that I'm a good engineer with solid fundamentals, good communication skills[^1], and fairly good at reasoning about complicated dependencies. All that'll translate to any other project or language.

What function tells me whether the command pallette is currently open

TerminalPage::_commandPaletteIs(Visibility::Visible) should do the trick

[^1]: for an engineer

Jaswir commented 8 months ago

@zadjii-msft

Nvm don't need to do that, there's a much easier hack that'll do the trick

that's a lie, JS is an abomination. TS is nice though . Honestly, C# probably strikes good balance place

You're such a Microsoft Employee xD! Are you allowed to use a different browser than Microsoft Edge?

Jaswir commented 7 months ago

@zadjii-msft

Am very much into AI these days, hence my absence. Thought I'd let you know. Hope you're well.

Jaswir commented 7 months ago

@zadjii-msft Are there AI Opensource project at Microsoft you recommend?

zadjii-msft commented 7 months ago

Are there AI Opensource project at Microsoft you recommend?

Honestly, not a lot that I intimately know of. I've been pretty checked out of the LLM work for the last couple months. Terminal Chat is an LLM-backed feature, but that's more of a frontend application built on top of existing models. It's not really about building or training models itself.