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