mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-26 06:05:59 +01:00
renderer: add force_wallpaper instead of no_hypr_chan (#3459)
This commit is contained in:
parent
38e242953d
commit
7d7565e7ec
2 changed files with 19 additions and 15 deletions
|
@ -91,8 +91,8 @@ void CConfigManager::setDefaultVars() {
|
|||
|
||||
configValues["misc:disable_hyprland_logo"].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_default_wallpaper"].intValue = -1;
|
||||
configValues["misc:vfr"].intValue = 1;
|
||||
configValues["misc:vrr"].intValue = 0;
|
||||
configValues["misc:mouse_move_enables_dpms"].intValue = 0;
|
||||
|
|
|
@ -1762,34 +1762,37 @@ void CHyprOpenGLImpl::renderSplash(cairo_t* const CAIRO, cairo_surface_t* const
|
|||
void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
||||
RASSERT(m_RenderData.pMonitor, "Tried to createBGTex without begin()!");
|
||||
|
||||
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 PNOSPLASH = &g_pConfigManager->getConfigValuePtr("misc:disable_splash_rendering")->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;
|
||||
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
|
||||
const auto FORCEWALLPAPER = std::clamp(*PFORCEWALLPAPER, -1L, 2L);
|
||||
|
||||
// release the last tex if exists
|
||||
const auto PTEX = &m_mMonitorBGTextures[pMonitor];
|
||||
PTEX->destroyTexture();
|
||||
|
||||
PTEX->allocate();
|
||||
|
||||
Debug::log(LOG, "Allocated texture for BGTex");
|
||||
|
||||
// TODO: use relative paths to the installation
|
||||
// or configure the paths at build time
|
||||
std::string texPath = "/usr/share/hyprland/wall_";
|
||||
std::string prefixes[] = {"", "anime_", "anime2_"};
|
||||
|
||||
// get the adequate tex
|
||||
std::string texPath = "/usr/share/hyprland/wall_";
|
||||
if (!*PDISABLEHYPRCHAN)
|
||||
texPath += std::string(USEANIME ? (distribution2(engine) == 0 ? "anime_" : "anime2_") : "");
|
||||
if (FORCEWALLPAPER == -1) {
|
||||
std::random_device dev;
|
||||
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;
|
||||
if (pMonitor->vecTransformedSize.x > 3850) {
|
||||
|
@ -1803,6 +1806,7 @@ void CHyprOpenGLImpl::createBGTextureForMonitor(CMonitor* pMonitor) {
|
|||
texPath += "2K.png";
|
||||
}
|
||||
|
||||
// check if wallpapers exist
|
||||
if (!std::filesystem::exists(texPath)) {
|
||||
// try local
|
||||
texPath = texPath.substr(0, 5) + "local/" + texPath.substr(5);
|
||||
|
|
Loading…
Reference in a new issue