src: clang-tidy

This commit is contained in:
Austin Horstman
2024-07-02 10:12:41 -05:00
parent 9997155617
commit 14c3235c12
9 changed files with 62 additions and 59 deletions

View File

@ -4,6 +4,7 @@
#include <spdlog/spdlog.h>
#include <iostream>
#include <utility>
#include "gtkmm/icontheme.h"
#include "idle-inhibit-unstable-v1-client-protocol.h"
@ -11,13 +12,13 @@
#include "util/format.hpp"
waybar::Client *waybar::Client::inst() {
static auto c = new Client();
static auto *c = new Client();
return c;
}
void waybar::Client::handleGlobal(void *data, struct wl_registry *registry, uint32_t name,
const char *interface, uint32_t version) {
auto client = static_cast<Client *>(data);
auto *client = static_cast<Client *>(data);
if (strcmp(interface, zxdg_output_manager_v1_interface.name) == 0 &&
version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) {
client->xdg_output_manager = static_cast<struct zxdg_output_manager_v1 *>(wl_registry_bind(
@ -42,7 +43,7 @@ void waybar::Client::handleOutput(struct waybar_output &output) {
.description = &handleOutputDescription,
};
// owned by output->monitor; no need to destroy
auto wl_output = gdk_wayland_monitor_get_wl_output(output.monitor->gobj());
auto *wl_output = gdk_wayland_monitor_get_wl_output(output.monitor->gobj());
output.xdg_output.reset(zxdg_output_manager_v1_get_xdg_output(xdg_output_manager, wl_output));
zxdg_output_v1_add_listener(output.xdg_output.get(), &xdgOutputListener, &output);
}
@ -61,7 +62,7 @@ std::vector<Json::Value> waybar::Client::getOutputConfigs(struct waybar_output &
}
void waybar::Client::handleOutputDone(void *data, struct zxdg_output_v1 * /*xdg_output*/) {
auto client = waybar::Client::inst();
auto *client = waybar::Client::inst();
try {
auto &output = client->getOutput(data);
/**
@ -85,24 +86,24 @@ void waybar::Client::handleOutputDone(void *data, struct zxdg_output_v1 * /*xdg_
}
}
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
}
}
void waybar::Client::handleOutputName(void *data, struct zxdg_output_v1 * /*xdg_output*/,
const char *name) {
auto client = waybar::Client::inst();
auto *client = waybar::Client::inst();
try {
auto &output = client->getOutput(data);
output.name = name;
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
}
}
void waybar::Client::handleOutputDescription(void *data, struct zxdg_output_v1 * /*xdg_output*/,
const char *description) {
auto client = waybar::Client::inst();
auto *client = waybar::Client::inst();
try {
auto &output = client->getOutput(data);
const char *open_paren = strrchr(description, '(');
@ -111,13 +112,13 @@ void waybar::Client::handleOutputDescription(void *data, struct zxdg_output_v1 *
size_t identifier_length = open_paren - description;
output.identifier = std::string(description, identifier_length - 1);
} catch (const std::exception &e) {
std::cerr << e.what() << std::endl;
std::cerr << e.what() << '\n';
}
}
void waybar::Client::handleMonitorAdded(Glib::RefPtr<Gdk::Monitor> monitor) {
auto &output = outputs_.emplace_back();
output.monitor = monitor;
output.monitor = std::move(monitor);
handleOutput(output);
}
@ -154,15 +155,15 @@ const std::string waybar::Client::getStyle(const std::string &style,
std::vector<std::string> search_files;
switch (appearance.value_or(portal->getAppearance())) {
case waybar::Appearance::LIGHT:
search_files.push_back("style-light.css");
search_files.emplace_back("style-light.css");
break;
case waybar::Appearance::DARK:
search_files.push_back("style-dark.css");
search_files.emplace_back("style-dark.css");
break;
case waybar::Appearance::UNKNOWN:
break;
}
search_files.push_back("style.css");
search_files.emplace_back("style.css");
css_file = Config::findConfigPath(search_files);
} else {
css_file = style;
@ -196,7 +197,7 @@ void waybar::Client::bindInterfaces() {
wl_registry_add_listener(registry, &registry_listener, this);
wl_display_roundtrip(wl_display);
if (!gtk_layer_is_supported()) {
if (gtk_layer_is_supported() == 0) {
throw std::runtime_error("The Wayland compositor does not support wlr-layer-shell protocol");
}
@ -233,11 +234,11 @@ int waybar::Client::main(int argc, char *argv[]) {
return 1;
}
if (show_help) {
std::cout << cli << std::endl;
std::cout << cli << '\n';
return 0;
}
if (show_version) {
std::cout << "Waybar v" << VERSION << std::endl;
std::cout << "Waybar v" << VERSION << '\n';
return 0;
}
if (!log_level.empty()) {