Fix device list not being updated on selecting new bluetooth controller

This commit is contained in:
Lukas Fink 2024-06-14 14:00:55 +02:00
parent ab91d0bac3
commit 0df3c84c0f
1 changed files with 12 additions and 3 deletions

View File

@ -301,16 +301,25 @@ auto waybar::modules::Bluetooth::onObjectAdded(GDBusObjectManager* manager,
auto waybar::modules::Bluetooth::onObjectRemoved(GDBusObjectManager* manager, auto waybar::modules::Bluetooth::onObjectRemoved(GDBusObjectManager* manager,
GDBusObject* object, GDBusObject* object,
gpointer user_data) -> void { gpointer user_data) -> void {
GDBusProxy* proxy_controller = Bluetooth* bt = static_cast<Bluetooth*>(user_data);
G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Adapter1")); GDBusProxy* proxy_controller;
if (!bt->cur_controller_.has_value()) {
return;
}
proxy_controller = G_DBUS_PROXY(g_dbus_object_get_interface(object, "org.bluez.Adapter1"));
if (proxy_controller != NULL) { if (proxy_controller != NULL) {
std::string object_path = g_dbus_object_get_object_path(object); std::string object_path = g_dbus_object_get_object_path(object);
Bluetooth* bt = static_cast<Bluetooth*>(user_data);
if (object_path == bt->cur_controller_->path) { if (object_path == bt->cur_controller_->path) {
bt->cur_controller_ = bt->findCurController(); bt->cur_controller_ = bt->findCurController();
if (bt->cur_controller_.has_value()) {
bt->connected_devices_.clear();
bt->findConnectedDevices(bt->cur_controller_->path, bt->connected_devices_);
}
bt->dp.emit(); bt->dp.emit();
} }