Skip to content

Commit b271c26

Browse files
committed
stuff
1 parent f38e72f commit b271c26

3 files changed

Lines changed: 21 additions & 11 deletions

File tree

src/system/Icons.cpp

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,7 @@ static std::optional<std::vector<std::string>> getIconThemeDirs() {
167167
return paths;
168168
}
169169

170-
static void parseThemes(const std::vector<std::string>& themeDirs, std::vector<std::string>& lookupDirs);
171-
172-
static void parseTheme(const std::string& themeDir, std::vector<std::string>& lookupDirs) {
170+
void CSystemIconFactory::parseTheme(const std::string& themeDir) {
173171
const auto THEME_DATA = readFileAsString(themeDir + "/index.theme");
174172

175173
if (!THEME_DATA)
@@ -190,7 +188,7 @@ static void parseTheme(const std::string& themeDir, std::vector<std::string>& lo
190188
CConstVarList dirs(directoriesList, 0, ',', true);
191189

192190
for (const auto& d : dirs) {
193-
lookupDirs.emplace_back(BASE_PATH / d);
191+
m_lookupPaths.emplace_back(BASE_PATH / d);
194192
}
195193

196194
g_logger->log(HT_LOG_TRACE, "CSystemIconFactory: theme {} has {} dirs", themeDir, dirs.size());
@@ -211,19 +209,22 @@ static void parseTheme(const std::string& themeDir, std::vector<std::string>& lo
211209
g_logger->log(HT_LOG_TRACE, "CSystemIconFactory: theme {} inherits {} themes", themeDir, inherits.size());
212210

213211
for (const auto& inheritName : inherits) {
212+
if (inheritName == "hicolor")
213+
m_hicolorAdded = true;
214+
214215
auto inheritTheme = getThemeDir(trim(std::string{inheritName}));
215216
if (inheritTheme) {
216217
g_logger->log(HT_LOG_TRACE, "CSystemIconFactory: parsing inherited theme {}", *inheritTheme);
217-
parseThemes(*inheritTheme, lookupDirs);
218+
parseThemes(*inheritTheme);
218219
} else
219220
g_logger->log(HT_LOG_WARNING, "CSystemIconFactory: inherited theme {} not found", std::string{inheritName});
220221
}
221222
}
222223
}
223224

224-
static void parseThemes(const std::vector<std::string>& themeDirs, std::vector<std::string>& lookupDirs) {
225+
void CSystemIconFactory::parseThemes(const std::vector<std::string>& themeDirs) {
225226
for (const auto& td : themeDirs) {
226-
parseTheme(td, lookupDirs);
227+
parseTheme(td);
227228
}
228229
}
229230

@@ -233,7 +234,13 @@ CSystemIconFactory::CSystemIconFactory() {
233234
if (!baseThemeDir)
234235
return;
235236

236-
parseThemes(baseThemeDir.value(), m_lookupPaths);
237+
parseThemes(baseThemeDir.value());
238+
239+
if (!m_hicolorAdded) {
240+
const auto DIRS = getThemeDir("hicolor");
241+
if (DIRS)
242+
parseThemes(*DIRS);
243+
}
237244

238245
g_logger->log(HT_LOG_TRACE, "CSystemIconFactory: initialized with {} lookup paths", m_lookupPaths.size());
239246
}

src/system/Icons.hpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,12 @@ namespace Hyprtoolkit {
4545
void cacheEntry(const std::string& iconName, SIconCacheResult&& result);
4646
std::optional<SIconCacheResult> getCached(const std::string& name);
4747

48+
bool m_hicolorAdded = false;
49+
4850
private:
51+
void parseThemes(const std::vector<std::string>& themeDirs);
52+
void parseTheme(const std::string& themeDir);
53+
4954
std::vector<std::string> m_lookupPaths;
5055

5156
// TODO: stdlib's map is SLOW

src/system/SystemIcon.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,8 @@ CSystemIconDescription::CSystemIconDescription(const std::string& name) {
2626
auto iconPath = fullDirPath / (name + ".svg");
2727
std::error_code ec;
2828

29-
if (!std::filesystem::exists(iconPath, ec) || ec) {
29+
if (!std::filesystem::exists(iconPath, ec) || ec)
3030
iconPath = fullDirPath / (name + ".png");
31-
continue;
32-
}
3331

3432
if (!std::filesystem::exists(iconPath, ec) || ec)
3533
continue;

0 commit comments

Comments
 (0)