From 27a58b584e994853b3a459d1305384c65ec94f9f Mon Sep 17 00:00:00 2001 From: alexei-zebra Date: Sat, 10 Oct 2026 00:38:06 +0300 Subject: [PATCH] Fix black frames of the simple window and rename its setting Without the shadow and the resize border composeFrame() only forced the alpha channel, so the buffer the driver reallocated after a size change was presented as it is, which showed up as a black frame on every resize step. The content is now always painted from the cache and only the shadow itself is skipped when there are no margins. The setting is named simple-window and means the opposite of the previous shadow-and-border: it is off by default, so the window keeps its shadow and the outer border for resizing. --- res/layouts/pages/settings_display.xml.lua | 4 ++-- res/texts/ru_RU.txt | 4 ++-- src/io/settings_io.cpp | 2 +- src/settings.hpp | 4 ++-- src/window/wayland/WaylandWindow.cpp | 21 +++++++++++---------- src/window/wayland/WaylandWindow.hpp | 2 +- 6 files changed, 19 insertions(+), 18 deletions(-) diff --git a/res/layouts/pages/settings_display.xml.lua b/res/layouts/pages/settings_display.xml.lua index b82bd0966..8c7986989 100644 --- a/res/layouts/pages/settings_display.xml.lua +++ b/res/layouts/pages/settings_display.xml.lua @@ -73,8 +73,8 @@ function on_open() "display.compact-window-bar.tooltip" ) create_checkbox( - "display.window-shadow", "Window Shadow", - "display.window-shadow.tooltip" + "display.simple-window", "Simple Window", + "display.simple-window.tooltip" ) create_checkbox( "display.live-resize", "Live Window Resize", diff --git a/res/texts/ru_RU.txt b/res/texts/ru_RU.txt index 6a95f8454..97372af89 100644 --- a/res/texts/ru_RU.txt +++ b/res/texts/ru_RU.txt @@ -119,10 +119,10 @@ settings.Clouds quality=Качество облаков settings.Acoustic effects=Акустические эффекты settings.Microphone access=Доступ к микрофону settings.Narrow Window Bar=Узкая шапка окна -settings.Window Shadow=Тень окна +settings.Simple Window=Простое окно settings.Live Window Resize=Живой ресайз окна settings.display.compact-window-bar.tooltip=Шапка окна высотой 24 px вместо 48 px -settings.display.window-shadow.tooltip=Тень вокруг окна и внешняя область для изменения размера (без неё окно рисуется упрощённо) +settings.display.simple-window.tooltip=Без тени и внешней рамки ресайза settings.display.live-resize.tooltip=Перерисовывать содержимое окна при изменении размера (выключено — последний кадр растягивается) # Управление diff --git a/src/io/settings_io.cpp b/src/io/settings_io.cpp index 772b5ccd8..4c2b3c218 100644 --- a/src/io/settings_io.cpp +++ b/src/io/settings_io.cpp @@ -56,7 +56,7 @@ SettingsHandler::SettingsHandler(EngineSettings& settings) { builder.add("window-mode", &settings.display.windowMode); builder.add("adaptive-menu-fps", &settings.display.adaptiveFpsInMenu); builder.add("compact-window-bar", &settings.display.compactWindowBar); - builder.add("window-shadow", &settings.display.windowShadow); + builder.add("simple-window", &settings.display.simpleWindow); builder.add("live-resize", &settings.display.liveResize); builder.addSection("camera"); diff --git a/src/settings.hpp b/src/settings.hpp index 7d84d6786..9d9b3c80a 100644 --- a/src/settings.hpp +++ b/src/settings.hpp @@ -40,8 +40,8 @@ struct DisplaySettings { FlagSetting adaptiveFpsInMenu {false}; /// @brief Draw the narrow (24px) window bar instead of the 48px one FlagSetting compactWindowBar {false}; - /// @brief Draw the window shadow and keep the outer area for resizing - FlagSetting windowShadow {true}; + /// @brief Draw the window without the shadow and the resize border + FlagSetting simpleWindow {false}; /// @brief Render the window content every frame while it is resized FlagSetting liveResize {true}; }; diff --git a/src/window/wayland/WaylandWindow.cpp b/src/window/wayland/WaylandWindow.cpp index 9724d82a8..c7cbb37ef 100644 --- a/src/window/wayland/WaylandWindow.cpp +++ b/src/window/wayland/WaylandWindow.cpp @@ -282,7 +282,7 @@ void WaylandWindow::setMaximized(bool enabled) { int WaylandWindow::marginSize() const { if (!barEnabled || !shadowEnabled || - (settings != nullptr && !settings->windowShadow.get())) { + (settings != nullptr && settings->simpleWindow.get())) { return 0; } if (fullscreen || maximized || Window::mode != WindowMode::WINDOWED) { @@ -307,9 +307,9 @@ void WaylandWindow::updateSettings() { if (settings == nullptr) { return; } - const bool shadow = settings->windowShadow.get(); - if (shadow != shadowSetting) { - shadowSetting = shadow; + const bool simple = settings->simpleWindow.get(); + if (simple != simpleWindowSetting) { + simpleWindowSetting = simple; // The surface size depends on whether the frame around the content is // drawn at all, so the egl window and the toplevel geometry change. resize(size.x, size.y); @@ -610,18 +610,19 @@ void WaylandWindow::composeFrame() { const int margin = marginSize(); GlStateGuard state; glBindFramebuffer(GL_FRAMEBUFFER, 0); - if (margin <= 0) { - makeContentOpaque(0, 0, size.x, size.y); - return; - } const auto surface = surfaceSize(); glViewport(0, 0, surface.x, surface.y); glDisable(GL_SCISSOR_TEST); glDisable(GL_BLEND); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); - glClearColor(0.0f, 0.0f, 0.0f, 0.0f); + // Without the shadow the surface is exactly the content, but it still has + // to be painted from the cache: a buffer the driver reallocated after a + // resize holds nothing until something is drawn into it. + glClearColor(0.0f, 0.0f, 0.0f, margin > 0 ? 0.0f : 1.0f); glClear(GL_COLOR_BUFFER_BIT); - drawShadow(); + if (margin > 0) { + drawShadow(); + } if (stretchProgram == 0 || cacheWidth == 0) { glEnable(GL_SCISSOR_TEST); glScissor(margin, margin, size.x, size.y); diff --git a/src/window/wayland/WaylandWindow.hpp b/src/window/wayland/WaylandWindow.hpp index 77bdd8543..9754126cd 100644 --- a/src/window/wayland/WaylandWindow.hpp +++ b/src/window/wayland/WaylandWindow.hpp @@ -133,7 +133,7 @@ class WaylandWindow : public Window { static constexpr int SHADOW_MARGIN = 10; static constexpr int RESIZE_GRAB_EXTRA = 2; bool shadowEnabled = false; - bool shadowSetting = true; + bool simpleWindowSetting = false; bool compactBarSetting = false; GLuint shadowProgram = 0;