mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
refactor(client): cleanup
This commit is contained in:
parent
be66cc2dd1
commit
9b75302d22
@ -23,10 +23,9 @@ namespace waybar {
|
||||
Glib::RefPtr<Gdk::Display> 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<std::unique_ptr<Bar>> bars;
|
||||
|
||||
Client(int argc, char* argv[]);
|
||||
|
@ -15,7 +15,7 @@ waybar::Bar::Bar(Client &client, std::unique_ptr<struct wl_output *> &&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<struct wl_output *> &&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,
|
||||
|
@ -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<waybar::Client *>(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<struct wl_output *>();
|
||||
*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<Bar>(*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<struct wl_output *>();
|
||||
*output = o->wlOutput;
|
||||
o->bars.emplace_back(std::make_unique<Bar>(*o, std::move(output)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void waybar::Client::_handle_global_remove(void *data,
|
||||
|
Loading…
Reference in New Issue
Block a user