From 8e6cbc10219f5f73d7d7162d3f7f033ee307d658 Mon Sep 17 00:00:00 2001 From: dmitry Date: Wed, 1 Jul 2020 02:10:22 +0300 Subject: [PATCH 1/3] Change find icon priority and to_lower app_id --- src/modules/wlr/taskbar.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index f588970..1676235 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -85,9 +85,9 @@ static bool image_load_icon(Gtk::Image& image, Glib::RefPtr icon * send a single app-id, but in any case this works fine */ while (stream >> app_id) { - std::string icon_name = get_from_desktop_app_info(app_id); + std::string icon_name = get_from_icon_theme(icon_theme, app_id); if (icon_name.empty()) - icon_name = get_from_icon_theme(icon_theme, app_id); + icon_name = get_from_desktop_app_info(app_id); if (icon_name.empty()) continue; @@ -271,7 +271,9 @@ void Task::handle_title(const char *title) void Task::handle_app_id(const char *app_id) { app_id_ = app_id; - if (!image_load_icon(icon_, tbar_->icon_theme(), app_id_, + std::transform(app_id_.begin(), app_id_.end(), app_id_.begin(), + [](char c){ return std::tolower(c); }); + if (!image_load_icon(icon_, tbar_->icon_theme(), app_id_, config_["icon-size"].isInt() ? config_["icon-size"].asInt() : 16)) spdlog::warn("Failed to load icon for {}", app_id); From 43500a9983a3341bf4309767f597da3c203a2b25 Mon Sep 17 00:00:00 2001 From: dmitry Date: Wed, 1 Jul 2020 02:56:44 +0300 Subject: [PATCH 2/3] Move lower to load_icon phase --- src/modules/wlr/taskbar.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index 1676235..6dd24a7 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -77,6 +77,7 @@ static bool image_load_icon(Gtk::Image& image, Glib::RefPtr icon const std::string &app_id_list, int size) { std::string app_id; + std::string lower_app_id; std::istringstream stream(app_id_list); bool found = false; @@ -85,10 +86,18 @@ static bool image_load_icon(Gtk::Image& image, Glib::RefPtr icon * send a single app-id, but in any case this works fine */ while (stream >> app_id) { + std::transform(app_id.begin(), app_id.end(), lower_app_id.begin(), + [](char c){ return std::tolower(c); }); std::string icon_name = get_from_icon_theme(icon_theme, app_id); + if (icon_name.empty()) + icon_name = get_from_icon_theme(icon_theme, lower_app_id); + if (icon_name.empty()) icon_name = get_from_desktop_app_info(app_id); + if (icon_name.empty()) + icon_name = get_from_desktop_app_info(lower_app_id); + if (icon_name.empty()) continue; @@ -271,8 +280,6 @@ void Task::handle_title(const char *title) void Task::handle_app_id(const char *app_id) { app_id_ = app_id; - std::transform(app_id_.begin(), app_id_.end(), app_id_.begin(), - [](char c){ return std::tolower(c); }); if (!image_load_icon(icon_, tbar_->icon_theme(), app_id_, config_["icon-size"].isInt() ? config_["icon-size"].asInt() : 16)) spdlog::warn("Failed to load icon for {}", app_id); From 8a13ed59bc039cb689a48c22f10a9a06d5394636 Mon Sep 17 00:00:00 2001 From: dmitry Date: Wed, 1 Jul 2020 03:05:17 +0300 Subject: [PATCH 3/3] Fix lower --- src/modules/wlr/taskbar.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/modules/wlr/taskbar.cpp b/src/modules/wlr/taskbar.cpp index 6dd24a7..95a7a51 100644 --- a/src/modules/wlr/taskbar.cpp +++ b/src/modules/wlr/taskbar.cpp @@ -86,11 +86,13 @@ static bool image_load_icon(Gtk::Image& image, Glib::RefPtr icon * send a single app-id, but in any case this works fine */ while (stream >> app_id) { - std::transform(app_id.begin(), app_id.end(), lower_app_id.begin(), - [](char c){ return std::tolower(c); }); std::string icon_name = get_from_icon_theme(icon_theme, app_id); - if (icon_name.empty()) + if (icon_name.empty()) { + lower_app_id = app_id; + std::transform(lower_app_id.begin(), lower_app_id.end(), lower_app_id.begin(), + [](char c){ return std::tolower(c); }); icon_name = get_from_icon_theme(icon_theme, lower_app_id); + } if (icon_name.empty()) icon_name = get_from_desktop_app_info(app_id);