-
Couldn't load subscription status.
- Fork 8.9k
Add Mica Alt support to Microsoft Terminal (#17650) #19246
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,9 +6,14 @@ | |
| #include "../types/inc/Viewport.hpp" | ||
| #include "resource.h" | ||
| #include "icon.h" | ||
| #include <dwmapi.h> | ||
| #include <TerminalThemeHelpers.h> | ||
| #include <CoreWindow.h> | ||
| #include <dwmapi.h> | ||
| #include <TerminalThemeHelpers.h> | ||
| #include <CoreWindow.h> | ||
|
|
||
| // Define DWMSBT_TRANSIENTWINDOW if not available (for Mica Alt) | ||
| #ifndef DWMSBT_TRANSIENTWINDOW | ||
Check failureCode scanning / check-spelling Unrecognized Spelling Error
TRANSIENTWINDOW is not a recognized word. (unrecognized-spelling)
|
||
| #define DWMSBT_TRANSIENTWINDOW 3 | ||
Check failureCode scanning / check-spelling Unrecognized Spelling Error
TRANSIENTWINDOW is not a recognized word. (unrecognized-spelling)
|
||
| #endif | ||
|
|
||
| extern "C" IMAGE_DOS_HEADER __ImageBase; | ||
|
|
||
|
|
@@ -1839,17 +1844,31 @@ | |
| std::ignore = DwmSetWindowAttribute(GetHandle(), DWMWA_USE_IMMERSIVE_DARK_MODE, &attribute, sizeof(attribute)); | ||
| } | ||
|
|
||
| void IslandWindow::UseMica(const bool newValue, const double /*titlebarOpacity*/) | ||
| { | ||
| // This block of code enables Mica for our window. By all accounts, this | ||
| // version of the code will only work on Windows 11, SV2. There's a slightly | ||
| // different API surface for enabling Mica on Windows 11 22000.0. | ||
| // | ||
| // This API was only publicly supported as of Windows 11 SV2, 22621. Before | ||
| // that version, this API will just return an error and do nothing silently. | ||
|
|
||
| const int attribute = newValue ? DWMSBT_MAINWINDOW : DWMSBT_NONE; | ||
| std::ignore = DwmSetWindowAttribute(GetHandle(), DWMWA_SYSTEMBACKDROP_TYPE, &attribute, sizeof(attribute)); | ||
| void IslandWindow::UseMica(const winrt::Microsoft::Terminal::Settings::Model::MicaKind micaKind, const double /*titlebarOpacity*/) | ||
| { | ||
| // This block of code enables Mica for our window. By all accounts, this | ||
| // version of the code will only work on Windows 11, SV2. There's a slightly | ||
| // different API surface for enabling Mica on Windows 11 22000.0. | ||
| // | ||
| // This API was only publicly supported as of Windows 11 SV2, 22621. Before | ||
| // that version, this API will just return an error and do nothing silently. | ||
|
|
||
| int attribute = DWMSBT_NONE; // Default to no backdrop | ||
| switch (micaKind) | ||
| { | ||
| case winrt::Microsoft::Terminal::Settings::Model::MicaKind::None: | ||
| attribute = DWMSBT_NONE; | ||
| break; | ||
| case winrt::Microsoft::Terminal::Settings::Model::MicaKind::Mica: | ||
| attribute = DWMSBT_MAINWINDOW; | ||
| break; | ||
| case winrt::Microsoft::Terminal::Settings::Model::MicaKind::MicaAlt: | ||
| // DWMSBT_TRANSIENTWINDOW is the constant for Mica Alt | ||
Check failureCode scanning / check-spelling Unrecognized Spelling Error
TRANSIENTWINDOW is not a recognized word. (unrecognized-spelling)
|
||
| attribute = DWMSBT_TRANSIENTWINDOW; | ||
Check failureCode scanning / check-spelling Unrecognized Spelling Error
TRANSIENTWINDOW is not a recognized word. (unrecognized-spelling)
|
||
| break; | ||
| } | ||
|
|
||
| std::ignore = DwmSetWindowAttribute(GetHandle(), DWMWA_SYSTEMBACKDROP_TYPE, &attribute, sizeof(attribute)); | ||
| } | ||
|
|
||
| // Method Description: | ||
|
|
||
Check failure
Code scanning / check-spelling
Unrecognized Spelling Error