mirror of
https://github.com/microsoft/terminal.git
synced 2026-02-08 13:49:31 +00:00
This makes sure we re-own the window appropriately, but defterm doesn't request focus mode. Weird.
This commit is contained in:
@@ -69,6 +69,29 @@ namespace winrt::TerminalApp::implementation
|
||||
// - see GH#2988
|
||||
HRESULT TerminalPage::Initialize(HWND hwnd)
|
||||
{
|
||||
if (!_hostingHwnd.has_value())
|
||||
{
|
||||
// GH#13211 - if we haven't yet set the owning hwnd, reparent all the controls now.
|
||||
for (const auto& tab : _tabs)
|
||||
{
|
||||
if (auto terminalTab{ _GetTerminalTabImpl(tab) })
|
||||
{
|
||||
terminalTab->GetRootPane()->WalkTree([&](auto&& pane) {
|
||||
if (const auto& term{ pane->GetTerminalControl() })
|
||||
{
|
||||
term.OwningHwnd(reinterpret_cast<uint64_t>(hwnd));
|
||||
}
|
||||
});
|
||||
}
|
||||
// We don't need to worry about resetting the owning hwnd for the
|
||||
// SUI here. GH#13211 only repros for a defterm connection, where
|
||||
// the tab is spawned before the window is created. It's not
|
||||
// possible to make a SUI tab like that, before the window is
|
||||
// created. The SUI could be spawned as a part of a window restore,
|
||||
// but that would still work fine. The window would be created
|
||||
// before restoring previous tabs in that scenario.
|
||||
}
|
||||
}
|
||||
_hostingHwnd = hwnd;
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
@@ -267,11 +267,11 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
const auto height = vp.Height();
|
||||
_connection.Resize(height, width);
|
||||
|
||||
if (_OwningHwnd != 0)
|
||||
if (_owningHwnd != 0)
|
||||
{
|
||||
if (auto conpty{ _connection.try_as<TerminalConnection::ConptyConnection>() })
|
||||
{
|
||||
conpty.ReparentWindow(_OwningHwnd);
|
||||
conpty.ReparentWindow(_owningHwnd);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1854,4 +1854,21 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
// transparency, or our acrylic, or our image.
|
||||
return Opacity() < 1.0f || UseAcrylic() || !_settings->BackgroundImage().empty() || _settings->UseBackgroundImageForWindow();
|
||||
}
|
||||
|
||||
uint64_t ControlCore::OwningHwnd()
|
||||
{
|
||||
return _owningHwnd;
|
||||
}
|
||||
|
||||
void ControlCore::OwningHwnd(uint64_t owner)
|
||||
{
|
||||
if (owner != _owningHwnd && _connection)
|
||||
{
|
||||
if (auto conpty{ _connection.try_as<TerminalConnection::ConptyConnection>() })
|
||||
{
|
||||
conpty.ReparentWindow(owner);
|
||||
}
|
||||
}
|
||||
_owningHwnd = owner;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -179,10 +179,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
|
||||
void WindowVisibilityChanged(const bool showOrHide);
|
||||
|
||||
// TODO:GH#1256 - When a tab can be torn out or otherwise reparented to
|
||||
// another window, this value will need a custom setter, so that we can
|
||||
// also update the connection.
|
||||
WINRT_PROPERTY(uint64_t, OwningHwnd, 0);
|
||||
uint64_t OwningHwnd();
|
||||
void OwningHwnd(uint64_t owner);
|
||||
|
||||
RUNTIME_SETTING(double, Opacity, _settings->Opacity());
|
||||
RUNTIME_SETTING(bool, UseAcrylic, _settings->UseAcrylic());
|
||||
@@ -252,6 +250,8 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
double _panelHeight{ 0 };
|
||||
double _compositionScale{ 0 };
|
||||
|
||||
uint64_t _owningHwnd{ 0 };
|
||||
|
||||
winrt::Windows::System::DispatcherQueue _dispatcher{ nullptr };
|
||||
std::shared_ptr<ThrottledFuncTrailing<>> _tsfTryRedrawCanvas;
|
||||
std::shared_ptr<ThrottledFuncTrailing<>> _updatePatternLocations;
|
||||
|
||||
Reference in New Issue
Block a user