mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
Merge branch 'master' into fmt
This commit is contained in:
@ -201,8 +201,9 @@ void waybar::modules::Network::worker() {
|
||||
}
|
||||
thread_timer_.sleep_for(interval_);
|
||||
};
|
||||
std::array<struct epoll_event, EPOLL_MAX> events{};
|
||||
thread_ = [this, &events] {
|
||||
thread_ = [this] {
|
||||
std::array<struct epoll_event, EPOLL_MAX> events{};
|
||||
|
||||
int ec = epoll_wait(efd_, events.data(), EPOLL_MAX, -1);
|
||||
if (ec > 0) {
|
||||
for (auto i = 0; i < ec; i++) {
|
||||
|
@ -130,7 +130,8 @@ std::tuple<std::string, std::string> Host::getBusNameAndObjectPath(const std::st
|
||||
}
|
||||
|
||||
void Host::addRegisteredItem(std::string service) {
|
||||
auto [bus_name, object_path] = getBusNameAndObjectPath(service);
|
||||
std::string bus_name, object_path;
|
||||
std::tie(bus_name, object_path) = getBusNameAndObjectPath(service);
|
||||
auto it = std::find_if(items_.begin(), items_.end(), [&bus_name, &object_path](const auto& item) {
|
||||
return bus_name == item->bus_name && object_path == item->object_path;
|
||||
});
|
||||
|
@ -128,6 +128,7 @@ void Item::setProperty(const Glib::ustring& name, Glib::VariantBase& value) {
|
||||
}
|
||||
} else if (name == "Menu") {
|
||||
menu = get_variant<std::string>(value);
|
||||
makeMenu();
|
||||
} else if (name == "ItemIsMenu") {
|
||||
item_is_menu = get_variant<bool>(value);
|
||||
}
|
||||
@ -319,7 +320,7 @@ void Item::onMenuDestroyed(Item* self, GObject* old_menu_pointer) {
|
||||
}
|
||||
}
|
||||
|
||||
void Item::makeMenu(GdkEventButton* const& ev) {
|
||||
void Item::makeMenu() {
|
||||
if (gtk_menu == nullptr && !menu.empty()) {
|
||||
dbus_menu = dbusmenu_gtkmenu_new(bus_name.data(), menu.data());
|
||||
if (dbus_menu != nullptr) {
|
||||
@ -334,8 +335,8 @@ void Item::makeMenu(GdkEventButton* const& ev) {
|
||||
bool Item::handleClick(GdkEventButton* const& ev) {
|
||||
auto parameters = Glib::VariantContainerBase::create_tuple(
|
||||
{Glib::Variant<int>::create(ev->x), Glib::Variant<int>::create(ev->y)});
|
||||
if ((ev->button == 1 && (item_is_menu || !menu.empty())) || ev->button == 3) {
|
||||
makeMenu(ev);
|
||||
if ((ev->button == 1 && item_is_menu) || ev->button == 3) {
|
||||
makeMenu();
|
||||
if (gtk_menu != nullptr) {
|
||||
#if GTK_CHECK_VERSION(3, 22, 0)
|
||||
gtk_menu->popup_at_pointer(reinterpret_cast<GdkEvent*>(ev));
|
||||
|
@ -17,7 +17,11 @@ void Mode::onEvent(const struct Ipc::ipc_response& res) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
auto payload = parser_.parse(res.payload);
|
||||
if (payload["change"] != "default") {
|
||||
mode_ = Glib::Markup::escape_text(payload["change"].asString());
|
||||
if (payload["pango_markup"].asBool()) {
|
||||
mode_ = payload["change"].asString();
|
||||
} else {
|
||||
mode_ = Glib::Markup::escape_text(payload["change"].asString());
|
||||
}
|
||||
} else {
|
||||
mode_.clear();
|
||||
}
|
||||
|
Reference in New Issue
Block a user