renderer: add force_wallpaper instead of no_hypr_chan (#3459)

This commit is contained in:
DaniD3v 2023-10-07 15:08:38 +02:00 committed by GitHub
parent 38e242953d
commit 7d7565e7ec
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 15 deletions

View file

@ -91,8 +91,8 @@ void CConfigManager::setDefaultVars() {
configValues["misc:disable_hyprland_logo"].intValue = 0; configValues["misc:disable_hyprland_logo"].intValue = 0;
configValues["misc:disable_splash_rendering"].intValue = 0; configValues["misc:disable_splash_rendering"].intValue = 0;
configValues["misc:disable_hypr_chan"].intValue = 0;
configValues["misc:force_hypr_chan"].intValue = 0; configValues["misc:force_hypr_chan"].intValue = 0;
configValues["misc:force_default_wallpaper"].intValue = -1;
configValues["misc:vfr"].intValue = 1; configValues["misc:vfr"].intValue = 1;
configValues["misc:vrr"].intValue = 0; configValues["misc:vrr"].intValue = 0;
configValues["misc:mouse_move_enables_dpms"].intValue = 0; configValues["misc:mouse_move_enables_dpms"].intValue = 0;

View file

@ -1763,33 +1763,36 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!"); RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!");
static auto* const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue; static auto* const PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->intValue;
static auto* const PDISABLEHYPRCHAN = &g_pConfigManager->getConfigValuePtr("misc:disable_hypr_chan")->intValue;
static auto* const PFORCEHYPRCHAN = &g_pConfigManager->getConfigValuePtr("misc:force_hypr_chan")->intValue; static auto* const PFORCEHYPRCHAN = &g_pConfigManager->getConfigValuePtr("misc:force_hypr_chan")->intValue;
static auto* const PFORCEWALLPAPER = &g_pConfigManager->getConfigValuePtr("misc:force_default_wallpaper")->intValue;
std::random_device dev; const auto FORCEWALLPAPER = std::clamp(*PFORCEWALLPAPER, -1L, 2L);
std::mt19937 engine(dev());
std::uniform_int_distribution<> distribution(0, 2);
std::uniform_int_distribution<> distribution2(0, 1);
const bool USEANIME = *PFORCEHYPRCHAN || distribution(engine) == 0; // 66% for anime
// release the last tex if exists // release the last tex if exists
const auto PTEX = &m_mMonitorBGTextures[pMonitor]; const auto PTEX = &m_mMonitorBGTextures[pMonitor];
PTEX->destroyTexture(); PTEX->destroyTexture();
PTEX->allocate(); PTEX->allocate();
Debug::log(LOG, "Allocated texture for BGTex"); Debug::log(LOG, "Allocated texture for BGTex");
// TODO: use relative paths to the installation // TODO: use relative paths to the installation
// or configure the paths at build time // or configure the paths at build time
std::string texPath = "/usr/share/hyprland/wall_";
std::string prefixes[] = {"", "anime_", "anime2_"};
// get the adequate tex // get the adequate tex
std::string texPath = "/usr/share/hyprland/wall_"; if (FORCEWALLPAPER == -1) {
if (!*PDISABLEHYPRCHAN) std::random_device dev;
texPath += std::string(USEANIME ? (distribution2(engine) == 0 ? "anime_" : "anime2_") : ""); std::mt19937 engine(dev());
std::uniform_int_distribution<> distribution(0, 2);
std::uniform_int_distribution<> distribution_anime(1, 2);
// check if wallpapers exist if (PFORCEHYPRCHAN)
texPath += prefixes[distribution_anime(engine)];
else
texPath += prefixes[distribution(engine)];
} else
texPath += prefixes[FORCEWALLPAPER];
Vector2D textureSize; Vector2D textureSize;
if (pMonitor->vecTransformedSize.x > 3850) { if (pMonitor->vecTransformedSize.x > 3850) {
@ -1803,6 +1806,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
texPath += "2K.png"; texPath += "2K.png";
} }
// check if wallpapers exist
if (!std::filesystem::exists(texPath)) { if (!std::filesystem::exists(texPath)) {
// try local // try local
texPath = texPath.substr(0, 5) + "local/" + texPath.substr(5); texPath = texPath.substr(0, 5) + "local/" + texPath.substr(5);