From d1d51b76aa1b313a010a6e266a6e142c932f4d9c Mon Sep 17 00:00:00 2001 From: Alexis Date: Wed, 15 Aug 2018 01:53:43 +0200 Subject: [PATCH] fix(client): try to fix #20 --- include/client.hpp | 11 ++++++----- src/client.cpp | 13 ++++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/include/client.hpp b/include/client.hpp index 2c982f88..130c42ad 100644 --- a/include/client.hpp +++ b/include/client.hpp @@ -21,11 +21,12 @@ namespace waybar { Gtk::Main gtk_main; Glib::RefPtr gdk_display; - struct wl_display *wlDisplay; - struct wl_registry *registry; - struct zwlr_layer_shell_v1 *layer_shell; - struct zxdg_output_manager_v1 *xdg_output_manager; - struct wl_seat *seat; + struct wl_display *wlDisplay = nullptr; + struct wl_registry *registry = nullptr; + struct zwlr_layer_shell_v1 *layer_shell = nullptr; + struct zxdg_output_manager_v1 *xdg_output_manager = nullptr; + struct wl_seat *seat = nullptr; + struct wl_output *wlOutput = nullptr; std::vector> bars; Client(int argc, char* argv[]); diff --git a/src/client.cpp b/src/client.cpp index d912a7a1..afeaf24e 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -46,10 +46,12 @@ void waybar::Client::_handle_global(void *data, struct wl_registry *registry, o->layer_shell = (zwlr_layer_shell_v1 *)wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, version); } else if (!strcmp(interface, wl_output_interface.name)) { - auto output = std::make_unique(); - *output = (struct wl_output *)wl_registry_bind(registry, name, + o->wlOutput = (struct wl_output *)wl_registry_bind(registry, name, &wl_output_interface, version); - o->bars.emplace_back(std::make_unique(*o, std::move(output))); + auto output = std::make_unique(); + *output = o->wlOutput; + if (o->xdg_output_manager) + o->bars.emplace_back(std::make_unique(*o, std::move(output))); } else if (!strcmp(interface, wl_seat_interface.name)) { o->seat = (struct wl_seat *)wl_registry_bind(registry, name, &wl_seat_interface, version); @@ -58,6 +60,11 @@ void waybar::Client::_handle_global(void *data, struct wl_registry *registry, o->xdg_output_manager = (struct zxdg_output_manager_v1 *)wl_registry_bind(registry, name, &zxdg_output_manager_v1_interface, ZXDG_OUTPUT_V1_NAME_SINCE_VERSION); + if (o->wlOutput) { + auto output = std::make_unique(); + *output = o->wlOutput; + o->bars.emplace_back(std::make_unique(*o, std::move(output))); + } } }