mirror of
https://github.com/microsoft/terminal.git
synced 2026-04-07 14:50:55 +00:00
Compare commits
1 Commits
dev/lhecke
...
dev/duhowe
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d881eaedb7 |
@@ -347,9 +347,9 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
|
||||
THROW_IF_FAILED(_CreatePseudoConsoleAndPipes(til::unwrap_coord_size(dimensions), flags, &_inPipe, &_outPipe, &_hPC));
|
||||
|
||||
if (_initialParentHwnd != 0)
|
||||
if (_parentWindow != nullptr)
|
||||
{
|
||||
THROW_IF_FAILED(ConptyReparentPseudoConsole(_hPC.get(), reinterpret_cast<HWND>(_initialParentHwnd)));
|
||||
THROW_IF_FAILED(ConptyReparentPseudoConsole(_hPC.get(), _parentWindow));
|
||||
}
|
||||
|
||||
// GH#12515: The conpty assumes it's hidden at the start. If we're visible, let it know now.
|
||||
@@ -359,6 +359,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
}
|
||||
|
||||
THROW_IF_FAILED(_LaunchAttachedClient());
|
||||
Focused(_focused);
|
||||
}
|
||||
// But if it was an inbound handoff... attempt to synchronize the size of it with what our connection
|
||||
// window is expecting it to be on the first layout.
|
||||
@@ -375,12 +376,14 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
TelemetryPrivacyDataTag(PDT_ProductAndServiceUsage));
|
||||
|
||||
THROW_IF_FAILED(ConptyResizePseudoConsole(_hPC.get(), til::unwrap_coord_size(dimensions)));
|
||||
THROW_IF_FAILED(ConptyReparentPseudoConsole(_hPC.get(), reinterpret_cast<HWND>(_initialParentHwnd)));
|
||||
THROW_IF_FAILED(ConptyReparentPseudoConsole(_hPC.get(), _parentWindow));
|
||||
|
||||
if (_initialVisibility)
|
||||
{
|
||||
THROW_IF_FAILED(ConptyShowHidePseudoConsole(_hPC.get(), _initialVisibility));
|
||||
}
|
||||
|
||||
Focused(_focused);
|
||||
}
|
||||
|
||||
THROW_IF_FAILED(ConptyReleasePseudoConsole(_hPC.get()));
|
||||
@@ -523,16 +526,40 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
void ConptyConnection::ReparentWindow(const uint64_t newParent)
|
||||
{
|
||||
// If we haven't started connecting at all, stash this HWND to use once we have started.
|
||||
_parentWindow = reinterpret_cast<HWND>(newParent);
|
||||
if (!_isStateAtOrBeyond(ConnectionState::Connecting))
|
||||
{
|
||||
_initialParentHwnd = newParent;
|
||||
return;
|
||||
}
|
||||
|
||||
// Otherwise, just inform the conpty of the new owner window handle.
|
||||
// This shouldn't be hittable until GH#5000 / GH#1256, when it's
|
||||
// possible to reparent terminals to different windows.
|
||||
else if (_isConnected())
|
||||
if (_isConnected())
|
||||
{
|
||||
THROW_IF_FAILED(ConptyReparentPseudoConsole(_hPC.get(), reinterpret_cast<HWND>(newParent)));
|
||||
THROW_IF_FAILED(ConptyReparentPseudoConsole(_hPC.get(), _parentWindow));
|
||||
}
|
||||
}
|
||||
|
||||
void ConptyConnection::Focused(bool f)
|
||||
{
|
||||
static auto s = []() {
|
||||
auto m = LoadLibraryExW(L"user32.dll", nullptr, LOAD_LIBRARY_SEARCH_SYSTEM32);
|
||||
return GetProcAddressByFunctionDeclaration(m, SetAdditionalForegroundBoostProcesses);
|
||||
}();
|
||||
|
||||
_focused = f;
|
||||
|
||||
if (!_parentWindow || !s)
|
||||
return;
|
||||
|
||||
if (f)
|
||||
{
|
||||
LOG_LAST_ERROR_IF(!s(_parentWindow, 1, &_piClient.hProcess));
|
||||
}
|
||||
else
|
||||
{
|
||||
LOG_LAST_ERROR_IF(!s(_parentWindow, 0, &_piClient.hProcess));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -34,6 +34,7 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
void ShowHide(const bool show);
|
||||
|
||||
void ReparentWindow(const uint64_t newParent);
|
||||
void Focused(bool f);
|
||||
|
||||
winrt::guid Guid() const noexcept;
|
||||
winrt::hstring Commandline() const;
|
||||
@@ -68,7 +69,8 @@ namespace winrt::Microsoft::Terminal::TerminalConnection::implementation
|
||||
|
||||
til::CoordType _rows{};
|
||||
til::CoordType _cols{};
|
||||
uint64_t _initialParentHwnd{ 0 };
|
||||
HWND _parentWindow{};
|
||||
bool _focused{};
|
||||
hstring _commandline{};
|
||||
hstring _startingDirectory{};
|
||||
hstring _startingTitle{};
|
||||
|
||||
@@ -7,7 +7,7 @@ namespace Microsoft.Terminal.TerminalConnection
|
||||
{
|
||||
delegate void NewConnectionHandler(ConptyConnection connection);
|
||||
|
||||
[default_interface] runtimeclass ConptyConnection : ITerminalConnection
|
||||
[default_interface] runtimeclass ConptyConnection : ITerminalConnection, ITerminalConnectionWithWindowAffinity
|
||||
{
|
||||
ConptyConnection();
|
||||
Guid Guid { get; };
|
||||
@@ -19,8 +19,6 @@ namespace Microsoft.Terminal.TerminalConnection
|
||||
|
||||
void ShowHide(Boolean show);
|
||||
|
||||
void ReparentWindow(UInt64 newParent);
|
||||
|
||||
static event NewConnectionHandler NewConnection;
|
||||
static void StartInboundListener();
|
||||
static void StopInboundListener();
|
||||
|
||||
@@ -29,4 +29,10 @@ namespace Microsoft.Terminal.TerminalConnection
|
||||
event Windows.Foundation.TypedEventHandler<ITerminalConnection, Object> StateChanged;
|
||||
ConnectionState State { get; };
|
||||
};
|
||||
|
||||
interface ITerminalConnectionWithWindowAffinity
|
||||
{
|
||||
void ReparentWindow(UInt64 newParent);
|
||||
void Focused(Boolean f);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -2053,6 +2053,10 @@ namespace winrt::Microsoft::Terminal::Control::implementation
|
||||
const auto previous = std::exchange(_isReadOnly, false);
|
||||
const auto restore = wil::scope_exit([&]() { _isReadOnly = previous; });
|
||||
_terminal->FocusChanged(focused);
|
||||
if (auto c{ _connection.try_as<TerminalConnection::ITerminalConnectionWithWindowAffinity>() })
|
||||
{
|
||||
c.Focused(focused);
|
||||
}
|
||||
}
|
||||
|
||||
bool ControlCore::_isBackgroundTransparent()
|
||||
|
||||
Reference in New Issue
Block a user