Skip to content

Commit 67272cc

Browse files
authored
Merge pull request #4042 from clemenscodes/wlr-taskbar-icon-title-fallback
wlr/taskbar: find icon by title as fallback
2 parents 1dfde58 + addf44d commit 67272cc

File tree

1 file changed

+31
-1
lines changed

1 file changed

+31
-1
lines changed

src/modules/wlr/taskbar.cpp

+31-1
Original file line numberDiff line numberDiff line change
@@ -382,9 +382,39 @@ std::string Task::state_string(bool shortened) const {
382382
return res.substr(0, res.size() - 1);
383383
}
384384

385-
void Task::handle_title(const char *title) {
385+
void Task::handle_title(const char* title) {
386+
if (title_.empty()) {
387+
spdlog::debug(fmt::format("Task ({}) setting title to {}", id_, title_));
388+
} else {
389+
spdlog::debug(fmt::format("Task ({}) overwriting title '{}' with '{}'", id_, title_, title));
390+
}
386391
title_ = title;
387392
hide_if_ignored();
393+
394+
if (!with_icon_ && !with_name_ || app_info_) {
395+
return;
396+
}
397+
398+
set_app_info_from_app_id_list(title_);
399+
name_ = app_info_ ? app_info_->get_display_name() : title;
400+
401+
if (!with_icon_) {
402+
return;
403+
}
404+
405+
int icon_size = config_["icon-size"].isInt() ? config_["icon-size"].asInt() : 16;
406+
bool found = false;
407+
for (auto &icon_theme : tbar_->icon_themes()) {
408+
if (image_load_icon(icon_, icon_theme, app_info_, icon_size)) {
409+
found = true;
410+
break;
411+
}
412+
}
413+
414+
if (found)
415+
icon_.show();
416+
else
417+
spdlog::debug("Couldn't find icon for {}", title_);
388418
}
389419

390420
void Task::set_minimize_hint() {

0 commit comments

Comments
 (0)