Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main' into dev/migrie/b/11170-cu…
Browse files Browse the repository at this point in the history
…rsorpositionchanged-events
  • Loading branch information
zadjii-msft committed Jan 25, 2022
2 parents b99167e + 57b93d2 commit b7c8c0c
Show file tree
Hide file tree
Showing 6 changed files with 36 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,9 @@
<Project>{CA5CAD1A-039A-4929-BA2A-8BEB2E4106FE}</Project>
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
</ProjectReference>
<ProjectReference Include="$(OpenConsoleDir)src\internal\internal.vcxproj">
<Project>{ef3e32a7-5ff6-42b4-b6e2-96cd7d033f00}</Project>
</ProjectReference>

<!-- For whatever reason, we can't include the TerminalControl and
TerminalSettings projects' winmds via project references. So we'll have to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@
<ProjectReference Include="$(OpenConsoleDir)src\propslib\propslib.vcxproj">
<Project>{345FD5A4-B32B-4F29-BD1C-B033BD2C35CC}</Project>
</ProjectReference>
<ProjectReference Include="$(OpenConsoleDir)src\internal\internal.vcxproj">
<Project>{ef3e32a7-5ff6-42b4-b6e2-96cd7d033f00}</Project>
</ProjectReference>
<!-- The midl compiler however, _will_ aggregate our winmd dependencies
somehow. So make sure to only include top-level dependencies here (don't
include Settings and Connection, since Control will include them for us) -->
Expand Down
4 changes: 2 additions & 2 deletions src/host/ft_fuzzer/fuzzmain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ struct NullDeviceComm : public IDeviceComm

CONSOLE_API_CONNECTINFO fakeConnectInfo{};
fakeConnectInfo.ConsoleInfo.SetShowWindow(SW_NORMAL);
fakeConnectInfo.ConsoleInfo.SetScreenBufferSize(til::size{ 80, 25 });
fakeConnectInfo.ConsoleInfo.SetWindowSize(til::size{ 80, 25 });
fakeConnectInfo.ConsoleInfo.SetScreenBufferSize(til::size{ 80, 25 }.to_win32_coord());
fakeConnectInfo.ConsoleInfo.SetWindowSize(til::size{ 80, 25 }.to_win32_coord());
fakeConnectInfo.ConsoleInfo.SetStartupFlags(STARTF_USECOUNTCHARS);
wcscpy_s(fakeConnectInfo.Title, fakeTitle.data());
fakeConnectInfo.TitleLength = gsl::narrow_cast<DWORD>(fakeTitle.size() * sizeof(wchar_t)); // bytes, not wchars
Expand Down
3 changes: 2 additions & 1 deletion src/renderer/atlas/AtlasEngine.api.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,7 @@ CATCH_RETURN()

void AtlasEngine::UpdateHyperlinkHoveredId(const uint16_t hoveredId) noexcept
{
_api.hyperlinkHoveredId = hoveredId;
}

