mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Don't subscribe to inhibiton changes when not supported
This commit is contained in:
parent
f9dd2b4a0a
commit
b4d310fd1e
1 changed files with 39 additions and 42 deletions
|
@ -258,11 +258,6 @@ void GetCapabilities(Fn<void(const QStringList &)> callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetInhibited(Fn<void(bool)> callback) {
|
void GetInhibited(Fn<void(bool)> callback) {
|
||||||
if (!CurrentCapabilities.contains(qsl("inhibitions"))) {
|
|
||||||
crl::on_main([=] { callback(false); });
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Noexcept([&] {
|
Noexcept([&] {
|
||||||
const auto connection = Gio::DBus::Connection::get_sync(
|
const auto connection = Gio::DBus::Connection::get_sync(
|
||||||
Gio::DBus::BusType::SESSION);
|
Gio::DBus::BusType::SESSION);
|
||||||
|
@ -947,50 +942,52 @@ Manager::Private::Private(not_null<Manager*> manager, Type type)
|
||||||
.arg(capabilities.join(", ")));
|
.arg(capabilities.join(", ")));
|
||||||
}
|
}
|
||||||
|
|
||||||
Noexcept([&] {
|
if (capabilities.contains(qsl("inhibitions"))) {
|
||||||
_dbusConnection = Gio::DBus::Connection::get_sync(
|
Noexcept([&] {
|
||||||
Gio::DBus::BusType::SESSION);
|
_dbusConnection = Gio::DBus::Connection::get_sync(
|
||||||
});
|
Gio::DBus::BusType::SESSION);
|
||||||
|
});
|
||||||
|
|
||||||
if (!_dbusConnection) {
|
if (!_dbusConnection) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto weak = base::make_weak(this);
|
const auto weak = base::make_weak(this);
|
||||||
GetInhibited(crl::guard(weak, [=](bool result) {
|
GetInhibited(crl::guard(weak, [=](bool result) {
|
||||||
_inhibited = result;
|
_inhibited = result;
|
||||||
}));
|
}));
|
||||||
|
|
||||||
_inhibitedSignalId = _dbusConnection->signal_subscribe(
|
_inhibitedSignalId = _dbusConnection->signal_subscribe(
|
||||||
[=](
|
[=](
|
||||||
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
const Glib::RefPtr<Gio::DBus::Connection> &connection,
|
||||||
const Glib::ustring &sender_name,
|
const Glib::ustring &sender_name,
|
||||||
const Glib::ustring &object_path,
|
const Glib::ustring &object_path,
|
||||||
const Glib::ustring &interface_name,
|
const Glib::ustring &interface_name,
|
||||||
const Glib::ustring &signal_name,
|
const Glib::ustring &signal_name,
|
||||||
Glib::VariantContainerBase parameters) {
|
Glib::VariantContainerBase parameters) {
|
||||||
Noexcept([&] {
|
Noexcept([&] {
|
||||||
const auto interface = GlibVariantCast<Glib::ustring>(
|
const auto interface = GlibVariantCast<Glib::ustring>(
|
||||||
parameters.get_child(0));
|
parameters.get_child(0));
|
||||||
|
|
||||||
if (interface != kInterface.data()) {
|
if (interface != kInterface.data()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto inhibited = GlibVariantCast<bool>(
|
const auto inhibited = GlibVariantCast<bool>(
|
||||||
GlibVariantCast<
|
GlibVariantCast<
|
||||||
std::map<Glib::ustring, Glib::VariantBase>
|
std::map<Glib::ustring, Glib::VariantBase>
|
||||||
>(parameters.get_child(1)).at("Inhibited"));
|
>(parameters.get_child(1)).at("Inhibited"));
|
||||||
|
|
||||||
crl::on_main(weak, [=] {
|
crl::on_main(weak, [=] {
|
||||||
_inhibited = inhibited;
|
_inhibited = inhibited;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
},
|
||||||
},
|
std::string(kService),
|
||||||
std::string(kService),
|
std::string(kPropertiesInterface),
|
||||||
std::string(kPropertiesInterface),
|
"PropertiesChanged",
|
||||||
"PropertiesChanged",
|
std::string(kObjectPath));
|
||||||
std::string(kObjectPath));
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Manager::Private::showNotification(
|
void Manager::Private::showNotification(
|
||||||
|
|
Loading…
Add table
Reference in a new issue