Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/config/ConfigManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ CConfigManager::CConfigManager() : m_inotifyFd(inotify_init()) {
m_config = makeUnique<Hyprlang::CConfig>(CFGPATH.c_str(), Hyprlang::SConfigOptions{.allowMissingConfig = true});

m_config->addConfigValue("general:grab_focus", Hyprlang::INT{1});
m_config->addConfigValue("general:show_apps_on_open", Hyprlang::INT{0});

m_config->addConfigValue("locale:override", Hyprlang::STRING{""});

Expand Down
25 changes: 24 additions & 1 deletion src/finders/desktop/DesktopFinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,30 @@ std::vector<SFinderResult> CDesktopFinder::getResultsForQuery(const std::string&

std::vector<SFinderResult> results;

auto fuzzed = Fuzzy::getNResults(m_desktopEntryCacheGeneric, query, MAX_RESULTS_PER_FINDER);
if (query.empty()) {
// Return all entries sorted by frequency (most used first)
auto sorted = m_desktopEntryCacheGeneric;
std::stable_sort(sorted.begin(), sorted.end(), [](const SP<IFinderResult>& a, const SP<IFinderResult>& b) { return a->frequency() > b->frequency(); });

size_t count = std::min(sorted.size(), sc<size_t>(MAX_RESULTS_PER_FINDER));
results.reserve(count);

for (size_t i = 0; i < count; ++i) {
const auto p = reinterpretPointerCast<CDesktopEntry>(sorted[i]);
if (!p)
continue;
results.emplace_back(SFinderResult{
.label = p->m_name,
.icon = *PICONSENABLED ? p->m_icon : "",
.result = p,
.hasIcon = true,
});
}

return results;
}

auto fuzzed = Fuzzy::getNResults(m_desktopEntryCacheGeneric, query, MAX_RESULTS_PER_FINDER);

results.reserve(fuzzed.size());

Expand Down
25 changes: 19 additions & 6 deletions src/query/QueryProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,25 @@ void CQueryProcessor::process() {
bool eat = false;

if (!m_overrideFinder) {
if (query.empty()) {
// Only show apps on empty query if configured to do so
static auto PSHOWONOPEN = Hyprlang::CSimpleConfigValue<Hyprlang::INT>(g_configManager->m_config.get(), "general:show_apps_on_open");
if (*PSHOWONOPEN) {
static auto PDEFAULTFINDER = Hyprlang::CSimpleConfigValue<Hyprlang::STRING>(g_configManager->m_config.get(), "finders:default_finder");
FINDER = finderForName(*PDEFAULTFINDER);
if (FINDER) {
auto RESULTS = FINDER->getResultsForQuery("");
if (g_ui && g_ui->m_backend)
g_ui->m_backend->addIdle([r = std::move(RESULTS)] mutable { g_ui->updateResults(std::move(r)); });
} else if (g_ui) {
g_ui->m_backend->addIdle([] mutable { g_ui->updateResults({}); });
}
} else if (g_ui) {
g_ui->m_backend->addIdle([] mutable { g_ui->updateResults({}); });
}
return;
}

const auto [F, e] = finderForPrefix(query[0]);

if (e && query.size() == 1)
Expand All @@ -107,12 +126,6 @@ void CQueryProcessor::process() {
} else
FINDER = m_overrideFinder;

if (query.empty() && !m_overrideFinder) {
if (g_ui)
g_ui->m_backend->addIdle([] mutable { g_ui->updateResults({}); });
return;
}

auto RESULTS = FINDER ? FINDER->getResultsForQuery(eat ? query.substr(1) : query) : std::vector<SFinderResult>{};

if (g_ui && g_ui->m_backend)
Expand Down
Loading