Merge pull request #5208 from Mrpaoo/ref/rm-dpemit

refactor: rm direct dp.emit() call in constructor.
This commit is contained in:
Alexis Rouillard
2026-07-19 19:15:51 +02:00
committed by GitHub
28 changed files with 3 additions and 41 deletions
+1
View File
@@ -624,6 +624,7 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos,
spdlog::error("{}: {}", ref, e.what()); spdlog::error("{}: {}", ref, e.what());
} }
}); });
module->dp.emit();
} catch (const std::exception& e) { } catch (const std::exception& e) {
spdlog::warn("module {}: {}", name.asString(), e.what()); spdlog::warn("module {}: {}", name.asString(), e.what());
} }
-2
View File
@@ -17,8 +17,6 @@ waybar::modules::Backlight::Backlight(const std::string& id, const Json::Value&
: ALabel(config, "backlight", id, "{percent}%", 2), : ALabel(config, "backlight", id, "{percent}%", 2),
preferred_device_(config["device"].isString() ? config["device"].asString() : ""), preferred_device_(config["device"].isString() ? config["device"].asString() : ""),
backend(interval_, [this] { dp.emit(); }) { backend(interval_, [this] { dp.emit(); }) {
dp.emit();
// Set up scroll handler // Set up scroll handler
event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK); event_box_.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
event_box_.signal_scroll_event().connect(sigc::mem_fun(*this, &Backlight::handleScroll)); event_box_.signal_scroll_event().connect(sigc::mem_fun(*this, &Backlight::handleScroll));
-2
View File
@@ -213,8 +213,6 @@ waybar::modules::Bluetooth::Bluetooth(const std::string& id, const Json::Value&
#ifdef WANT_RFKILL #ifdef WANT_RFKILL
rfkill_.on_update.connect(sigc::hide(sigc::mem_fun(*this, &Bluetooth::update))); rfkill_.on_update.connect(sigc::hide(sigc::mem_fun(*this, &Bluetooth::update)));
#endif #endif
dp.emit();
} }
auto waybar::modules::Bluetooth::update() -> void { auto waybar::modules::Bluetooth::update() -> void {
+1 -1
View File
@@ -17,7 +17,7 @@ waybar::modules::Custom::Custom(const std::string& name, const std::string& id,
if (config.isNull()) { if (config.isNull()) {
spdlog::warn("There is no configuration for 'custom/{}', element will be hidden", name); spdlog::warn("There is no configuration for 'custom/{}', element will be hidden", name);
} }
dp.emit();
if (!config_["signal"].empty() && config_["interval"].empty() && if (!config_["signal"].empty() && config_["interval"].empty() &&
config_["restart-interval"].empty()) { config_["restart-interval"].empty()) {
waitingWorker(); waitingWorker();
+1 -1
View File
@@ -22,7 +22,7 @@ waybar::modules::CustomGraph::CustomGraph(const std::string& name, const std::st
if (config.isNull()) { if (config.isNull()) {
spdlog::warn("There is no configuration for 'custom-graph/{}', element will be hidden", name); spdlog::warn("There is no configuration for 'custom-graph/{}', element will be hidden", name);
} }
dp.emit();
if (!config_["signal"].empty() && config_["interval"].empty() && if (!config_["signal"].empty() && config_["interval"].empty() &&
config_["restart-interval"].empty()) { config_["restart-interval"].empty()) {
waitingWorker(); waitingWorker();
-1
View File
@@ -20,7 +20,6 @@ Submap::Submap(const std::string& id, const Bar& bar, const Json::Value& config)
// register for hyprland ipc // register for hyprland ipc
m_ipc.registerForIPC("submap", this); m_ipc.registerForIPC("submap", this);
dp.emit();
if (config["icons"].isObject()) { if (config["icons"].isObject()) {
const Json::Value& icons = config["icons"]; const Json::Value& icons = config["icons"];
-2
View File
@@ -32,8 +32,6 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
m_ipc.registerForIPC("changefloatingmode", this); m_ipc.registerForIPC("changefloatingmode", this);
m_ipc.registerForIPC("fullscreen", this); m_ipc.registerForIPC("fullscreen", this);
windowIpcUniqueLock.unlock(); windowIpcUniqueLock.unlock();
dp.emit();
} }
Window::~Window() { Window::~Window() {
-1
View File
@@ -19,7 +19,6 @@ WindowCount::WindowCount(const std::string& id, const Bar& bar, const Json::Valu
queryActiveWorkspace(); queryActiveWorkspace();
update(); update();
dp.emit();
// register for hyprland ipc // register for hyprland ipc
m_ipc.registerForIPC("fullscreen", this); m_ipc.registerForIPC("fullscreen", this);
-1
View File
@@ -104,7 +104,6 @@ Inhibitor::Inhibitor(const std::string& id, const Bar& bar, const Json::Value& c
inhibitors_(::getInhibitors(config)) { inhibitors_(::getInhibitors(config)) {
event_box_.add_events(Gdk::BUTTON_PRESS_MASK); event_box_.add_events(Gdk::BUTTON_PRESS_MASK);
event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, &Inhibitor::handleToggle)); event_box_.signal_button_press_event().connect(sigc::mem_fun(*this, &Inhibitor::handleToggle));
dp.emit();
} }
Inhibitor::~Inhibitor() { Inhibitor::~Inhibitor() {
-1
View File
@@ -7,7 +7,6 @@ namespace waybar::modules::mango {
Keymode::Keymode(const std::string& id, const Bar& bar, const Json::Value& config) Keymode::Keymode(const std::string& id, const Bar& bar, const Json::Value& config)
: ALabel(config, "keymode", id, "{}", 0, false), bar_(bar) { : ALabel(config, "keymode", id, "{}", 0, false), bar_(bar) {
IPC::getInstance().registerForIPC("monitor", this); IPC::getInstance().registerForIPC("monitor", this);
dp.emit();
} }
Keymode::~Keymode() { IPC::getInstance().unregisterForIPC(this); } Keymode::~Keymode() { IPC::getInstance().unregisterForIPC(this); }
-1
View File
@@ -17,7 +17,6 @@ Language::Language(const std::string& id, const Bar& bar, const Json::Value& con
IPC::getInstance().registerForIPC("monitor", this); IPC::getInstance().registerForIPC("monitor", this);
updateFromIPC(); updateFromIPC();
dp.emit();
} }
Language::~Language() { Language::~Language() {
-1
View File
@@ -7,7 +7,6 @@ namespace waybar::modules::mango {
Layout::Layout(const std::string& id, const Bar& bar, const Json::Value& config) Layout::Layout(const std::string& id, const Bar& bar, const Json::Value& config)
: ALabel(config, "layout", id, "{}", 0, false), bar_(bar) { : ALabel(config, "layout", id, "{}", 0, false), bar_(bar) {
IPC::getInstance().registerForIPC("monitor", this); IPC::getInstance().registerForIPC("monitor", this);
dp.emit();
} }
Layout::~Layout() { IPC::getInstance().unregisterForIPC(this); } Layout::~Layout() { IPC::getInstance().unregisterForIPC(this); }
-1
View File
@@ -10,7 +10,6 @@ namespace waybar::modules::mango {
Window::Window(const std::string& id, const Bar& bar, const Json::Value& config) Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
: AAppIconLabel(config, "window", id, "{title}", 0, true), bar_(bar) { : AAppIconLabel(config, "window", id, "{title}", 0, true), bar_(bar) {
IPC::getInstance().registerForIPC("monitor", this); IPC::getInstance().registerForIPC("monitor", this);
dp.emit();
} }
Window::~Window() { IPC::getInstance().unregisterForIPC(this); } Window::~Window() { IPC::getInstance().unregisterForIPC(this); }
-1
View File
@@ -29,7 +29,6 @@ Workspaces::Workspaces(const std::string& id, const Bar& bar, const Json::Value&
} }
IPC::getInstance().registerForIPC("monitor", this); IPC::getInstance().registerForIPC("monitor", this);
dp.emit();
} }
Workspaces::~Workspaces() { Workspaces::~Workspaces() {
-3
View File
@@ -177,9 +177,6 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
thread_.sleep_for(interval_); thread_.sleep_for(interval_);
}; };
} }
// trigger initial update
dp.emit();
} }
Mpris::~Mpris() { Mpris::~Mpris() {
-1
View File
@@ -140,7 +140,6 @@ waybar::modules::Network::Network(const std::string& id, const Json::Value& conf
createEventSocket(); createEventSocket();
createInfoSocket(); createInfoSocket();
dp.emit();
// Ask for a dump of interfaces and then addresses to populate our // Ask for a dump of interfaces and then addresses to populate our
// information. First the interface dump, and once done, the callback // information. First the interface dump, and once done, the callback
// will be called again which will ask for addresses dump. // will be called again which will ask for addresses dump.
-1
View File
@@ -18,7 +18,6 @@ Language::Language(const std::string& id, const Bar& bar, const Json::Value& con
gIPC->registerForIPC("KeyboardLayoutSwitched", this); gIPC->registerForIPC("KeyboardLayoutSwitched", this);
updateFromIPC(); updateFromIPC();
dp.emit();
} }
Language::~Language() { Language::~Language() {
-2
View File
@@ -18,8 +18,6 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
gIPC->registerForIPC("WindowClosed", this); gIPC->registerForIPC("WindowClosed", this);
gIPC->registerForIPC("WindowFocusChanged", this); gIPC->registerForIPC("WindowFocusChanged", this);
gIPC->registerForIPC("WindowLayoutsChanged", this); gIPC->registerForIPC("WindowLayoutsChanged", this);
dp.emit();
} }
Window::~Window() { gIPC->unregisterForIPC(this); } Window::~Window() { gIPC->unregisterForIPC(this); }
-2
View File
@@ -82,8 +82,6 @@ Workspaces::Workspaces(const std::string& id, const Bar& bar, const Json::Value&
window.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK); window.add_events(Gdk::SCROLL_MASK | Gdk::SMOOTH_SCROLL_MASK);
window.signal_scroll_event().connect(sigc::mem_fun(*this, &Workspaces::handleScroll)); window.signal_scroll_event().connect(sigc::mem_fun(*this, &Workspaces::handleScroll));
} }
dp.emit();
} }
Workspaces::~Workspaces() { gIPC->unregisterForIPC(this); } Workspaces::~Workspaces() { gIPC->unregisterForIPC(this); }
-2
View File
@@ -44,8 +44,6 @@ PowerProfilesDaemon::PowerProfilesDaemon(const std::string& id, const Json::Valu
Gio::DBus::Proxy::create_for_bus(Gio::DBus::BusType::BUS_TYPE_SYSTEM, "net.hadess.PowerProfiles", Gio::DBus::Proxy::create_for_bus(Gio::DBus::BusType::BUS_TYPE_SYSTEM, "net.hadess.PowerProfiles",
"/net/hadess/PowerProfiles", "net.hadess.PowerProfiles", "/net/hadess/PowerProfiles", "net.hadess.PowerProfiles",
sigc::mem_fun(*this, &PowerProfilesDaemon::busConnectedCb)); sigc::mem_fun(*this, &PowerProfilesDaemon::busConnectedCb));
// Schedule update to set the initial visibility
dp.emit();
} }
void PowerProfilesDaemon::busConnectedCb(Glib::RefPtr<Gio::AsyncResult>& r) { void PowerProfilesDaemon::busConnectedCb(Glib::RefPtr<Gio::AsyncResult>& r) {
-2
View File
@@ -117,8 +117,6 @@ Privacy::Privacy(const std::string& id, const Json::Value& config, Gtk::Orientat
geoclue_backend = util::GeoClueBackend::GeoClueBackend::getInstance(); geoclue_backend = util::GeoClueBackend::GeoClueBackend::getInstance();
geoclue_backend->in_use_changed_signal_event.connect( geoclue_backend->in_use_changed_signal_event.connect(
sigc::mem_fun(*this, &Privacy::onGeoCluePrivacyNodesChanged)); sigc::mem_fun(*this, &Privacy::onGeoCluePrivacyNodesChanged));
dp.emit();
} }
void Privacy::onPWPrivacyNodesChanged() { void Privacy::onPWPrivacyNodesChanged() {
-1
View File
@@ -49,7 +49,6 @@ Tray::Tray(const std::string& id, const Bar& bar, const Json::Value& config)
box_.set_spacing(config_["spacing"].asUInt()); box_.set_spacing(config_["spacing"].asUInt());
} }
nb_hosts_ += 1; nb_hosts_ += 1;
dp.emit();
} }
void Tray::checkIgnoreList(std::unique_ptr<Item>* item_ptr) { void Tray::checkIgnoreList(std::unique_ptr<Item>* item_ptr) {
-1
View File
@@ -42,7 +42,6 @@ Language::Language(const std::string& id, const Json::Value& config)
spdlog::error("Language: {}", e.what()); spdlog::error("Language: {}", e.what());
} }
}); });
dp.emit();
} }
void Language::onCmd(const struct Ipc::ipc_response& res) { void Language::onCmd(const struct Ipc::ipc_response& res) {
-1
View File
@@ -16,7 +16,6 @@ Mode::Mode(const std::string& id, const Json::Value& config)
spdlog::error("Mode: {}", e.what()); spdlog::error("Mode: {}", e.what());
} }
}); });
dp.emit();
} }
void Mode::onEvent(const struct Ipc::ipc_response& res) { void Mode::onEvent(const struct Ipc::ipc_response& res) {
-2
View File
@@ -88,8 +88,6 @@ SystemdFailedUnits::SystemdFailedUnits(const std::string& id, const Json::Value&
throw std::runtime_error("Neither system nor user status is requested."); throw std::runtime_error("Neither system nor user status is requested.");
updateData(); updateData();
/* Always update for the first time. */
dp.emit();
} }
auto SystemdFailedUnits::notify_cb(const Glib::ustring& sender_name, auto SystemdFailedUnits::notify_cb(const Glib::ustring& sender_name,
-2
View File
@@ -79,8 +79,6 @@ UPower::UPower(const std::string& id, const Json::Value& config)
resetDevices(); resetDevices();
setDisplayDevice(); setDisplayDevice();
// Update the widget
dp.emit();
} }
UPower::~UPower() { UPower::~UPower() {
-2
View File
@@ -20,8 +20,6 @@ Window::Window(const std::string& id, const Bar& bar, const Json::Value& config)
ipc->register_handler("view-app-id-changed", handler); ipc->register_handler("view-app-id-changed", handler);
ipc->register_handler("window-rules/get-focused-view", handler); ipc->register_handler("window-rules/get-focused-view", handler);
dp.emit();
} }
Window::~Window() { ipc->unregister_handler(handler); } Window::~Window() { ipc->unregister_handler(handler); }
-3
View File
@@ -44,9 +44,6 @@ Workspaces::Workspaces(const std::string& id, const Bar& bar, const Json::Value&
ipc->register_handler("window-rules/list-outputs", handler); ipc->register_handler("window-rules/list-outputs", handler);
ipc->register_handler("window-rules/list-wsets", handler); ipc->register_handler("window-rules/list-wsets", handler);
ipc->register_handler("window-rules/get-focused-output", handler); ipc->register_handler("window-rules/get-focused-output", handler);
// initial render
dp.emit();
} }
Workspaces::~Workspaces() { ipc->unregister_handler(handler); } Workspaces::~Workspaces() { ipc->unregister_handler(handler); }