Skip to content

Commit

Permalink
comments, clean up scratch
Browse files Browse the repository at this point in the history
  • Loading branch information
zadjii-msft committed Apr 11, 2022
1 parent 22fb15f commit 90d6fe7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 63 deletions.
11 changes: 9 additions & 2 deletions src/host/PtySignalInputThread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,17 @@ void PtySignalInputThread::ConnectConsole() noexcept
LockConsole();
auto Unlock = wil::scope_exit([&] { UnlockConsole(); });

// TODO!
// If the client app hasn't yet connected, stash our initial
// visibility for when we do. We default to not being visible - if a
// terminal wants the ConPTY windows to start "visible", then they
// should send a ShowHidePseudoConsole(..., true) to tell us to
// initially be visible.
//
// Notably, if they don't, then a ShowWindow(SW_HIDE) on the ConPTY
// HWND will initially do _nothing_, because the OS will think that
// the window is already hidden.
if (!_consoleConnected)
{
// TODO!
_initialShowHide = msg;
}
else
Expand Down
59 changes: 1 addition & 58 deletions src/tools/scratch/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,9 @@
// Licensed under the MIT license.

#include <windows.h>
#include <iostream>

// {fmt}, a C++20-compatible formatting library
#include <fmt/format.h>
#include <fmt/compile.h>

// This wmain exists for help in writing scratch programs while debugging.
int __cdecl wmain(int argc, WCHAR* /*argv[]*/)
int __cdecl wmain(int /*argc*/, WCHAR* /*argv[]*/)
{
std::cout << "Args: " << argc << std::endl;

auto consoleHwnd = GetConsoleWindow();

const auto consoleAncestor_PARENT{ GetAncestor(consoleHwnd, GA_PARENT) };
const auto consoleAncestor_ROOT{ GetAncestor(consoleHwnd, GA_ROOT) };
const auto consoleAncestor_ROOTOWNER{ GetAncestor(consoleHwnd, GA_ROOTOWNER) };
wprintf(fmt::format(L"Ancestor_PARENT: {0:#010x}\n", reinterpret_cast<unsigned long long>(consoleAncestor_PARENT)).c_str());
wprintf(fmt::format(L"Ancestor_ROOT: {0:#010x}\n", reinterpret_cast<unsigned long long>(consoleAncestor_ROOT)).c_str());
wprintf(fmt::format(L"Ancestor_ROOTOWNER: {0:#010x}\n", reinterpret_cast<unsigned long long>(consoleAncestor_ROOTOWNER)).c_str());

const auto terminalHwnd = consoleAncestor_ROOT;
wprintf(fmt::format(L"consoleHwnd: {0:#010x}\n", reinterpret_cast<unsigned long long>(consoleHwnd)).c_str());
wprintf(fmt::format(L"terminalHwnd: {0:#010x}\n", reinterpret_cast<unsigned long long>(terminalHwnd)).c_str());

::SetLastError(S_OK);

auto logStyles = [&]() {
wprintf(fmt::format(L"console:\t{0:#010x}\n", GetWindowLong(consoleHwnd, GWL_STYLE)).c_str());
};
logStyles();
printf("\x1b[39;1mHide window...\x1b[m\n");
Sleep(200);
::ShowWindow(consoleHwnd, SW_HIDE);
Sleep(1000);

logStyles();
printf("\x1b[39;1mNormal window...\x1b[m\n");
Sleep(200);
::ShowWindow(consoleHwnd, SW_NORMAL);
Sleep(1000);

logStyles();
printf("\x1b[39;1mHide window...\x1b[m\n");
Sleep(200);
::ShowWindow(consoleHwnd, SW_HIDE);
Sleep(1000);

logStyles();
printf("\x1b[39;1mShow window...\x1b[m\n");
Sleep(200);
::ShowWindow(consoleHwnd, SW_SHOW);
Sleep(1000);

logStyles();
printf("\x1b[39;1mBack to normal window...\x1b[m\n");
Sleep(200);
::ShowWindow(consoleHwnd, SW_NORMAL);
Sleep(1000);

logStyles();

return 0;
}
10 changes: 7 additions & 3 deletions src/winconpty/winconpty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,11 @@ HRESULT _ClearPseudoConsole(_In_ const PseudoConsole* const pPty)
}

// Function Description:
// - TODO!
// - Shows or hides the intermal HWND used by ConPTY. This should be kept in
// sync with the hosting application's window.
// Arguments:
// - hSignal: A signal pipe as returned by CreateConPty.
// TODO!
// - show: true if the window should be shown, false to mark it as iconic.
// Return Value:
// - S_OK if the call succeeded, else an appropriate HRESULT for failing to
// write the clear message to the pty.
Expand Down Expand Up @@ -449,7 +450,10 @@ extern "C" HRESULT WINAPI ConptyClearPseudoConsole(_In_ HPCON hPC)
}

// Function Description:
// - TODO!
// - Tell the ConPTY about the state of the hosting window. This should be used
// to keep ConPTY's internal HWND state in sync with the state of whatever the
// hosting window is.
// - For more information, refer to GH#12515.
extern "C" HRESULT WINAPI ConptyShowHidePseudoConsole(_In_ HPCON hPC, bool show)
{
const PseudoConsole* const pPty = (PseudoConsole*)hPC;
Expand Down

1 comment on commit 90d6fe7

@github-actions

This comment was marked as outdated.

Please sign in to comment.