Remove listener when window is destroyed (#3215)

This commit is contained in:
Eldar Yusupov 2024-05-06 11:51:14 +03:00 committed by GitHub
parent e7779b5458
commit df1a9c5509
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 8 additions and 2 deletions

View File

@ -14,7 +14,7 @@ namespace waybar::modules::dwl {
class Window : public AAppIconLabel, public sigc::trackable {
public:
Window(const std::string &, const waybar::Bar &, const Json::Value &);
virtual ~Window() = default;
~Window();
void handle_layout(const uint32_t layout);
void handle_title(const char *title);

View File

@ -80,7 +80,7 @@ Window::Window(const std::string &id, const Bar &bar, const Json::Value &config)
wl_registry_add_listener(registry, &registry_listener_impl, this);
wl_display_roundtrip(display);
if (!status_manager_) {
if (status_manager_ == nullptr) {
spdlog::error("dwl_status_manager_v2 not advertised");
return;
}
@ -91,6 +91,12 @@ Window::Window(const std::string &id, const Bar &bar, const Json::Value &config)
zdwl_ipc_manager_v2_destroy(status_manager_);
}
Window::~Window() {
if (output_status_ != nullptr) {
zdwl_ipc_output_v2_destroy(output_status_);
}
}
void Window::handle_title(const char *title) { title_ = title; }
void Window::handle_appid(const char *appid) { appid_ = appid; }