diff --git a/include/client.hpp b/include/client.hpp index 130c42a..67a02ab 100644 --- a/include/client.hpp +++ b/include/client.hpp @@ -23,10 +23,9 @@ namespace waybar { Glib::RefPtr gdk_display; 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 zwlr_layer_shell_v1 *layerShell = nullptr; + struct zxdg_output_manager_v1 *xdgOutputManager = nullptr; struct wl_seat *seat = nullptr; - struct wl_output *wlOutput = nullptr; std::vector> bars; Client(int argc, char* argv[]); diff --git a/src/bar.cpp b/src/bar.cpp index be8d386..af18d8f 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -15,7 +15,7 @@ waybar::Bar::Bar(Client &client, std::unique_ptr &&p_output) .description = _handleDescription, }; _xdgOutput = - zxdg_output_manager_v1_get_xdg_output(client.xdg_output_manager, *output); + zxdg_output_manager_v1_get_xdg_output(client.xdgOutputManager, *output); zxdg_output_v1_add_listener(_xdgOutput, &xdgOutputListener, this); window.set_title("waybar"); window.set_decorated(false); @@ -31,7 +31,7 @@ waybar::Bar::Bar(Client &client, std::unique_ptr &&p_output) gdk_wayland_window_set_use_custom_surface(gdkWindow); surface = gdk_wayland_window_get_wl_surface(gdkWindow); layerSurface = zwlr_layer_shell_v1_get_layer_surface( - client.layer_shell, surface, *output, + client.layerShell, surface, *output, (layerTop ? ZWLR_LAYER_SHELL_V1_LAYER_TOP : ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM), "waybar"); zwlr_layer_surface_v1_set_anchor(layerSurface, diff --git a/src/client.cpp b/src/client.cpp index afeaf24..a9be135 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -14,9 +14,8 @@ waybar::Client::Client(int argc, char* argv[]) std::string result = p.we_wordv[0]; wordfree(&p); return result; - } else { - wordfree(&p); } + wordfree(&p); } } @@ -42,30 +41,23 @@ void waybar::Client::_handle_global(void *data, struct wl_registry *registry, uint32_t name, const char *interface, uint32_t version) { auto o = reinterpret_cast(data); - if (!strcmp(interface, zwlr_layer_shell_v1_interface.name)) { - o->layer_shell = (zwlr_layer_shell_v1 *)wl_registry_bind(registry, name, + if (!strcmp(interface, zwlr_layer_shell_v1_interface.name)) + o->layerShell = (zwlr_layer_shell_v1 *)wl_registry_bind(registry, name, &zwlr_layer_shell_v1_interface, version); - } else if (!strcmp(interface, wl_output_interface.name)) { - o->wlOutput = (struct wl_output *)wl_registry_bind(registry, name, - &wl_output_interface, version); + else if (!strcmp(interface, wl_output_interface.name)) { auto output = std::make_unique(); - *output = o->wlOutput; - if (o->xdg_output_manager) + *output = (struct wl_output *)wl_registry_bind(registry, name, + &wl_output_interface, version); + if (o->xdgOutputManager) o->bars.emplace_back(std::make_unique(*o, std::move(output))); - } else if (!strcmp(interface, wl_seat_interface.name)) { + } else if (!strcmp(interface, wl_seat_interface.name)) o->seat = (struct wl_seat *)wl_registry_bind(registry, name, &wl_seat_interface, version); - } else if (!strcmp(interface, zxdg_output_manager_v1_interface.name) - && version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) { - o->xdg_output_manager = + else if (!strcmp(interface, zxdg_output_manager_v1_interface.name) + && version >= ZXDG_OUTPUT_V1_NAME_SINCE_VERSION) + o->xdgOutputManager = (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))); - } - } } void waybar::Client::_handle_global_remove(void *data,