From 2b735f44bc80ab0f8a16406da1d58dc1be59218d Mon Sep 17 00:00:00 2001 From: Simon Plakolb Date: Wed, 23 Jun 2021 10:43:28 +0200 Subject: [PATCH] modules: Set tooltip on button Mouse-over tooltips set on the label only appear once the mouse hovers over exactly the label. Other apps (e.g. firefox) show the tooltip once the pointer hovers the button. Not solely its label. With this commit we get the same behaviour. --- src/modules/battery.cpp | 2 +- src/modules/bluetooth.cpp | 2 +- src/modules/clock.cpp | 2 +- src/modules/cpu/common.cpp | 2 +- src/modules/custom.cpp | 8 ++++---- src/modules/disk.cpp | 2 +- src/modules/idle_inhibitor.cpp | 2 +- src/modules/inhibitor.cpp | 2 +- src/modules/memory/common.cpp | 4 ++-- src/modules/mpd/mpd.cpp | 4 ++-- src/modules/network.cpp | 8 ++++---- src/modules/pulseaudio.cpp | 4 ++-- src/modules/simpleclock.cpp | 4 ++-- src/modules/sway/language.cpp | 4 ++-- src/modules/sway/mode.cpp | 2 +- src/modules/temperature.cpp | 2 +- 16 files changed, 27 insertions(+), 27 deletions(-) diff --git a/src/modules/battery.cpp b/src/modules/battery.cpp index 6d84946..be30e14 100644 --- a/src/modules/battery.cpp +++ b/src/modules/battery.cpp @@ -347,7 +347,7 @@ auto waybar::modules::Battery::update() -> void { } else if (config_["tooltip-format"].isString()) { tooltip_format = config_["tooltip-format"].asString(); } - label_->set_tooltip_text(fmt::format(tooltip_format, fmt::arg("timeTo", tooltip_text_default), + button_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("timeTo", tooltip_text_default), fmt::arg("capacity", capacity), fmt::arg("time", time_remaining_formatted))); } diff --git a/src/modules/bluetooth.cpp b/src/modules/bluetooth.cpp index d483ac3..6ceab78 100644 --- a/src/modules/bluetooth.cpp +++ b/src/modules/bluetooth.cpp @@ -245,7 +245,7 @@ auto waybar::modules::Bluetooth::update() -> void { device_enumerate_.erase(0, 1); } } - label_->set_tooltip_text(fmt::format( + button_.set_tooltip_text(fmt::format( tooltip_format, fmt::arg("status", state_), fmt::arg("num_connections", connected_devices_.size()), fmt::arg("controller_address", cur_controller_.address), diff --git a/src/modules/clock.cpp b/src/modules/clock.cpp index 07625d5..80c02a4 100644 --- a/src/modules/clock.cpp +++ b/src/modules/clock.cpp @@ -119,7 +119,7 @@ auto waybar::modules::Clock::update() -> void { text = fmt::format(tooltip_format, wtime, fmt::arg(kCalendarPlaceholder.c_str(), calendar_lines), fmt::arg(KTimezonedTimeListPlaceholder.c_str(), timezoned_time_lines)); - label_->set_tooltip_markup(text); + button_.set_tooltip_markup(text); } } diff --git a/src/modules/cpu/common.cpp b/src/modules/cpu/common.cpp index 888d311..8201ed0 100644 --- a/src/modules/cpu/common.cpp +++ b/src/modules/cpu/common.cpp @@ -23,7 +23,7 @@ auto waybar::modules::Cpu::update() -> void { auto [cpu_usage, tooltip] = getCpuUsage(); auto [max_frequency, min_frequency, avg_frequency] = getCpuFrequency(); if (tooltipEnabled()) { - label_->set_tooltip_text(tooltip); + button_.set_tooltip_text(tooltip); } auto format = format_; auto total_usage = cpu_usage.empty() ? 0 : cpu_usage[0]; diff --git a/src/modules/custom.cpp b/src/modules/custom.cpp index 930379b..397298b 100644 --- a/src/modules/custom.cpp +++ b/src/modules/custom.cpp @@ -134,12 +134,12 @@ auto waybar::modules::Custom::update() -> void { label_->set_markup(str); if (tooltipEnabled()) { if (text_ == tooltip_) { - if (label_->get_tooltip_markup() != str) { - label_->set_tooltip_markup(str); + if (button_.get_tooltip_markup() != str) { + button_.set_tooltip_markup(str); } } else { - if (label_->get_tooltip_markup() != tooltip_) { - label_->set_tooltip_markup(tooltip_); + if (button_.get_tooltip_markup() != tooltip_) { + button_.set_tooltip_markup(tooltip_); } } } diff --git a/src/modules/disk.cpp b/src/modules/disk.cpp index 1767cfd..626378c 100644 --- a/src/modules/disk.cpp +++ b/src/modules/disk.cpp @@ -70,7 +70,7 @@ auto waybar::modules::Disk::update() -> void { if (config_["tooltip-format"].isString()) { tooltip_format = config_["tooltip-format"].asString(); } - label_->set_tooltip_text( + button_.set_tooltip_text( fmt::format(tooltip_format, stats.f_bavail * 100 / stats.f_blocks, fmt::arg("free", free), fmt::arg("percentage_free", stats.f_bavail * 100 / stats.f_blocks), fmt::arg("used", used), fmt::arg("percentage_used", percentage_used), diff --git a/src/modules/idle_inhibitor.cpp b/src/modules/idle_inhibitor.cpp index dc373a9..c75c53c 100644 --- a/src/modules/idle_inhibitor.cpp +++ b/src/modules/idle_inhibitor.cpp @@ -62,7 +62,7 @@ auto waybar::modules::IdleInhibitor::update() -> void { fmt::arg("icon", getIcon(0, status_text)))); button_.get_style_context()->add_class(status_text); if (tooltipEnabled()) { - label_->set_tooltip_markup( + button_.set_tooltip_markup( status ? fmt::format(config_["tooltip-format-activated"].isString() ? config_["tooltip-format-activated"].asString() : "{status}", diff --git a/src/modules/inhibitor.cpp b/src/modules/inhibitor.cpp index fc85456..73af503 100644 --- a/src/modules/inhibitor.cpp +++ b/src/modules/inhibitor.cpp @@ -123,7 +123,7 @@ auto Inhibitor::update() -> void { button_.get_style_context()->add_class(status_text); if (tooltipEnabled()) { - label_->set_tooltip_text(status_text); + button_.set_tooltip_text(status_text); } return AButton::update(); diff --git a/src/modules/memory/common.cpp b/src/modules/memory/common.cpp index b924445..596659b 100644 --- a/src/modules/memory/common.cpp +++ b/src/modules/memory/common.cpp @@ -66,7 +66,7 @@ auto waybar::modules::Memory::update() -> void { if (tooltipEnabled()) { if (config_["tooltip-format"].isString()) { auto tooltip_format = config_["tooltip-format"].asString(); - label_->set_tooltip_text(fmt::format( + button_.set_tooltip_text(fmt::format( tooltip_format, used_ram_percentage, fmt::arg("total", total_ram_gigabytes), fmt::arg("swapTotal", total_swap_gigabytes), fmt::arg("percentage", used_ram_percentage), @@ -74,7 +74,7 @@ auto waybar::modules::Memory::update() -> void { fmt::arg("swapUsed", used_swap_gigabytes), fmt::arg("avail", available_ram_gigabytes), fmt::arg("swapAvail", available_swap_gigabytes))); } else { - label_->set_tooltip_text(fmt::format("{:.{}f}GiB used", used_ram_gigabytes, 1)); + button_.set_tooltip_text(fmt::format("{:.{}f}GiB used", used_ram_gigabytes, 1)); } } } else { diff --git a/src/modules/mpd/mpd.cpp b/src/modules/mpd/mpd.cpp index ec6ccb3..d223c66 100644 --- a/src/modules/mpd/mpd.cpp +++ b/src/modules/mpd/mpd.cpp @@ -101,7 +101,7 @@ void waybar::modules::MPD::setLabel() { ? config_["tooltip-format-disconnected"].asString() : "MPD (disconnected)"; // Nothing to format - label_->set_tooltip_text(tooltip_format); + button_.set_tooltip_text(tooltip_format); } return; } else { @@ -195,7 +195,7 @@ void waybar::modules::MPD::setLabel() { fmt::arg("queueLength", queue_length), fmt::arg("stateIcon", stateIcon), fmt::arg("consumeIcon", consumeIcon), fmt::arg("randomIcon", randomIcon), fmt::arg("repeatIcon", repeatIcon), fmt::arg("singleIcon", singleIcon)); - label_->set_tooltip_text(tooltip_text); + button_.set_tooltip_text(tooltip_text); } catch (fmt::format_error const& e) { spdlog::warn("mpd: format error (tooltip): {}", e.what()); } diff --git a/src/modules/network.cpp b/src/modules/network.cpp index e2467f2..953d407 100644 --- a/src/modules/network.cpp +++ b/src/modules/network.cpp @@ -382,11 +382,11 @@ auto waybar::modules::Network::update() -> void { fmt::arg("bandwidthUpBytes", pow_format(bandwidth_up / interval_.count(), "B/s")), fmt::arg("bandwidthTotalBytes", pow_format((bandwidth_up + bandwidth_down) / interval_.count(), "B/s"))); - if (label_->get_tooltip_text() != tooltip_text) { - label_->set_tooltip_markup(tooltip_text); + if (button_.get_tooltip_text() != tooltip_text) { + button_.set_tooltip_markup(tooltip_text); } - } else if (label_->get_tooltip_text() != text) { - label_->set_tooltip_markup(text); + } else if (button_.get_tooltip_text() != text) { + button_.set_tooltip_markup(text); } } diff --git a/src/modules/pulseaudio.cpp b/src/modules/pulseaudio.cpp index f0b7b7d..f71d37d 100644 --- a/src/modules/pulseaudio.cpp +++ b/src/modules/pulseaudio.cpp @@ -283,13 +283,13 @@ auto waybar::modules::Pulseaudio::update() -> void { tooltip_format = config_["tooltip-format"].asString(); } if (!tooltip_format.empty()) { - label_->set_tooltip_text(fmt::format( + button_.set_tooltip_text(fmt::format( tooltip_format, fmt::arg("desc", desc_), fmt::arg("volume", volume_), fmt::arg("format_source", format_source), fmt::arg("source_volume", source_volume_), fmt::arg("source_desc", source_desc_), fmt::arg("icon", getIcon(volume_, getPulseIcon())))); } else { - label_->set_tooltip_text(desc_); + button_.set_tooltip_text(desc_); } } diff --git a/src/modules/simpleclock.cpp b/src/modules/simpleclock.cpp index 9cf5a2d..f6fc17f 100644 --- a/src/modules/simpleclock.cpp +++ b/src/modules/simpleclock.cpp @@ -25,9 +25,9 @@ auto waybar::modules::Clock::update() -> void { if (config_["tooltip-format"].isString()) { auto tooltip_format = config_["tooltip-format"].asString(); auto tooltip_text = fmt::format(tooltip_format, localtime); - label_->set_tooltip_text(tooltip_text); + button_.set_tooltip_text(tooltip_text); } else { - label_->set_tooltip_text(text); + button_.set_tooltip_text(text); } } // Call parent update diff --git a/src/modules/sway/language.cpp b/src/modules/sway/language.cpp index f9d81a2..8a6af61 100644 --- a/src/modules/sway/language.cpp +++ b/src/modules/sway/language.cpp @@ -107,9 +107,9 @@ auto Language::update() -> void { fmt::arg("shortDescription", layout_.short_description), fmt::arg("long", layout_.full_name), fmt::arg("variant", layout_.variant), fmt::arg("flag", layout_.country_flag()))); - label_->set_tooltip_markup(tooltip_display_layout); + button_.set_tooltip_markup(tooltip_display_layout); } else { - label_->set_tooltip_markup(display_layout); + button_.set_tooltip_markup(display_layout); } } diff --git a/src/modules/sway/mode.cpp b/src/modules/sway/mode.cpp index 9f4c6b1..b6c9fc2 100644 --- a/src/modules/sway/mode.cpp +++ b/src/modules/sway/mode.cpp @@ -44,7 +44,7 @@ auto Mode::update() -> void { } else { label_->set_markup(fmt::format(format_, mode_)); if (tooltipEnabled()) { - label_->set_tooltip_text(mode_); + button_.set_tooltip_text(mode_); } event_box_.show(); } diff --git a/src/modules/temperature.cpp b/src/modules/temperature.cpp index c8e0bf0..e888109 100644 --- a/src/modules/temperature.cpp +++ b/src/modules/temperature.cpp @@ -67,7 +67,7 @@ auto waybar::modules::Temperature::update() -> void { if (config_["tooltip-format"].isString()) { tooltip_format = config_["tooltip-format"].asString(); } - label_->set_tooltip_text(fmt::format(tooltip_format, fmt::arg("temperatureC", temperature_c), + button_.set_tooltip_text(fmt::format(tooltip_format, fmt::arg("temperatureC", temperature_c), fmt::arg("temperatureF", temperature_f), fmt::arg("temperatureK", temperature_k))); }