Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into dev/migrie/b/13211-de…
Browse files Browse the repository at this point in the history
…fterm-focus-foreground
  • Loading branch information
zadjii-msft committed Jun 9, 2022
2 parents 9295f95 + 730eb5f commit b1721f6
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 39 deletions.
2 changes: 0 additions & 2 deletions .github/actions/spelling/expect/expect.txt
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,6 @@ guardxfg
guc
gui
guidatom
guiddef
GValue
GWL
GWLP
Expand Down Expand Up @@ -1567,7 +1566,6 @@ NOCOLOR
NOCOMM
NOCONTEXTHELP
NOCOPYBITS
nodefaultlib
nodiscard
NODUP
noexcept
Expand Down
56 changes: 41 additions & 15 deletions src/host/proxy/Host.Proxy.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<Import Project="$(SolutionDir)src\common.build.pre.props" />
<ItemGroup>
<Midl Include="IConsoleHandoff.idl">
<!--
<!--
In Razzle, IDL files generate %FileName%.h
In Visual Studio, IDL files generate %FileName%_h.h
Visual Studio is easier to override than Razzle.
Expand All @@ -41,7 +41,6 @@
<ItemGroup>
<ClInclude Include="$(IntDir)\IConsoleHandoff.h" />
<ClInclude Include="$(IntDir)\ITerminalHandoff.h" />
<ClInclude Include="nodefaultlib_shim.h" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="$(IntDir)\dlldata.c" />
Expand All @@ -67,27 +66,54 @@
</ItemDefinitionGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>.;..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CallingConvention Condition="'$(Platform)'!='ARM64'">StdCall</CallingConvention>
<AdditionalIncludeDirectories>..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<CallingConvention>StdCall</CallingConvention>
<!-- Must be Stdcall on all platforms to resolve _ObjectStublessClient3 -->
<PreprocessorDefinitions>REGISTER_PROXY_DLL;WIN32;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<BasicRuntimeChecks>Default</BasicRuntimeChecks>
<BufferSecurityCheck>false</BufferSecurityCheck>
<SDLCheck>false</SDLCheck>
<ForcedIncludeFiles>nodefaultlib_shim.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
</ClCompile>
<Link>
<ModuleDefinitionFile>OpenConsoleProxy.def</ModuleDefinitionFile>
<!--
Not depending on the CRT cuts binary size by half and prevents issues if this DLL
is copied elsewhere and executed outside of our app package without our bundled CRT present.
-->
<AdditionalDependencies />
<IgnoreAllDefaultLibraries>true</IgnoreAllDefaultLibraries>
<EntryPointSymbol>DllMain</EntryPointSymbol>
</Link>
</ItemDefinitionGroup>

<!--
OpenConsoleProxy gets copied out of our app package and into a shared system store. As such, it can't take a
dependency on any libraries inside our package **or** inside any of our dependency packages. It has to stand
on its own.
Therefore, we're going to use the Hybrid CRT model from WinAppSDK for only OpenConsoleProxy. It statically
links the runtime and STL and dynamically links the UCRT instead of the VC++ CRT. The UCRT ships with Windows.
WinAppSDK asserts that this is "supported according to the CRT maintainer."
-->
<ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
<ClCompile>
<!-- We use MultiThreadedDebug, rather than MultiThreadedDebugDLL, to avoid DLL dependencies on VCRUNTIME140d.dll and MSVCP140d.dll. -->
<RuntimeLibrary>MultiThreadedDebug</RuntimeLibrary>
</ClCompile>
<Link>
<!-- Link statically against the runtime and STL, but link dynamically against the CRT by ignoring the static CRT
lib and instead linking against the Universal CRT DLL import library. This "hybrid" linking mechanism is
supported according to the CRT maintainer. Dynamic linking against the CRT makes the binaries a bit smaller
than they would otherwise be if the CRT, runtime, and STL were all statically linked in. -->
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries);libucrtd.lib</IgnoreSpecificDefaultLibraries>
<AdditionalOptions>%(AdditionalOptions) /defaultlib:ucrtd.lib</AdditionalOptions>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
<ClCompile>
<!-- We use MultiThreaded, rather than MultiThreadedDLL, to avoid DLL dependencies on VCRUNTIME140.dll and MSVCP140.dll. -->
<RuntimeLibrary>MultiThreaded</RuntimeLibrary>
</ClCompile>
<Link>
<!-- Link statically against the runtime and STL, but link dynamically against the CRT by ignoring the static CRT
lib and instead linking against the Universal CRT DLL import library. This "hybrid" linking mechanism is
supported according to the CRT maintainer. Dynamic linking against the CRT makes the binaries a bit smaller
than they would otherwise be if the CRT, runtime, and STL were all statically linked in. -->
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries);libucrt.lib</IgnoreSpecificDefaultLibraries>
<AdditionalOptions>%(AdditionalOptions) /defaultlib:ucrt.lib</AdditionalOptions>
</Link>
</ItemDefinitionGroup>

