Skip to content

Commit d234049

Browse files
committed
Revert "we do not want this"
This reverts commit 4ab628d.
1 parent 4ab628d commit d234049

File tree

3 files changed

+2
-97
lines changed

3 files changed

+2
-97
lines changed

src/cascadia/Remoting/WindowManager.cpp

Lines changed: 2 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,26 +75,8 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
7575
//
7676
// * If we're running unpackaged: the .winmd must be a sibling of the .exe
7777
// * If we're running packaged: the .winmd must be in the package root
78-
// const winrt::com_ptr<::IUnknown> monarch = try_create_instance<::IUnknown>(MonarchCLSID(),
79-
// CLSCTX_LOCAL_SERVER);
80-
// // const auto monarch = try_create_instance<Remoting::IMonarch>(MonarchCLSID(),
81-
// // CLSCTX_LOCAL_SERVER);
82-
83-
// if (monarch)
84-
// {
85-
// const auto hr = (CoAllowSetForegroundWindow(monarch.get(), nullptr));
86-
// if (FAILED(hr))
87-
// {
88-
// DebugBreak();
89-
// }
90-
// }
91-
92-
// _monarch = monarch.try_as<Remoting::IMonarch>();
93-
_monarch = try_create_instance<Remoting::IMonarch>(MonarchCLSID(), CLSCTX_LOCAL_SERVER);
94-
if (_monarch)
95-
{
96-
LOG_LAST_ERROR_IF(!AllowSetForegroundWindow((DWORD)_monarch.GetPID()));
97-
}
78+
_monarch = try_create_instance<Remoting::IMonarch>(MonarchCLSID(),
79+
CLSCTX_LOCAL_SERVER);
9880
}
9981

10082
// Check if we became the king, and if we are, wire up callbacks.
@@ -507,9 +489,6 @@ namespace winrt::Microsoft::Terminal::Remoting::implementation
507489
summonArgs.ToggleVisibility(false);
508490

509491
args.SummonBehavior(summonArgs);
510-
511-
LOG_LAST_ERROR_IF(!AllowSetForegroundWindow((DWORD)monarch.GetPID()));
512-
513492
monarch.SummonWindow(args);
514493
return true;
515494
}

src/cascadia/WindowsTerminal/IslandWindow.cpp

Lines changed: 0 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,6 @@ using VirtualKeyModifiers = winrt::Windows::System::VirtualKeyModifiers;
2727
#define XAML_HOSTING_WINDOW_CLASS_NAME L"CASCADIA_HOSTING_WINDOW_CLASS"
2828
#define IDM_SYSTEM_MENU_BEGIN 0x1000
2929

