Merge branch 'master' into fmt

This commit is contained in:
Alex
2019-08-29 11:29:48 +02:00
committed by GitHub
28 changed files with 1858 additions and 16 deletions

View File

@ -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++) {

View File

@ -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;
});

View File

@ -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));

View File

@ -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();
}