Added tooltips to hyprland/workspaces
Simply slam a `"tooltip": true` and a `"tooltip-format": "<your format>"` in that config
This commit is contained in:
@@ -94,7 +94,7 @@ class Workspace {
|
|||||||
bool onWindowOpened(WindowCreationPayload const& create_window_paylod);
|
bool onWindowOpened(WindowCreationPayload const& create_window_paylod);
|
||||||
std::optional<std::string> closeWindow(WindowAddress const& addr);
|
std::optional<std::string> closeWindow(WindowAddress const& addr);
|
||||||
|
|
||||||
void update(const std::string& format, const std::string& icon);
|
void update(const std::string& format, const std::string& icon, const std::string &tooltipFormat);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Workspaces& m_workspaceManager;
|
Workspaces& m_workspaceManager;
|
||||||
@@ -199,6 +199,7 @@ class Workspaces : public AModule, public EventHandler {
|
|||||||
{"DEFAULT", SortMethod::DEFAULT}};
|
{"DEFAULT", SortMethod::DEFAULT}};
|
||||||
|
|
||||||
std::string m_format;
|
std::string m_format;
|
||||||
|
std::string m_tooltipFormat;
|
||||||
|
|
||||||
std::map<std::string, std::string> m_iconsMap;
|
std::map<std::string, std::string> m_iconsMap;
|
||||||
util::RegexCollection m_windowRewriteRules;
|
util::RegexCollection m_windowRewriteRules;
|
||||||
|
|||||||
@@ -60,6 +60,13 @@ auto Workspaces::parseConfig(const Json::Value &config) -> void {
|
|||||||
m_format = configFormat.isString() ? configFormat.asString() : "{name}";
|
m_format = configFormat.isString() ? configFormat.asString() : "{name}";
|
||||||
m_withIcon = m_format.find("{icon}") != std::string::npos;
|
m_withIcon = m_format.find("{icon}") != std::string::npos;
|
||||||
|
|
||||||
|
if (tooltipEnabled()) {
|
||||||
|
const Json::Value &configTooltipFormat = config["tooltip-format"];
|
||||||
|
m_tooltipFormat = configTooltipFormat.isString() ? configTooltipFormat.asString() : "{name}";
|
||||||
|
} else {
|
||||||
|
m_tooltipFormat = "";
|
||||||
|
}
|
||||||
|
|
||||||
if (m_withIcon && m_iconsMap.empty()) {
|
if (m_withIcon && m_iconsMap.empty()) {
|
||||||
Json::Value formatIcons = config["format-icons"];
|
Json::Value formatIcons = config["format-icons"];
|
||||||
for (std::string &name : formatIcons.getMemberNames()) {
|
for (std::string &name : formatIcons.getMemberNames()) {
|
||||||
@@ -237,7 +244,7 @@ void Workspaces::doUpdate() {
|
|||||||
});
|
});
|
||||||
workspace->setOutput((*updated_workspace)["monitor"].asString());
|
workspace->setOutput((*updated_workspace)["monitor"].asString());
|
||||||
|
|
||||||
workspace->update(m_format, workspaceIcon);
|
workspace->update(m_format, workspaceIcon, m_tooltipFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
spdlog::trace("Updating window count");
|
spdlog::trace("Updating window count");
|
||||||
@@ -866,7 +873,7 @@ void addOrRemoveClass(const Glib::RefPtr<Gtk::StyleContext> &context, bool condi
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Workspace::update(const std::string &format, const std::string &icon) {
|
void Workspace::update(const std::string &format, const std::string &icon, const std::string &tooltipFormat) {
|
||||||
// clang-format off
|
// clang-format off
|
||||||
if (this->m_workspaceManager.activeOnly() && \
|
if (this->m_workspaceManager.activeOnly() && \
|
||||||
!this->isActive() && \
|
!this->isActive() && \
|
||||||
@@ -902,6 +909,10 @@ void Workspace::update(const std::string &format, const std::string &icon) {
|
|||||||
windows.append(window_repr);
|
windows.append(window_repr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_button.set_tooltip_text(fmt::format(fmt::runtime(tooltipFormat), fmt::arg("id", id()),
|
||||||
|
fmt::arg("name", name()), fmt::arg("icon", icon),
|
||||||
|
fmt::arg("windows", windows)));
|
||||||
|
|
||||||
m_label.set_markup(fmt::format(fmt::runtime(format), fmt::arg("id", id()),
|
m_label.set_markup(fmt::format(fmt::runtime(format), fmt::arg("id", id()),
|
||||||
fmt::arg("name", name()), fmt::arg("icon", icon),
|
fmt::arg("name", name()), fmt::arg("icon", icon),
|
||||||
fmt::arg("windows", windows)));
|
fmt::arg("windows", windows)));
|
||||||
|
|||||||
Reference in New Issue
Block a user