<!-- Careful reordering these. Some default props (contained in these files) are order sensitive. -->
<Import Project="$(SolutionDir)src\common.build.post.props" />
</Project>
3 changes: 0 additions & 3 deletions src/host/proxy/Host.Proxy.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,6 @@
<ClInclude Include="$(IntDir)\ITerminalHandoff.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="nodefaultlib_shim.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Midl Include="IConsoleHandoff.idl">
Expand Down
8 changes: 0 additions & 8 deletions src/host/proxy/nodefaultlib_shim.h

This file was deleted.

18 changes: 9 additions & 9 deletions src/host/scrolling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ using Microsoft::Console::VirtualTerminal::StateMachine;
using namespace Microsoft::Console::Interactivity;
using namespace Microsoft::Console::Types;

ULONG Scrolling::s_ucWheelScrollLines = 0;
ULONG Scrolling::s_ucWheelScrollChars = 0;
til::CoordType Scrolling::s_ucWheelScrollLines = 0;
til::CoordType Scrolling::s_ucWheelScrollChars = 0;

void Scrolling::s_UpdateSystemMetrics()
{
s_ucWheelScrollLines = ServiceLocator::LocateSystemConfigurationProvider()->GetNumberOfWheelScrollLines();
s_ucWheelScrollChars = ServiceLocator::LocateSystemConfigurationProvider()->GetNumberOfWheelScrollCharacters();
s_ucWheelScrollLines = ::base::saturated_cast<decltype(s_ucWheelScrollLines)>(ServiceLocator::LocateSystemConfigurationProvider()->GetNumberOfWheelScrollLines());
s_ucWheelScrollChars = ::base::saturated_cast<decltype(s_ucWheelScrollChars)>(ServiceLocator::LocateSystemConfigurationProvider()->GetNumberOfWheelScrollCharacters());
}

bool Scrolling::s_IsInScrollMode()
Expand Down Expand Up @@ -112,7 +112,7 @@ void Scrolling::s_HandleMouseWheel(_In_ bool isMouseWheel,
if (isMouseWheel && s_ucWheelScrollLines > 0)
{
// Rounding could cause this to be zero if gucWSL is bigger than 240 or so.
const auto ulActualDelta = std::max(WHEEL_DELTA / s_ucWheelScrollLines, 1ul);
const auto ulActualDelta = std::max(WHEEL_DELTA / s_ucWheelScrollLines, 1);

// If we change direction we need to throw away any remainder we may have in the other direction.
if ((ScreenInfo.WheelDelta > 0) == (wheelDelta > 0))
Expand All @@ -124,7 +124,7 @@ void Scrolling::s_HandleMouseWheel(_In_ bool isMouseWheel,
ScreenInfo.WheelDelta = wheelDelta;
}

if ((ULONG)abs(ScreenInfo.WheelDelta) >= ulActualDelta)
if (abs(ScreenInfo.WheelDelta) >= ulActualDelta)
{
/*
* By default, SHIFT + WM_MOUSEWHEEL will scroll 1/2 the
Expand All @@ -134,7 +134,7 @@ void Scrolling::s_HandleMouseWheel(_In_ bool isMouseWheel,
til::CoordType delta = 1;
if (hasShift)
{
delta = std::max((ScreenInfo.GetViewport().Height() * ScreenInfo.ScrollScale) / 2, 1u);
delta = std::max((ScreenInfo.GetViewport().Height() * ::base::saturated_cast<til::CoordType>(ScreenInfo.ScrollScale)) / 2, 1);

// Account for scroll direction changes by adjusting delta if there was a direction change.
delta *= (ScreenInfo.WheelDelta < 0 ? -1 : 1);
Expand All @@ -161,7 +161,7 @@ void Scrolling::s_HandleMouseWheel(_In_ bool isMouseWheel,
}
else if (isMouseHWheel && s_ucWheelScrollChars > 0)
{
const auto ulActualDelta = std::max(WHEEL_DELTA / s_ucWheelScrollChars, 1ul);
const auto ulActualDelta = std::max(WHEEL_DELTA / s_ucWheelScrollChars, 1);

if ((ScreenInfo.HWheelDelta > 0) == (wheelDelta > 0))
{
Expand All @@ -172,7 +172,7 @@ void Scrolling::s_HandleMouseWheel(_In_ bool isMouseWheel,
ScreenInfo.HWheelDelta = wheelDelta;
}

if ((ULONG)abs(ScreenInfo.HWheelDelta) >= ulActualDelta)
if (abs(ScreenInfo.HWheelDelta) >= ulActualDelta)
{
til::CoordType delta = 1;

Expand Down
4 changes: 2 additions & 2 deletions src/host/scrolling.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ class Scrolling
private:
static BOOL s_IsPointInRectangle(const til::rect* prc, const til::point pt);

static ULONG s_ucWheelScrollLines;
static ULONG s_ucWheelScrollChars;
static til::CoordType s_ucWheelScrollLines;
static til::CoordType s_ucWheelScrollChars;
};

0 comments on commit b1721f6

Please sign in to comment.