Add removed secondary identifier
(class for xwayland under sway)
This commit is contained in:
parent
31683d9e2a
commit
a8a1a4985f
|
@ -16,7 +16,8 @@ class AAppIconLabel : public AIconLabel {
|
||||||
auto update() -> void override;
|
auto update() -> void override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void updateAppIconName(const std::string &app_identifier);
|
void updateAppIconName(const std::string &app_identifier,
|
||||||
|
const std::string &alternative_app_identifier);
|
||||||
void updateAppIcon();
|
void updateAppIcon();
|
||||||
unsigned app_icon_size_{24};
|
unsigned app_icon_size_{24};
|
||||||
bool update_app_icon_{true};
|
bool update_app_icon_{true};
|
||||||
|
|
|
@ -24,7 +24,8 @@ AAppIconLabel::AAppIconLabel(const Json::Value& config, const std::string& name,
|
||||||
image_.set_pixel_size(app_icon_size_);
|
image_.set_pixel_size(app_icon_size_);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<std::string> getDesktopFilePath(const std::string& app_identifier) {
|
std::optional<std::string> getDesktopFilePath(const std::string& app_identifier,
|
||||||
|
const std::string& alternative_app_identifier) {
|
||||||
const auto data_dirs = Glib::get_system_data_dirs();
|
const auto data_dirs = Glib::get_system_data_dirs();
|
||||||
for (const auto& data_dir : data_dirs) {
|
for (const auto& data_dir : data_dirs) {
|
||||||
const auto data_app_dir = data_dir + "applications/";
|
const auto data_app_dir = data_dir + "applications/";
|
||||||
|
@ -32,12 +33,19 @@ std::optional<std::string> getDesktopFilePath(const std::string& app_identifier)
|
||||||
if (std::filesystem::exists(desktop_file_path)) {
|
if (std::filesystem::exists(desktop_file_path)) {
|
||||||
return desktop_file_path;
|
return desktop_file_path;
|
||||||
}
|
}
|
||||||
|
if (!alternative_app_identifier.empty()) {
|
||||||
|
desktop_file_path = data_app_dir + alternative_app_identifier + ".desktop";
|
||||||
|
if (std::filesystem::exists(desktop_file_path)) {
|
||||||
|
return desktop_file_path;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Glib::ustring> getIconName(const std::string& app_identifier) {
|
std::optional<Glib::ustring> getIconName(const std::string& app_identifier,
|
||||||
const auto desktop_file_path = getDesktopFilePath(app_identifier);
|
const std::string& alternative_app_identifier) {
|
||||||
|
const auto desktop_file_path = getDesktopFilePath(app_identifier, alternative_app_identifier);
|
||||||
if (!desktop_file_path.has_value()) {
|
if (!desktop_file_path.has_value()) {
|
||||||
// Try some heuristics to find a matching icon
|
// Try some heuristics to find a matching icon
|
||||||
|
|
||||||
|
@ -90,12 +98,13 @@ std::optional<Glib::ustring> getIconName(const std::string& app_identifier) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
void AAppIconLabel::updateAppIconName(const std::string& app_identifier) {
|
void AAppIconLabel::updateAppIconName(const std::string& app_identifier,
|
||||||
|
const std::string& alternative_app_identifier) {
|
||||||
if (!iconEnabled()) {
|
if (!iconEnabled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto icon_name = getIconName(app_identifier);
|
const auto icon_name = getIconName(app_identifier, alternative_app_identifier);
|
||||||
if (icon_name.has_value()) {
|
if (icon_name.has_value()) {
|
||||||
app_icon_name_ = icon_name.value();
|
app_icon_name_ = icon_name.value();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -152,7 +152,7 @@ void Window::queryActiveWorkspace() {
|
||||||
}
|
}
|
||||||
|
|
||||||
window_data_ = WindowData::parse(*active_window);
|
window_data_ = WindowData::parse(*active_window);
|
||||||
updateAppIconName(window_data_.class_name);
|
updateAppIconName(window_data_.class_name, window_data_.initial_class_name);
|
||||||
std::vector<Json::Value> workspace_windows;
|
std::vector<Json::Value> workspace_windows;
|
||||||
std::copy_if(clients.begin(), clients.end(), std::back_inserter(workspace_windows),
|
std::copy_if(clients.begin(), clients.end(), std::back_inserter(workspace_windows),
|
||||||
[&](Json::Value window) {
|
[&](Json::Value window) {
|
||||||
|
|
|
@ -43,7 +43,7 @@ void Window::onCmd(const struct Ipc::ipc_response& res) {
|
||||||
auto output = payload["output"].isString() ? payload["output"].asString() : "";
|
auto output = payload["output"].isString() ? payload["output"].asString() : "";
|
||||||
std::tie(app_nb_, floating_count_, windowId_, window_, app_id_, app_class_, shell_, layout_) =
|
std::tie(app_nb_, floating_count_, windowId_, window_, app_id_, app_class_, shell_, layout_) =
|
||||||
getFocusedNode(payload["nodes"], output);
|
getFocusedNode(payload["nodes"], output);
|
||||||
updateAppIconName(app_id_);
|
updateAppIconName(app_id_, app_class_);
|
||||||
dp.emit();
|
dp.emit();
|
||||||
} catch (const std::exception& e) {
|
} catch (const std::exception& e) {
|
||||||
spdlog::error("Window: {}", e.what());
|
spdlog::error("Window: {}", e.what());
|
||||||
|
|
Loading…
Reference in New Issue