chore: upgrade to clang-format@21

This commit is contained in:
Alex
2026-02-04 09:24:14 +01:00
parent 6cecaf56b9
commit 47fb21a2c1
75 changed files with 1294 additions and 1297 deletions

View File

@ -69,8 +69,8 @@ void AudioBackend::connectContext() {
}
}
void AudioBackend::contextStateCb(pa_context *c, void *data) {
auto *backend = static_cast<AudioBackend *>(data);
void AudioBackend::contextStateCb(pa_context* c, void* data) {
auto* backend = static_cast<AudioBackend*>(data);
switch (pa_context_get_state(c)) {
case PA_CONTEXT_TERMINATED:
backend->mainloop_api_->quit(backend->mainloop_api_, 0);
@ -107,8 +107,8 @@ void AudioBackend::contextStateCb(pa_context *c, void *data) {
/*
* Called when an event we subscribed to occurs.
*/
void AudioBackend::subscribeCb(pa_context *context, pa_subscription_event_type_t type, uint32_t idx,
void *data) {
void AudioBackend::subscribeCb(pa_context* context, pa_subscription_event_type_t type, uint32_t idx,
void* data) {
unsigned facility = type & PA_SUBSCRIPTION_EVENT_FACILITY_MASK;
unsigned operation = type & PA_SUBSCRIPTION_EVENT_TYPE_MASK;
if (operation != PA_SUBSCRIPTION_EVENT_CHANGE) {
@ -130,8 +130,8 @@ void AudioBackend::subscribeCb(pa_context *context, pa_subscription_event_type_t
/*
* Called in response to a volume change request
*/
void AudioBackend::volumeModifyCb(pa_context *c, int success, void *data) {
auto *backend = static_cast<AudioBackend *>(data);
void AudioBackend::volumeModifyCb(pa_context* c, int success, void* data) {
auto* backend = static_cast<AudioBackend*>(data);
if (success != 0) {
if ((backend->context_ != nullptr) &&
pa_context_get_state(backend->context_) == PA_CONTEXT_READY) {
@ -145,18 +145,18 @@ void AudioBackend::volumeModifyCb(pa_context *c, int success, void *data) {
/*
* Called when the requested sink information is ready.
*/
void AudioBackend::sinkInfoCb(pa_context * /*context*/, const pa_sink_info *i, int /*eol*/,
void *data) {
void AudioBackend::sinkInfoCb(pa_context* /*context*/, const pa_sink_info* i, int /*eol*/,
void* data) {
if (i == nullptr) return;
auto running = i->state == PA_SINK_RUNNING;
auto idle = i->state == PA_SINK_IDLE;
spdlog::trace("Sink name {} Running:[{}] Idle:[{}]", i->name, running, idle);
auto *backend = static_cast<AudioBackend *>(data);
auto* backend = static_cast<AudioBackend*>(data);
if (!backend->ignored_sinks_.empty()) {
for (const auto &ignored_sink : backend->ignored_sinks_) {
for (const auto& ignored_sink : backend->ignored_sinks_) {
if (ignored_sink == i->description) {
if (i->name == backend->current_sink_name_) {
// If the current sink happens to be ignored it is never considered running
@ -205,7 +205,7 @@ void AudioBackend::sinkInfoCb(pa_context * /*context*/, const pa_sink_info *i, i
backend->desc_ = i->description;
backend->monitor_ = i->monitor_source_name;
backend->port_name_ = i->active_port != nullptr ? i->active_port->name : "Unknown";
if (const auto *ff = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_FORM_FACTOR)) {
if (const auto* ff = pa_proplist_gets(i->proplist, PA_PROP_DEVICE_FORM_FACTOR)) {
backend->form_factor_ = ff;
} else {
backend->form_factor_ = "";
@ -217,9 +217,9 @@ void AudioBackend::sinkInfoCb(pa_context * /*context*/, const pa_sink_info *i, i
/*
* Called when the requested source information is ready.
*/
void AudioBackend::sourceInfoCb(pa_context * /*context*/, const pa_source_info *i, int /*eol*/,
void *data) {
auto *backend = static_cast<AudioBackend *>(data);
void AudioBackend::sourceInfoCb(pa_context* /*context*/, const pa_source_info* i, int /*eol*/,
void* data) {
auto* backend = static_cast<AudioBackend*>(data);
if (i != nullptr && backend->default_source_name_ == i->name) {
auto source_volume = static_cast<float>(pa_cvolume_avg(&(i->volume))) / float{PA_VOLUME_NORM};
backend->source_volume_ = std::round(source_volume * 100.0F);
@ -235,8 +235,8 @@ void AudioBackend::sourceInfoCb(pa_context * /*context*/, const pa_source_info *
* Called when the requested information on the server is ready. This is
* used to find the default PulseAudio sink.
*/
void AudioBackend::serverInfoCb(pa_context *context, const pa_server_info *i, void *data) {
auto *backend = static_cast<AudioBackend *>(data);
void AudioBackend::serverInfoCb(pa_context* context, const pa_server_info* i, void* data) {
auto* backend = static_cast<AudioBackend*>(data);
backend->current_sink_name_ = i->default_sink_name;
backend->default_sink_name = i->default_sink_name;
backend->default_source_name_ = i->default_source_name;
@ -392,9 +392,9 @@ bool AudioBackend::isBluetooth() {
monitor_.find("bluez") != std::string::npos;
}
void AudioBackend::setIgnoredSinks(const Json::Value &config) {
void AudioBackend::setIgnoredSinks(const Json::Value& config) {
if (config.isArray()) {
for (const auto &ignored_sink : config) {
for (const auto& ignored_sink : config) {
if (ignored_sink.isString()) {
ignored_sinks_.push_back(ignored_sink.asString());
}

View File

@ -14,10 +14,10 @@ namespace {
class FileDescriptor {
public:
explicit FileDescriptor(int fd) : fd_(fd) {}
FileDescriptor(const FileDescriptor &other) = delete;
FileDescriptor(FileDescriptor &&other) noexcept = delete;
FileDescriptor &operator=(const FileDescriptor &other) = delete;
FileDescriptor &operator=(FileDescriptor &&other) noexcept = delete;
FileDescriptor(const FileDescriptor& other) = delete;
FileDescriptor(FileDescriptor&& other) noexcept = delete;
FileDescriptor& operator=(const FileDescriptor& other) = delete;
FileDescriptor& operator=(FileDescriptor&& other) noexcept = delete;
~FileDescriptor() {
if (fd_ != -1) {
if (close(fd_) != 0) {
@ -31,27 +31,27 @@ class FileDescriptor {
int fd_;
};
void check_eq(int rc, int expected, const char *message = "eq, rc was: ") {
void check_eq(int rc, int expected, const char* message = "eq, rc was: ") {
if (rc != expected) {
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));
}
}
void check_neq(int rc, int bad_rc, const char *message = "neq, rc was: ") {
void check_neq(int rc, int bad_rc, const char* message = "neq, rc was: ") {
if (rc == bad_rc) {
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));
}
}
void check0(int rc, const char *message = "rc wasn't 0") { check_eq(rc, 0, message); }
void check0(int rc, const char* message = "rc wasn't 0") { check_eq(rc, 0, message); }
void check_gte(int rc, int gte, const char *message = "rc was: ") {
void check_gte(int rc, int gte, const char* message = "rc was: ") {
if (rc < gte) {
throw std::runtime_error(fmt::format(fmt::runtime(message), rc));
}
}
void check_nn(const void *ptr, const char *message = "ptr was null") {
void check_nn(const void* ptr, const char* message = "ptr was null") {
if (ptr == nullptr) {
throw std::runtime_error(message);
}
@ -61,20 +61,20 @@ void check_nn(const void *ptr, const char *message = "ptr was null") {
namespace waybar::util {
static void upsert_device(std::vector<BacklightDevice> &devices, udev_device *dev) {
const char *name = udev_device_get_sysname(dev);
static void upsert_device(std::vector<BacklightDevice>& devices, udev_device* dev) {
const char* name = udev_device_get_sysname(dev);
check_nn(name);
const char *actual_brightness_attr =
const char* actual_brightness_attr =
strncmp(name, "amdgpu_bl", 9) == 0 || strcmp(name, "apple-panel-bl") == 0
? "brightness"
: "actual_brightness";
const char *actual = udev_device_get_sysattr_value(dev, actual_brightness_attr);
const char *max = udev_device_get_sysattr_value(dev, "max_brightness");
const char *power = udev_device_get_sysattr_value(dev, "bl_power");
const char* actual = udev_device_get_sysattr_value(dev, actual_brightness_attr);
const char* max = udev_device_get_sysattr_value(dev, "max_brightness");
const char* power = udev_device_get_sysattr_value(dev, "bl_power");
auto found = std::find_if(devices.begin(), devices.end(), [name](const BacklightDevice &device) {
auto found = std::find_if(devices.begin(), devices.end(), [name](const BacklightDevice& device) {
return device.name() == name;
});
if (found != devices.end()) {
@ -95,14 +95,14 @@ static void upsert_device(std::vector<BacklightDevice> &devices, udev_device *de
}
}
static void enumerate_devices(std::vector<BacklightDevice> &devices, udev *udev) {
static void enumerate_devices(std::vector<BacklightDevice>& devices, udev* udev) {
std::unique_ptr<udev_enumerate, UdevEnumerateDeleter> enumerate{udev_enumerate_new(udev)};
udev_enumerate_add_match_subsystem(enumerate.get(), "backlight");
udev_enumerate_scan_devices(enumerate.get());
udev_list_entry *enum_devices = udev_enumerate_get_list_entry(enumerate.get());
udev_list_entry *dev_list_entry;
udev_list_entry* enum_devices = udev_enumerate_get_list_entry(enumerate.get());
udev_list_entry* dev_list_entry;
udev_list_entry_foreach(dev_list_entry, enum_devices) {
const char *path = udev_list_entry_get_name(dev_list_entry);
const char* path = udev_list_entry_get_name(dev_list_entry);
std::unique_ptr<udev_device, UdevDeviceDeleter> dev{udev_device_new_from_syspath(udev, path)};
check_nn(dev.get(), "dev new failed");
upsert_device(devices, dev.get());
@ -184,7 +184,7 @@ BacklightBackend::BacklightBackend(std::chrono::milliseconds interval,
devices = devices_;
}
for (int i = 0; i < event_count; ++i) {
const auto &event = events[i];
const auto& event = events[i];
check_eq(event.data.fd, udev_fd, "unexpected udev fd");
std::unique_ptr<udev_device, UdevDeviceDeleter> dev{udev_monitor_receive_device(mon.get())};
if (!dev) {
@ -206,27 +206,27 @@ BacklightBackend::BacklightBackend(std::chrono::milliseconds interval,
};
}
const BacklightDevice *BacklightBackend::best_device(const std::vector<BacklightDevice> &devices,
const BacklightDevice* BacklightBackend::best_device(const std::vector<BacklightDevice>& devices,
std::string_view preferred_device) {
const auto found = std::find_if(
devices.begin(), devices.end(),
[preferred_device](const BacklightDevice &dev) { return dev.name() == preferred_device; });
[preferred_device](const BacklightDevice& dev) { return dev.name() == preferred_device; });
if (found != devices.end()) {
return &(*found);
}
const auto max = std::max_element(
devices.begin(), devices.end(),
[](const BacklightDevice &l, const BacklightDevice &r) { return l.get_max() < r.get_max(); });
[](const BacklightDevice& l, const BacklightDevice& r) { return l.get_max() < r.get_max(); });
return max == devices.end() ? nullptr : &(*max);
}
const BacklightDevice *BacklightBackend::get_previous_best_device() {
const BacklightDevice* BacklightBackend::get_previous_best_device() {
return previous_best_.has_value() ? &(*previous_best_) : nullptr;
}
void BacklightBackend::set_previous_best_device(const BacklightDevice *device) {
void BacklightBackend::set_previous_best_device(const BacklightDevice* device) {
if (device == nullptr) {
previous_best_ = std::nullopt;
} else {
@ -234,7 +234,7 @@ void BacklightBackend::set_previous_best_device(const BacklightDevice *device) {
}
}
void BacklightBackend::set_scaled_brightness(const std::string &preferred_device, int brightness) {
void BacklightBackend::set_scaled_brightness(const std::string& preferred_device, int brightness) {
GET_BEST_DEVICE(best, (*this), preferred_device);
if (best != nullptr) {
@ -244,7 +244,7 @@ void BacklightBackend::set_scaled_brightness(const std::string &preferred_device
}
}
void BacklightBackend::set_brightness(const std::string &preferred_device, ChangeType change_type,
void BacklightBackend::set_brightness(const std::string& preferred_device, ChangeType change_type,
double step) {
GET_BEST_DEVICE(best, (*this), preferred_device);
@ -259,7 +259,7 @@ void BacklightBackend::set_brightness(const std::string &preferred_device, Chang
}
}
void BacklightBackend::set_brightness_internal(const std::string &device_name, int brightness,
void BacklightBackend::set_brightness_internal(const std::string& device_name, int brightness,
int max_brightness) {
brightness = std::clamp(brightness, 0, max_brightness);
@ -269,7 +269,7 @@ void BacklightBackend::set_brightness_internal(const std::string &device_name, i
login_proxy_->call_sync("SetBrightness", call_args);
}
int BacklightBackend::get_scaled_brightness(const std::string &preferred_device) {
int BacklightBackend::get_scaled_brightness(const std::string& preferred_device) {
GET_BEST_DEVICE(best, (*this), preferred_device);
if (best != nullptr) {

View File

@ -26,12 +26,12 @@ std::vector<std::string> IconLoader::search_prefix() {
} while (end != std::string::npos);
}
for (auto &p : prefixes) spdlog::debug("Using 'desktop' search path prefix: {}", p);
for (auto& p : prefixes) spdlog::debug("Using 'desktop' search path prefix: {}", p);
return prefixes;
}
Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_app_info_by_name(const std::string &app_id) {
Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_app_info_by_name(const std::string& app_id) {
static std::vector<std::string> prefixes = search_prefix();
std::vector<std::string> app_folders = {"", "applications/", "applications/kde/",
@ -39,9 +39,9 @@ Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_app_info_by_name(const std::st
std::vector<std::string> suffixes = {"", ".desktop"};
for (auto const &prefix : prefixes) {
for (auto const &folder : app_folders) {
for (auto const &suffix : suffixes) {
for (auto const& prefix : prefixes) {
for (auto const& folder : app_folders) {
for (auto const& suffix : suffixes) {
auto app_info_ =
Gio::DesktopAppInfo::create_from_filename(prefix + folder + app_id + suffix);
if (!app_info_) {
@ -56,7 +56,7 @@ Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_app_info_by_name(const std::st
return {};
}
Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_desktop_app_info(const std::string &app_id) {
Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_desktop_app_info(const std::string& app_id) {
auto app_info = get_app_info_by_name(app_id);
if (app_info) {
return app_info;
@ -64,7 +64,7 @@ Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_desktop_app_info(const std::st
std::string desktop_file = "";
gchar ***desktop_list = g_desktop_app_info_search(app_id.c_str());
gchar*** desktop_list = g_desktop_app_info_search(app_id.c_str());
if (desktop_list != nullptr && desktop_list[0] != nullptr) {
for (size_t i = 0; desktop_list[0][i]; i++) {
if (desktop_file == "") {
@ -89,7 +89,7 @@ Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_desktop_app_info(const std::st
return get_app_info_by_name(desktop_file);
}
Glib::RefPtr<Gdk::Pixbuf> IconLoader::load_icon_from_file(std::string const &icon_path, int size) {
Glib::RefPtr<Gdk::Pixbuf> IconLoader::load_icon_from_file(std::string const& icon_path, int size) {
try {
auto pb = Gdk::Pixbuf::create_from_file(icon_path, size, size);
return pb;
@ -99,13 +99,13 @@ Glib::RefPtr<Gdk::Pixbuf> IconLoader::load_icon_from_file(std::string const &ico
}
std::string IconLoader::get_icon_name_from_icon_theme(
const Glib::RefPtr<Gtk::IconTheme> &icon_theme, const std::string &app_id) {
const Glib::RefPtr<Gtk::IconTheme>& icon_theme, const std::string& app_id) {
if (icon_theme->lookup_icon(app_id, 24)) return app_id;
return "";
}
bool IconLoader::image_load_icon(Gtk::Image &image, const Glib::RefPtr<Gtk::IconTheme> &icon_theme,
bool IconLoader::image_load_icon(Gtk::Image& image, const Glib::RefPtr<Gtk::IconTheme>& icon_theme,
Glib::RefPtr<Gio::DesktopAppInfo> app_info, int size) {
std::string ret_icon_name = "unknown";
if (app_info) {
@ -152,16 +152,16 @@ bool IconLoader::image_load_icon(Gtk::Image &image, const Glib::RefPtr<Gtk::Icon
return false;
}
void IconLoader::add_custom_icon_theme(const std::string &theme_name) {
void IconLoader::add_custom_icon_theme(const std::string& theme_name) {
auto icon_theme = Gtk::IconTheme::create();
icon_theme->set_custom_theme(theme_name);
custom_icon_themes_.push_back(icon_theme);
spdlog::debug("Use custom icon theme: {}", theme_name);
}
bool IconLoader::image_load_icon(Gtk::Image &image, Glib::RefPtr<Gio::DesktopAppInfo> app_info,
bool IconLoader::image_load_icon(Gtk::Image& image, Glib::RefPtr<Gio::DesktopAppInfo> app_info,
int size) const {
for (auto &icon_theme : custom_icon_themes_) {
for (auto& icon_theme : custom_icon_themes_) {
if (image_load_icon(image, icon_theme, app_info, size)) {
return true;
}
@ -170,7 +170,7 @@ bool IconLoader::image_load_icon(Gtk::Image &image, Glib::RefPtr<Gio::DesktopApp
}
Glib::RefPtr<Gio::DesktopAppInfo> IconLoader::get_app_info_from_app_id_list(
const std::string &app_id_list) {
const std::string& app_id_list) {
std::string app_id;
std::istringstream stream(app_id_list);
Glib::RefPtr<Gio::DesktopAppInfo> app_info_;

View File

@ -4,11 +4,11 @@
namespace waybar::util::PipewireBackend {
static void getNodeInfo(void *data_, const struct pw_node_info *info) {
auto *pNodeInfo = static_cast<PrivacyNodeInfo *>(data_);
static void getNodeInfo(void* data_, const struct pw_node_info* info) {
auto* pNodeInfo = static_cast<PrivacyNodeInfo*>(data_);
pNodeInfo->handleNodeEventInfo(info);
static_cast<PipewireBackend *>(pNodeInfo->data)->privacy_nodes_changed_signal_event.emit();
static_cast<PipewireBackend*>(pNodeInfo->data)->privacy_nodes_changed_signal_event.emit();
}
static const struct pw_node_events NODE_EVENTS = {
@ -16,8 +16,8 @@ static const struct pw_node_events NODE_EVENTS = {
.info = getNodeInfo,
};
static void proxyDestroy(void *data) {
static_cast<PrivacyNodeInfo *>(data)->handleProxyEventDestroy();
static void proxyDestroy(void* data) {
static_cast<PrivacyNodeInfo*>(data)->handleProxyEventDestroy();
}
static const struct pw_proxy_events PROXY_EVENTS = {
@ -25,14 +25,14 @@ static const struct pw_proxy_events PROXY_EVENTS = {
.destroy = proxyDestroy,
};
static void registryEventGlobal(void *_data, uint32_t id, uint32_t permissions, const char *type,
uint32_t version, const struct spa_dict *props) {
static_cast<PipewireBackend *>(_data)->handleRegistryEventGlobal(id, permissions, type, version,
props);
static void registryEventGlobal(void* _data, uint32_t id, uint32_t permissions, const char* type,
uint32_t version, const struct spa_dict* props) {
static_cast<PipewireBackend*>(_data)->handleRegistryEventGlobal(id, permissions, type, version,
props);
}
static void registryEventGlobalRemove(void *_data, uint32_t id) {
static_cast<PipewireBackend *>(_data)->handleRegistryEventGlobalRemove(id);
static void registryEventGlobalRemove(void* _data, uint32_t id) {
static_cast<PipewireBackend*>(_data)->handleRegistryEventGlobalRemove(id);
}
static const struct pw_registry_events REGISTRY_EVENTS = {
@ -78,7 +78,7 @@ PipewireBackend::~PipewireBackend() {
}
if (registry_ != nullptr) {
pw_proxy_destroy((struct pw_proxy *)registry_);
pw_proxy_destroy((struct pw_proxy*)registry_);
}
spa_zero(registryListener_);
@ -103,11 +103,11 @@ std::shared_ptr<PipewireBackend> PipewireBackend::getInstance() {
return std::make_shared<PipewireBackend>(tag);
}
void PipewireBackend::handleRegistryEventGlobal(uint32_t id, uint32_t permissions, const char *type,
uint32_t version, const struct spa_dict *props) {
void PipewireBackend::handleRegistryEventGlobal(uint32_t id, uint32_t permissions, const char* type,
uint32_t version, const struct spa_dict* props) {
if (props == nullptr || strcmp(type, PW_TYPE_INTERFACE_Node) != 0) return;
const char *lookupStr = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
const char* lookupStr = spa_dict_lookup(props, PW_KEY_MEDIA_CLASS);
if (lookupStr == nullptr) return;
std::string mediaClass = lookupStr;
enum PrivacyNodeType mediaType = PRIVACY_NODE_TYPE_NONE;
@ -121,11 +121,11 @@ void PipewireBackend::handleRegistryEventGlobal(uint32_t id, uint32_t permission
return;
}
auto *proxy = (pw_proxy *)pw_registry_bind(registry_, id, type, version, sizeof(PrivacyNodeInfo));
auto* proxy = (pw_proxy*)pw_registry_bind(registry_, id, type, version, sizeof(PrivacyNodeInfo));
if (proxy == nullptr) return;
auto *pNodeInfo = (PrivacyNodeInfo *)pw_proxy_get_user_data(proxy);
auto* pNodeInfo = (PrivacyNodeInfo*)pw_proxy_get_user_data(proxy);
new (pNodeInfo) PrivacyNodeInfo{};
pNodeInfo->id = id;
pNodeInfo->data = this;

View File

@ -3,9 +3,9 @@
namespace waybar::util::PipewireBackend {
std::string PrivacyNodeInfo::getName() {
const std::vector<std::string *> names{&application_name, &node_name};
const std::vector<std::string*> names{&application_name, &node_name};
std::string name = "Unknown Application";
for (const auto &item : names) {
for (const auto& item : names) {
if (item != nullptr && !item->empty()) {
name = *item;
name[0] = toupper(name[0]);
@ -16,10 +16,10 @@ std::string PrivacyNodeInfo::getName() {
}
std::string PrivacyNodeInfo::getIconName() {
const std::vector<std::string *> names{&application_icon_name, &pipewire_access_portal_app_id,
&application_name, &node_name};
const std::vector<std::string*> names{&application_icon_name, &pipewire_access_portal_app_id,
&application_name, &node_name};
std::string name = "application-x-executable-symbolic";
for (const auto &item : names) {
for (const auto& item : names) {
if (item != nullptr && !item->empty() && DefaultGtkIconThemeWrapper::has_icon(*item)) {
return *item;
}
@ -32,10 +32,10 @@ void PrivacyNodeInfo::handleProxyEventDestroy() {
spa_hook_remove(&object_listener);
}
void PrivacyNodeInfo::handleNodeEventInfo(const struct pw_node_info *info) {
void PrivacyNodeInfo::handleNodeEventInfo(const struct pw_node_info* info) {
state = info->state;
const struct spa_dict_item *item;
const struct spa_dict_item* item;
spa_dict_for_each(item, info->props) {
if (strcmp(item->key, PW_KEY_CLIENT_ID) == 0) {
client_id = strtoul(item->value, nullptr, 10);

View File

@ -18,21 +18,21 @@ class PrepareForSleep {
}
}
static void prepareForSleep_cb(GDBusConnection *system_bus, const gchar *sender_name,
const gchar *object_path, const gchar *interface_name,
const gchar *signal_name, GVariant *parameters,
static void prepareForSleep_cb(GDBusConnection* system_bus, const gchar* sender_name,
const gchar* object_path, const gchar* interface_name,
const gchar* signal_name, GVariant* parameters,
gpointer user_data) {
if (g_variant_is_of_type(parameters, G_VARIANT_TYPE("(b)")) != 0) {
gboolean sleeping;
g_variant_get(parameters, "(b)", &sleeping);
auto *self = static_cast<PrepareForSleep *>(user_data);
auto* self = static_cast<PrepareForSleep*>(user_data);
self->signal.emit(sleeping);
}
}
public:
static PrepareForSleep &GetInstance() {
static PrepareForSleep& GetInstance() {
static PrepareForSleep instance;
return instance;
}
@ -40,10 +40,10 @@ class PrepareForSleep {
private:
guint login1_id;
GDBusConnection *login1_connection;
GDBusConnection* login1_connection;
};
} // namespace
waybar::SafeSignal<bool> &waybar::util::prepare_for_sleep() {
waybar::SafeSignal<bool>& waybar::util::prepare_for_sleep() {
return PrepareForSleep::GetInstance().signal;
}

View File

@ -1,6 +1,6 @@
#include "util/ustring_clen.hpp"
int ustring_clen(const Glib::ustring &str) {
int ustring_clen(const Glib::ustring& str) {
int total = 0;
for (unsigned int i : str) {
total += g_unichar_iswide(i) + 1;