| 59 | .global_remove = handle_global_remove}; |
| 60 | |
| 61 | Mode::Mode(const std::string& id, const waybar::Bar& bar, const Json::Value& config) |
| 62 | : waybar::ALabel(config, "mode", id, "{}"), |
| 63 | status_manager_{nullptr}, |
| 64 | seat_{nullptr}, |
| 65 | bar_(bar), |
| 66 | mode_{""}, |
| 67 | seat_status_{nullptr} { |
| 68 | struct wl_display* display = Client::inst()->wl_display; |
| 69 | struct wl_registry* registry = wl_display_get_registry(display); |
| 70 | wl_registry_add_listener(registry, ®istry_listener_impl, this); |
| 71 | wl_display_roundtrip(display); |
| 72 | |
| 73 | if (!status_manager_) { |
| 74 | spdlog::error("river_status_manager_v1 not advertised"); |
| 75 | return; |
| 76 | } |
| 77 | |
| 78 | if (!seat_) { |
| 79 | spdlog::error("wl_seat not advertised"); |
| 80 | } |
| 81 | |
| 82 | label_.hide(); |
| 83 | ALabel::update(); |
| 84 | |
| 85 | seat_status_ = zriver_status_manager_v1_get_river_seat_status(status_manager_, seat_); |
| 86 | zriver_seat_status_v1_add_listener(seat_status_, &seat_status_listener_impl, this); |
| 87 | |
| 88 | zriver_status_manager_v1_destroy(status_manager_); |
| 89 | } |
| 90 | |
| 91 | Mode::~Mode() { |
| 92 | if (seat_status_) { |