mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor(bar): prefer standard unique_ptr
This commit is contained in:
@ -49,7 +49,7 @@ void waybar::Client::_handle_global(void *data, struct wl_registry *registry,
|
||||
auto output = std::make_unique<struct wl_output *>();
|
||||
*output = (struct wl_output *)wl_registry_bind(registry, name,
|
||||
&wl_output_interface, version);
|
||||
o->bars.emplace_back(*o, std::move(output));
|
||||
o->bars.emplace_back(std::make_unique<Bar>(*o, std::move(output)));
|
||||
} else if (!strcmp(interface, wl_seat_interface.name)) {
|
||||
o->seat = (struct wl_seat *)wl_registry_bind(registry, name,
|
||||
&wl_seat_interface, version);
|
||||
|
@ -15,7 +15,7 @@ int main(int argc, char* argv[])
|
||||
waybar::client = &c;
|
||||
std::signal(SIGUSR1, [] (int signal) {
|
||||
for (auto& bar : waybar::client->bars) {
|
||||
bar.toggle();
|
||||
bar.get()->toggle();
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -42,14 +42,18 @@ auto waybar::modules::Battery::update() -> void
|
||||
charging = true;
|
||||
}
|
||||
}
|
||||
if (charging) {
|
||||
_label.get_style_context()->add_class("charging");
|
||||
} else {
|
||||
_label.get_style_context()->remove_class("charging");
|
||||
}
|
||||
auto format = _config["format"] ? _config["format"].asString() : "{}%";
|
||||
_label.set_text(fmt::format(format, total / _batteries.size()));
|
||||
auto value = total / _batteries.size();
|
||||
_label.set_text(fmt::format(format, value));
|
||||
_label.set_tooltip_text(charging ? "Charging" : "Discharging");
|
||||
if (charging)
|
||||
_label.get_style_context()->add_class("charging");
|
||||
else
|
||||
_label.get_style_context()->remove_class("charging");
|
||||
if (value < 52 && !charging)
|
||||
_label.get_style_context()->add_class("warning");
|
||||
else
|
||||
_label.get_style_context()->remove_class("warning");
|
||||
} catch (std::exception &e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
}
|
||||
|
Reference in New Issue
Block a user