30-
void _trace(const wchar_t* const pwsz)
31-
{
32-
TraceLoggingWrite(g_hWindowsTerminalProvider,
33-
"TraceMessage",
34-
TraceLoggingDescription("debug print messages"),
35-
TraceLoggingWideString(pwsz, "message", "the message"),
36-
TraceLoggingLevel(WINEVENT_LEVEL_VERBOSE),
37-
TraceLoggingKeyword(TIL_KEYWORD_TRACE));
38-
}
39-
4030
IslandWindow::IslandWindow() noexcept :
4131
_interopWindowHandle{ nullptr },
4232
_rootGrid{ nullptr },
@@ -1532,7 +1522,6 @@ void IslandWindow::_globalActivateWindow(const uint32_t dropdownDuration,
15321522
// restore-down the window.
15331523
if (IsIconic(_window.get()))
15341524
{
1535-
_trace(L"window was iconic");
15361525
if (dropdownDuration > 0)
15371526
{
15381527
_dropdownWindow(dropdownDuration, toMonitor);
@@ -1545,47 +1534,16 @@ void IslandWindow::_globalActivateWindow(const uint32_t dropdownDuration,
15451534
// able to properly set this as the foreground window.
15461535
if (!IsWindowVisible(GetHandle()))
15471536
{
1548-
_trace(L"window wasn't visible");
15491537
ShowWindow(_window.get(), SW_SHOW);
15501538
}
15511539
ShowWindow(_window.get(), SW_RESTORE);
1552-
if (!SetForegroundWindow(_window.get()))
1553-
{
1554-
const auto gle = GetLastError();
1555-
_trace(fmt::format(L"SetForegroundWindow failed: {}", gle).c_str());
1556-
1557-
const auto fg = GetForegroundWindow();
1558-
std::wstring title(GetWindowTextLength(fg) + 1, L'\0');
1559-
GetWindowTextW(fg, &title[0], (DWORD)title.size());
1560-
DWORD fgPid = 0;
1561-
GetWindowThreadProcessId(fg, &fgPid);
1562-
_trace(fmt::format(L"Foreground Window is: [{}]={}", (uint64_t)fgPid, title).c_str());
1563-
1564-
SwitchToThisWindow(_window.get(), false);
1565-
}
1566-
else
1567-
{
1568-
_trace(L"got fg?");
1569-
}
1570-
1571-
// LOG_IF_WIN32_BOOL_FALSE(BringWindowToTop(_window.get()));
1572-
if (!BringWindowToTop(_window.get()))
1573-
{
1574-
const auto gle = GetLastError();
1575-
_trace(fmt::format(L"BringWindowToTop failed: {}", gle).c_str());
1576-
}
1577-
else
1578-
{
1579-
_trace(L"brought to top?");
1580-
}
15811540

15821541
// Once we've been restored, throw us on the active monitor.
15831542
_moveToMonitor(oldForegroundWindow, toMonitor);
15841543
}
15851544
}
15861545
else
15871546
{
1588-
_trace(L"window wasn't iconic");
15891547
// Try first to send a message to the current foreground window. If it's not responding, it may
15901548
// be waiting on us to finish launching. Passing SMTO_NOTIMEOUTIFNOTHUNG means that we get the same
15911549
// behavior as before--that is, waiting for the message loop--but we've done an early return if
@@ -1611,10 +1569,6 @@ void IslandWindow::_globalActivateWindow(const uint32_t dropdownDuration,
16111569
// Throw us on the active monitor.
16121570
_moveToMonitor(oldForegroundWindow, toMonitor);
16131571
}
1614-
else
1615-
{
1616-
_trace(L"huh");
1617-
}
16181572
}
16191573
}
16201574

src/cascadia/WindowsTerminal/WindowEmperor.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -59,32 +59,6 @@ void _buildArgsFromCommandline(std::vector<winrt::hstring>& args)
5959
args.emplace_back(L"wt.exe");
6060
}
6161
}
62-
63-
HWND _createToolWindow()
64-
{
65-
WNDCLASS wc{};
66-
wc.hCursor = LoadCursor(nullptr, IDC_ARROW);
67-
wc.hInstance = reinterpret_cast<HINSTANCE>(&__ImageBase);
68-
wc.lpszClassName = TERMINAL_MESSAGE_CLASS_NAME;
69-
wc.style = CS_HREDRAW | CS_VREDRAW;
70-
wc.lpfnWndProc = DefWindowProc; //WindowEmperor::_wndProc;
71-
wc.hIcon = LoadIconW(wc.hInstance, MAKEINTRESOURCEW(IDI_APPICON));
72-
RegisterClass(&wc);
73-
// WINRT_ASSERT(!_window);
74-
75-
return CreateWindow(wc.lpszClassName,
76-
L"Windows Terminal Notification Handoff",
77-
0,
78-
CW_USEDEFAULT,
79-
CW_USEDEFAULT,
80-
CW_USEDEFAULT,
81-
CW_USEDEFAULT,
82-
HWND_MESSAGE,
83-
nullptr,
84-
wc.hInstance,
85-
nullptr);
86-
}
87-
8862
bool WindowEmperor::_handleLaunchArgs()
8963
try
9064
{
@@ -140,8 +114,6 @@ try
140114
// }
141115
}
142116
}
143-
auto fake = _createToolWindow();
144-
fake;
145117
return winrt::Microsoft::Terminal::Remoting::WindowManager::SummonForNotification(window);
146118
}
147119
}

0 commit comments

Comments
 (0)