#pragma endregion
Expand Down Expand Up @@ -580,7 +581,7 @@ void AtlasEngine::_resolveFontMetrics(const FontInfoDesired& fontInfoDesired, Fo
const auto strikethroughOffsetInPx = static_cast<double>(-metrics.strikethroughPosition) * designUnitsPerPx;
const auto strikethroughThicknessInPx = static_cast<double>(metrics.strikethroughThickness) * designUnitsPerPx;
const auto lineThickness = gsl::narrow<u16>(std::round(std::min(underlineThicknessInPx, strikethroughThicknessInPx)));
const auto underlinePos = gsl::narrow<u16>(std::round(baseline + underlineOffsetInPx - lineThickness / 2.0));
const auto underlinePos = gsl::narrow<u16>(std::ceil(baseline + underlineOffsetInPx - lineThickness / 2.0));
const auto strikethroughPos = gsl::narrow<u16>(std::round(baseline + strikethroughOffsetInPx - lineThickness / 2.0));

auto fontName = wil::make_process_heap_string(requestedFaceName);
Expand Down
29 changes: 25 additions & 4 deletions src/renderer/atlas/AtlasEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,13 @@ try
const auto x = gsl::narrow_cast<u16>(clamp<int>(coord.X, 0, _api.cellCount.x));
const auto y = gsl::narrow_cast<u16>(clamp<int>(coord.Y, 0, _api.cellCount.y));

if (_api.currentRow != y)
if (_api.lastPaintBufferLineCoord.y != y)
{
_flushBufferLine();
}

_api.currentRow = y;
_api.lastPaintBufferLineCoord = { x, y };
_api.bufferLineWasHyperlinked = false;

// Due to the current IRenderEngine interface (that wasn't refactored yet) we need to assemble
// the current buffer line first as the remaining function operates on whole lines of text.
Expand Down Expand Up @@ -502,9 +503,21 @@ try
CATCH_RETURN()

[[nodiscard]] HRESULT AtlasEngine::PaintBufferGridLines(const GridLineSet lines, const COLORREF color, const size_t cchLine, const COORD coordTarget) noexcept
try
{
if (!_api.bufferLineWasHyperlinked && lines.test(GridLines::Underline) && WI_IsFlagClear(_api.flags, CellFlags::Underline))
{
_api.bufferLineWasHyperlinked = true;

WI_UpdateFlagsInMask(_api.flags, CellFlags::Underline | CellFlags::UnderlineDotted | CellFlags::UnderlineDouble, CellFlags::Underline);

const BufferLineMetadata metadata{ _api.currentColor, _api.flags };
const size_t x = _api.lastPaintBufferLineCoord.x;
std::fill_n(_api.bufferLineMetadata.data() + x, _api.bufferLineMetadata.size() - x, metadata);
}
return S_OK;
}
CATCH_RETURN()

[[nodiscard]] HRESULT AtlasEngine::PaintSelection(SMALL_RECT rect) noexcept
try
Expand Down Expand Up @@ -568,16 +581,24 @@ try

if (!isSettingDefaultBrushes)
{
const auto hyperlinkId = textAttributes.GetHyperlinkId();

auto flags = CellFlags::None;
WI_SetFlagIf(flags, CellFlags::BorderLeft, textAttributes.IsLeftVerticalDisplayed());
WI_SetFlagIf(flags, CellFlags::BorderTop, textAttributes.IsTopHorizontalDisplayed());
WI_SetFlagIf(flags, CellFlags::BorderRight, textAttributes.IsRightVerticalDisplayed());
WI_SetFlagIf(flags, CellFlags::BorderBottom, textAttributes.IsBottomHorizontalDisplayed());
WI_SetFlagIf(flags, CellFlags::Underline, textAttributes.IsUnderlined());
WI_SetFlagIf(flags, CellFlags::UnderlineDotted, textAttributes.IsHyperlink());
WI_SetFlagIf(flags, CellFlags::UnderlineDotted, hyperlinkId != 0);
WI_SetFlagIf(flags, CellFlags::UnderlineDouble, textAttributes.IsDoublyUnderlined());
WI_SetFlagIf(flags, CellFlags::Strikethrough, textAttributes.IsCrossedOut());

if (_api.hyperlinkHoveredId && _api.hyperlinkHoveredId == hyperlinkId)
{
WI_SetFlag(flags, CellFlags::Underline);
WI_ClearAllFlags(flags, CellFlags::UnderlineDotted | CellFlags::UnderlineDouble);
}

const u32x2 newColors{ gsl::narrow_cast<u32>(fg | 0xff000000), gsl::narrow_cast<u32>(bg | _api.backgroundOpaqueMixin) };
const AtlasKeyAttributes attributes{ 0, textAttributes.IsBold(), textAttributes.IsItalic(), 0 };

Expand Down Expand Up @@ -1444,7 +1465,7 @@ void AtlasEngine::_emplaceGlyph(IDWriteFontFace* fontFace, float scale, size_t b

const auto valueData = value.data();
const auto coords = &valueData->coords[0];
const auto data = _getCell(x1, _api.currentRow);
const auto data = _getCell(x1, _api.lastPaintBufferLineCoord.y);

for (u32 i = 0; i < cellCount; ++i)
{
Expand Down
5 changes: 4 additions & 1 deletion src/renderer/atlas/AtlasEngine.h
Original file line number Diff line number Diff line change
Expand Up @@ -735,10 +735,13 @@ namespace Microsoft::Console::Render
u32 backgroundOpaqueMixin = 0xff000000; // changes are flagged as ApiInvalidations::Device
u32x2 currentColor;
AtlasKeyAttributes attributes{};
u16 currentRow = 0;
u16x2 lastPaintBufferLineCoord;
CellFlags flags = CellFlags::None;
// SetSelectionBackground()
u32 selectionColor = 0x7fffffff;
// UpdateHyperlinkHoveredId()
u16 hyperlinkHoveredId = 0;
bool bufferLineWasHyperlinked = false;

// dirtyRect is a computed value based on invalidatedRows.
til::rect dirtyRect;
Expand Down

0 comments on commit b7c8c0c

Please sign in to comment.