Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions src/cascadia/TerminalApp/App.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#include "pch.h"
#include "App.h"
#include "App.g.cpp"
#include <CoreWindow.h>

using namespace winrt;
using namespace winrt::Windows::ApplicationModel::Activation;
Expand Down Expand Up @@ -32,6 +33,27 @@ namespace winrt::TerminalApp::implementation
if (!dispatcherQueue)
{
_windowsXamlManager = xaml::Hosting::WindowsXamlManager::InitializeForCurrentThread();

// As of Process Model v3, terminal windows are all created on their
// own threads, but we still initiate XAML for the App on the main
// thread. Thing is, just initializing XAML creates a CoreWindow for
// us. On Windows 10, that CoreWindow will show up as a visible
// window on the taskbar, unless we hide it manually. So, go get it
// and do the SW_HIDE thing on it.
if (const auto& coreWindow{ winrt::Windows::UI::Core::CoreWindow::GetForCurrentThread() })
{
if (const auto& interop{ coreWindow.try_as<ICoreWindowInterop>() })
{
HWND coreHandle{ 0 };
interop->get_WindowHandle(&coreHandle);
if (coreHandle)
{
// This prevents an empty "DesktopWindowXamlSource" from
// appearing on the taskbar
ShowWindow(coreHandle, SW_HIDE);
}
}
}
}
else
{
Expand Down
5 changes: 5 additions & 0 deletions src/cascadia/WindowsTerminal/IslandWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,11 @@ void IslandWindow::Initialize()
// stash the child interop handle so we can resize it when the main hwnd is resized
interop->get_WindowHandle(&_interopWindowHandle);

// Immediately hide our XAML island hwnd. On earlier versions of Windows,
// this HWND could sometimes appear as an actual window in the taskbar
// without this!
ShowWindow(_interopWindowHandle, SW_HIDE);

_rootGrid = winrt::Windows::UI::Xaml::Controls::Grid();
_source.Content(_rootGrid);

Expand Down
4 changes: 2 additions & 2 deletions src/cascadia/WindowsTerminal/IslandWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ class IslandWindow :

HWND _interopWindowHandle;

winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource _source;
winrt::Windows::UI::Xaml::Controls::Grid _rootGrid;
winrt::Windows::UI::Xaml::Hosting::DesktopWindowXamlSource _source; // nulled in ctor
winrt::Windows::UI::Xaml::Controls::Grid _rootGrid; // nulled in ctor
wil::com_ptr<ITaskbarList3> _taskbar;

std::function<void(const HWND, const til::rect&)> _pfnCreateCallback;
Expand Down