Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/inbox'
Browse files Browse the repository at this point in the history
  • Loading branch information
DHowett committed Jan 12, 2024
2 parents 057183b + f1ca156 commit a4445ed
Show file tree
Hide file tree
Showing 8 changed files with 31 additions and 41 deletions.
2 changes: 1 addition & 1 deletion src/host/exe/exemain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ int CALLBACK wWinMain(
{
// Only try to register as a handoff target if we are NOT a part of Windows.
#if TIL_FEATURE_RECEIVEINCOMINGHANDOFF_ENABLED
if (args.ShouldRunAsComServer() && Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy())
if (args.ShouldRunAsComServer())
{
try
{
Expand Down
4 changes: 2 additions & 2 deletions src/host/srvinit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ try

// Check if this conhost is allowed to delegate its activities to another.
// If so, look up the registered default console handler.
if (Globals.delegationPair.IsUndecided() && Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy())
if (Globals.delegationPair.IsUndecided())
{
Globals.delegationPair = DelegationConfig::s_GetDelegationPair();

Expand All @@ -82,7 +82,7 @@ try
// If we looked up the registered defterm pair, and it was left as the default (missing or {0}),
// AND velocity is enabled for DxD, then we switch the delegation pair to Terminal and
// mark that we should check that class for the marker interface later.
if (Globals.delegationPair.IsDefault() && Microsoft::Console::Internal::DefaultApp::CheckShouldTerminalBeDefault())
if (Globals.delegationPair.IsDefault())
{
Globals.delegationPair = DelegationConfig::TerminalDelegationPair;
Globals.defaultTerminalMarkerCheckRequired = true;
Expand Down
6 changes: 0 additions & 6 deletions src/inc/conint.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,4 @@ namespace Microsoft::Console::Internal
{
[[nodiscard]] HRESULT TrySetDarkMode(HWND hwnd) noexcept;
}

namespace DefaultApp
{
[[nodiscard]] bool CheckDefaultAppPolicy() noexcept;
[[nodiscard]] bool CheckShouldTerminalBeDefault() noexcept;
}
}
15 changes: 0 additions & 15 deletions src/internal/stubs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,3 @@ using namespace Microsoft::Console::Internal;
{
return S_FALSE;
}

[[nodiscard]] bool DefaultApp::CheckDefaultAppPolicy() noexcept
{
// True so propsheet will show configuration options but be sure that
// the open one won't attempt handoff from double click of OpenConsole.exe
return true;
}

[[nodiscard]] bool DefaultApp::CheckShouldTerminalBeDefault() noexcept
{
// False since setting Terminal as the default app is an OS feature and probably
// should not be done in the open source conhost. We can always decide to turn it
// on in the future though.
return false;
}
19 changes: 18 additions & 1 deletion src/propsheet/OptionsPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,23 @@ INT_PTR WINAPI SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lPara
// Initialize the global handle to this dialog
g_hOptionsDlg = hDlg;

{
// Do the check for conhostv1 early, so that we can propagate the new ForceV2 state to everyone.
wil::unique_hmodule conhostV1{ LoadLibraryExW(L"conhostv1.dll", nullptr, LOAD_LIBRARY_AS_DATAFILE | LOAD_LIBRARY_SEARCH_SYSTEM32) };
HWND hwndItemToShow, hwndItemToHide;
hwndItemToShow = GetDlgItem(hDlg, IDD_HELP_LEGACY_LINK);
hwndItemToHide = GetDlgItem(hDlg, IDD_HELP_LEGACY_LINK_MISSING);
if (!conhostV1)
{
g_fForceV2 = true;
EnableWindow(GetDlgItem(hDlg, IDD_FORCEV2), FALSE);
std::swap(hwndItemToShow, hwndItemToHide);
}

ShowWindow(hwndItemToShow, SW_SHOW);
ShowWindow(hwndItemToHide, SW_HIDE);
}

CheckDlgButton(hDlg, IDD_HISTORY_NODUP, gpStateInfo->HistoryNoDup);
CheckDlgButton(hDlg, IDD_QUICKEDIT, gpStateInfo->QuickEdit);
CheckDlgButton(hDlg, IDD_INSERT, gpStateInfo->InsertMode);
Expand Down Expand Up @@ -250,7 +267,7 @@ INT_PTR WINAPI SettingsDlgProc(HWND hDlg, UINT wMsg, WPARAM wParam, LPARAM lPara

case WM_NOTIFY:
{
if (lParam && (wParam == IDD_HELP_SYSLINK || wParam == IDD_HELP_LEGACY_LINK))
if (lParam && (wParam == IDD_HELP_SYSLINK || wParam == IDD_HELP_LEGACY_LINK || wParam == IDD_HELP_LEGACY_LINK_MISSING))
{
// handle hyperlink click or keyboard activation
switch (((LPNMHDR)lParam)->code)
Expand Down
19 changes: 3 additions & 16 deletions src/propsheet/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ void SaveConsoleSettingsIfNeeded(const HWND hwnd)
gpStateInfo->FaceName[0] = TEXT('\0');
}

if (Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy())
{
LOG_IF_FAILED(DelegationConfig::s_SetDefaultByPackage(g_selectedPackage));
}
LOG_IF_FAILED(DelegationConfig::s_SetDefaultByPackage(g_selectedPackage));

if (gpStateInfo->LinkTitle != nullptr)
{
Expand Down Expand Up @@ -552,14 +549,7 @@ BOOL PopulatePropSheetPageArray(_Out_writes_(cPsps) PROPSHEETPAGE* pPsp, const s
{
pTerminalPage->dwSize = sizeof(PROPSHEETPAGE);
pTerminalPage->hInstance = ghInstance;
if (Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy())
{
pTerminalPage->pszTemplate = MAKEINTRESOURCE(DID_TERMINAL_WITH_DEFTERM);
}
else
{
pTerminalPage->pszTemplate = MAKEINTRESOURCE(DID_TERMINAL);
}
pTerminalPage->pszTemplate = MAKEINTRESOURCE(DID_TERMINAL_WITH_DEFTERM);
pTerminalPage->pfnDlgProc = TerminalDlgProc;
pTerminalPage->lParam = TERMINAL_PAGE_INDEX;
pTerminalPage->dwFlags = PSP_DEFAULT;
Expand Down Expand Up @@ -629,10 +619,7 @@ INT_PTR ConsolePropertySheet(__in HWND hWnd, __in PCONSOLE_STATE_INFO pStateInfo
// Find the available default console/terminal packages
//

if (Microsoft::Console::Internal::DefaultApp::CheckDefaultAppPolicy())
{
LOG_IF_FAILED(DelegationConfig::s_GetAvailablePackages(g_availablePackages, g_selectedPackage));
}
LOG_IF_FAILED(DelegationConfig::s_GetAvailablePackages(g_availablePackages, g_selectedPackage));

//
// Get the current page number
Expand Down
6 changes: 6 additions & 0 deletions src/propsheet/console.rc
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ BEGIN
CONTROL "&Use legacy console (requires relaunch, affects all consoles)", IDD_FORCEV2, "Button",
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 10, 199, 200, 10

CONTROL "The legacy console is not installed. <A HREF=""https://go.microsoft.com/fwlink/?linkid=2257470"">Learn more.</A>",
IDD_HELP_LEGACY_LINK_MISSING, "SysLink", WS_TABSTOP, 21, 211, 179, 10

CONTROL "Learn more about <A HREF=""https://go.microsoft.com/fwlink/?LinkId=871150"">legacy console mode</A>",
IDD_HELP_LEGACY_LINK, "SysLink", WS_TABSTOP, 21, 211, 179, 10

Expand Down Expand Up @@ -148,6 +151,9 @@ BEGIN
CONTROL "&Use legacy console (requires relaunch, affects all consoles)", IDD_FORCEV2, "Button",
BS_AUTOCHECKBOX | WS_GROUP | WS_TABSTOP, 10, 199, 200, 10

CONTROL "The legacy console is not installed. <A HREF=""https://go.microsoft.com/fwlink/?linkid=2257470"">Learn more.</A>",
IDD_HELP_LEGACY_LINK_MISSING, "SysLink", WS_TABSTOP, 21, 211, 179, 10

CONTROL "Learn more about <A HREF=""https://go.microsoft.com/fwlink/?LinkId=871150"">legacy console mode</A>",
IDD_HELP_LEGACY_LINK, "SysLink", WS_TABSTOP, 21, 211, 179, 10

Expand Down
1 change: 1 addition & 0 deletions src/propsheet/dialogs.h
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ Revision History:
#define IDD_OPACITY_VALUE 514
#define IDD_INTERCEPT_COPY_PASTE 515
#define IDD_HELP_LEGACY_LINK 516
#define IDD_HELP_LEGACY_LINK_MISSING 517


#define DID_TERMINAL 600
Expand Down

0 comments on commit a4445ed

Please sign in to comment.