mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-25 11:05: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
|
||||
|
||||
// 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
|
||||
|
||||
Vector2D textureSize;
|
||||
if (pMonitor->vecTransformedSize.x > 3850) {
|
||||
textureSize = Vector2D(7680, 4320);
|
||||
texPath += "8K.png";
|
||||
texName += "8K.png";
|
||||
} else if (pMonitor->vecTransformedSize.x > 1930) {
|
||||
textureSize = Vector2D(3840, 2160);
|
||||
texPath += "4K.png";
|
||||
texName += "4K.png";
|
||||
} else {
|
||||
textureSize = Vector2D(1920, 1080);
|
||||
texPath += "2K.png";
|
||||
texName += "2K.png";
|
||||
}
|
||||
|
||||
if (!std::filesystem::exists(texPath)) {
|
||||
// try local
|
||||
texPath = texPath.substr(0, 5) + "local/" + texPath.substr(5);
|
||||
|
||||
if (!std::filesystem::exists(texPath))
|
||||
return; // the texture will be empty, oh well. We'll clear with a solid color anyways.
|
||||
}
|
||||
std::string texPath = "/usr/share/hyprland/" + texName;
|
||||
if (std::filesystem::exists(texPath))
|
||||
goto hastex;
|
||||
texPath = "/usr/local/share/hyprland/" + texName;
|
||||
if (std::filesystem::exists(texPath))
|
||||
goto hastex;
|
||||
texPath = "assets/" + texName;
|
||||
if (std::filesystem::exists(texPath))
|
||||
goto hastex;
|
||||
texPath = "";
|
||||
hastex:
|
||||
|
||||
PTEX->m_vSize = textureSize;
|
||||
|
||||
|
@ -1755,8 +1759,19 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
|||
m_mMonitorRenderResources[pMonitor].backgroundTexBox = box;
|
||||
|
||||
// create a new one with cairo
|
||||
const auto CAIROSURFACE = cairo_image_surface_create_from_png(texPath.c_str());
|
||||
const auto CAIRO = cairo_create(CAIROSURFACE);
|
||||
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);
|
||||
|
||||
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
|
||||
cairo_scale(CAIRO, textureSize.x / pMonitor->vecTransformedSize.x, textureSize.y / pMonitor->vecTransformedSize.y);
|
||||
|
|
Loading…
Reference in a new issue