Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions metainfo.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@
<li>Fixes build failure on Alpine Linux (musl libc) due to missing close_range() function (#1879)</li>
<li>Fixes third-party dependency files (headers, libraries) leaking into install tree (#1788)</li>
<li>Fixes size of the window when using tiling WM (#1908)</li>
<li>Fixes crash when rapidly changing font size due to data races between UI and render threads (#1922)</li>
</ul>
</description>
</release>
Expand Down
8 changes: 3 additions & 5 deletions src/contour/helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -781,14 +781,12 @@ void applyResize(vtbackend::ImageSize newPixelSize,
vtbackend::Terminal& terminal = session.terminal();
vtbackend::ImageSize const cellSize = renderer.gridMetrics().cellSize;

if (renderer.hasRenderTarget())
renderer.renderTarget().setRenderSize(newPixelSize);
renderer.setPageSize(newPageSize);
renderer.setMargin(computeMargin(
auto const newMargin = computeMargin(
renderer.gridMetrics().cellSize,
newPageSize,
newPixelSize,
applyContentScale(session.profile().margins.value(), session.display()->contentScale())));
applyContentScale(session.profile().margins.value(), session.display()->contentScale()));
renderer.applyResize(newPixelSize, newPageSize, newMargin);

if (oldPageSize.lines != newPageSize.lines)
emit session.lineCountChanged(newPageSize.lines.as<int>());
Expand Down
6 changes: 5 additions & 1 deletion src/vtbackend/Terminal.h
Original file line number Diff line number Diff line change
Expand Up @@ -1213,7 +1213,11 @@ class Terminal
void resetStatusLineDefinition();

TabsInfo guiTabsInfoForStatusLine() const noexcept { return _guiTabInfoForStatusLine; }
void setGuiTabInfoForStatusLine(TabsInfo&& info) { _guiTabInfoForStatusLine = std::move(info); }
void setGuiTabInfoForStatusLine(TabsInfo&& info)
{
auto const l = std::lock_guard { _stateMutex };
_guiTabInfoForStatusLine = std::move(info);
}

TabsNamingMode getTabsNamingMode() const noexcept { return _settings.tabNamingMode; }
void requestTabName();
Expand Down
5 changes: 4 additions & 1 deletion src/vtrasterizer/Renderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,8 @@ bool Renderer::setFontSize(text::font_size fontSize)

void Renderer::updateFontMetrics()
{
auto const l = std::scoped_lock { _renderMutex };

rendererLog()("Updating grid metrics: {}", _gridMetrics);

_gridMetrics = loadGridMetrics(_fonts.regular, _gridMetrics.pageSize, *_textShaper);
Expand Down Expand Up @@ -324,8 +326,9 @@ void Renderer::render(vtbackend::Terminal& terminal, bool pressure)

void Renderer::renderImpl(vtbackend::Terminal& terminal, bool pressure)
{
auto const renderLock = std::scoped_lock { _renderMutex };

auto const statusLineHeight = terminal.statusLineHeight();
_gridMetrics.pageSize = terminal.pageSize() + statusLineHeight;

executeImageDiscards();

Expand Down
23 changes: 22 additions & 1 deletion src/vtrasterizer/Renderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include <format>
#include <memory>
#include <mutex>
#include <span>
#include <vector>

Expand Down Expand Up @@ -83,15 +84,34 @@ class Renderer
_decorationRenderer.setHyperlinkDecoration(normal, hover);
}

void setPageSize(vtbackend::PageSize screenSize) noexcept { _gridMetrics.pageSize = screenSize; }
void setPageSize(vtbackend::PageSize screenSize) noexcept
{
auto const l = std::scoped_lock { _renderMutex };
_gridMetrics.pageSize = screenSize;
}

void setMargin(PageMargin margin) noexcept
{
auto const l = std::scoped_lock { _renderMutex };
if (_renderTarget)
_renderTarget->setMargin(margin);
_gridMetrics.pageMargin = margin;
}

void applyResize(vtbackend::ImageSize newPixelSize,
vtbackend::PageSize newPageSize,
PageMargin newMargin) noexcept
{
auto const l = std::scoped_lock { _renderMutex };
if (_renderTarget)
{
_renderTarget->setRenderSize(newPixelSize);
_renderTarget->setMargin(newMargin);
}
_gridMetrics.pageSize = newPageSize;
_gridMetrics.pageMargin = newMargin;
}

/**
* Renders the given @p terminal to the current OpenGL context.
*
Expand Down Expand Up @@ -182,6 +202,7 @@ class Renderer

GridMetrics _gridMetrics;

mutable std::mutex _renderMutex; //!< Protects _gridMetrics during resize/render.
std::mutex _imageDiscardLock; //!< Lock guard for accessing _discardImageQueue.
std::vector<vtbackend::ImageId> _discardImageQueue; //!< List of images to be discarded.

Expand Down
Loading