mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 15:25:59 +01:00
Fix background not being cleared
Previously no image would be rendered if hyprland could not find one to use, leaving last frame as the background. This commit ensures there will always be an image available to clear the screen with.
This commit is contained in:
parent
4986d74ef2
commit
aeeecc8129
1 changed files with 28 additions and 13 deletions
|
@ -1708,28 +1708,32 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
// or configure the paths at build time
|
// or configure the paths at build time
|
||||||
|
|
||||||
// get the adequate tex
|
// get the adequate tex
|
||||||
std::string texPath = "/usr/share/hyprland/wall_" + std::string(USEANIME ? (distribution2(engine) == 0 ? "anime_" : "anime2_") : "");
|
std::string texName = "wall_" + std::string(USEANIME ? (distribution2(engine) == 0 ? "anime_" : "anime2_") : "");
|
||||||
// check if wallpapers exist
|
// check if wallpapers exist
|
||||||
|
|
||||||
Vector2D textureSize;
|
Vector2D textureSize;
|
||||||
if (pMonitor->vecTransformedSize.x > 3850) {
|
if (pMonitor->vecTransformedSize.x > 3850) {
|
||||||
textureSize = Vector2D(7680, 4320);
|
textureSize = Vector2D(7680, 4320);
|
||||||
texPath += "8K.png";
|
texName += "8K.png";
|
||||||
} else if (pMonitor->vecTransformedSize.x > 1930) {
|
} else if (pMonitor->vecTransformedSize.x > 1930) {
|
||||||
textureSize = Vector2D(3840, 2160);
|
textureSize = Vector2D(3840, 2160);
|
||||||
texPath += "4K.png";
|
texName += "4K.png";
|
||||||
} else {
|
} else {
|
||||||
textureSize = Vector2D(1920, 1080);
|
textureSize = Vector2D(1920, 1080);
|
||||||
texPath += "2K.png";
|
texName += "2K.png";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!std::filesystem::exists(texPath)) {
|
std::string texPath = "/usr/share/hyprland/" + texName;
|
||||||
// try local
|
if (std::filesystem::exists(texPath))
|
||||||
texPath = texPath.substr(0, 5) + "local/" + texPath.substr(5);
|
goto hastex;
|
||||||
|
texPath = "/usr/local/share/hyprland/" + texName;
|
||||||
if (!std::filesystem::exists(texPath))
|
if (std::filesystem::exists(texPath))
|
||||||
return; // the texture will be empty, oh well. We'll clear with a solid color anyways.
|
goto hastex;
|
||||||
}
|
texPath = "assets/" + texName;
|
||||||
|
if (std::filesystem::exists(texPath))
|
||||||
|
goto hastex;
|
||||||
|
texPath = "";
|
||||||
|
hastex:
|
||||||
|
|
||||||
PTEX->m_vSize = textureSize;
|
PTEX->m_vSize = textureSize;
|
||||||
|
|
||||||
|
@ -1755,9 +1759,20 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||||
m_mMonitorRenderResources[pMonitor].backgroundTexBox = box;
|
m_mMonitorRenderResources[pMonitor].backgroundTexBox = box;
|
||||||
|
|
||||||
// create a new one with cairo
|
// create a new one with cairo
|
||||||
const auto CAIROSURFACE = cairo_image_surface_create_from_png(texPath.c_str());
|
cairo_surface_t* CAIROSURFACE;
|
||||||
|
if (texPath.empty())
|
||||||
|
// if we couldn't find a texture, use a grey filler image instead.
|
||||||
|
CAIROSURFACE = cairo_image_surface_create(CAIRO_FORMAT_ARGB32, textureSize.x, textureSize.y);
|
||||||
|
else
|
||||||
|
CAIROSURFACE = cairo_image_surface_create_from_png(texPath.c_str());
|
||||||
const auto CAIRO = cairo_create(CAIROSURFACE);
|
const auto CAIRO = cairo_create(CAIROSURFACE);
|
||||||
|
|
||||||
|
if (texPath.empty()) {
|
||||||
|
cairo_set_source_rgba(CAIRO, 0.106, 0.106, 0.106, 1.0);
|
||||||
|
cairo_rectangle(CAIRO, 0, 0, box.width, box.height);
|
||||||
|
cairo_fill(CAIRO);
|
||||||
|
}
|
||||||
|
|
||||||
// scale it to fit the current monitor
|
// scale it to fit the current monitor
|
||||||
cairo_scale(CAIRO, textureSize.x / pMonitor->vecTransformedSize.x, textureSize.y / pMonitor->vecTransformedSize.y);
|
cairo_scale(CAIRO, textureSize.x / pMonitor->vecTransformedSize.x, textureSize.y / pMonitor->vecTransformedSize.y);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue