Fix the engine window frame on windows

Four things came out of testing on windows.

The window settings were hidden outside of wayland because the check used
the backend name, while the bar height matters wherever the engine draws
the frame. The window now reports that (hasEngineFrame: barEnabled on
wayland, engineFrame on glfw) and the display page asks for it. Only the
live resize switch stays wayland specific, since the glfw backend always
draws a fresh frame.

The simplified mode is gone: when the frame is active and the surface has
alpha, the shadow and the outer resize border are always there.

The bar and its controls are drawn even when the font is missing: the early
return used to make the whole bar invisible while its hit zones kept
working.

GLFW rewrites the window style on every mode change and dropped the thick
frame the native resize border and snapping need, so the frame is set up
again after such a change.

Windows runs a modal loop while a window border is dragged and the main
loop is blocked inside it, which froze the content during a resize. The
backend draws and presents a frame from the refresh callback now, and
skips the framerate limit there.
This commit is contained in:
alexei-zebra 2026-10-10 22:02:33 +03:00
parent 4bc81af726
commit 68d4214627
No known key found for this signature in database
GPG key ID: D19D450AC3D9A80E
11 changed files with 96 additions and 52 deletions

View file

@ -40,9 +40,6 @@ void draw_window_bar(Engine& engine) {
}
auto* batch = engine.getGUI().getBatch2D();
auto font = engine.requireAssets().getShared<Font>(BAR_FONT);
if (font == nullptr) {
return;
}
const auto size = window.getSize();
const float barHeight = static_cast<float>(height);
@ -81,30 +78,35 @@ void draw_window_bar(Engine& engine) {
titleRight = std::min(titleRight, item.x - 8.0f);
}
}
const std::wstring title = to_wide(window.getTitle());
const float available = std::max(0.0f, titleRight - titleLeft);
size_t titleLength = title.size();
while (titleLength > 0 && font->calcWidth(title, titleLength) > available) {
titleLength--;
}
if (titleLength > 0) {
const float textWidth = static_cast<float>(
font->calcWidth(title, titleLength)
);
const float centered = (static_cast<float>(size.x) - textWidth) * 0.5f;
const float titleX = std::clamp(
centered,
titleLeft,
std::max(titleLeft, titleRight - textWidth)
);
batch->setColor(glm::vec4(1.0f, 1.0f, 1.0f, 0.85f));
font->draw(
*batch, std::wstring_view(title).substr(0, titleLength),
static_cast<int>(titleX),
(height - font->getLineHeight()) / 2,
nullptr, 0
);
batch->untexture();
// the bar and its controls do not need the font, only the title does
if (font != nullptr) {
const std::wstring title = to_wide(window.getTitle());
const float available = std::max(0.0f, titleRight - titleLeft);
size_t titleLength = title.size();
while (titleLength > 0 &&
font->calcWidth(title, titleLength) > available) {
titleLength--;
}
if (titleLength > 0) {
const float textWidth = static_cast<float>(
font->calcWidth(title, titleLength)
);
const float centered =
(static_cast<float>(size.x) - textWidth) * 0.5f;
const float titleX = std::clamp(
centered,
titleLeft,
std::max(titleLeft, titleRight - textWidth)
);
batch->setColor(glm::vec4(1.0f, 1.0f, 1.0f, 0.85f));
font->draw(
*batch, std::wstring_view(title).substr(0, titleLength),
static_cast<int>(titleX),
(height - font->getLineHeight()) / 2,
nullptr, 0
);
batch->untexture();
}
}
for (size_t i = 0; i < buttons.size(); i++) {