From 472a954d03f8a4aea893b42374fbd760d35f4a6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20Pla=C3=A7ais?= Date: Fri, 10 Aug 2018 00:40:09 +0200 Subject: [PATCH] Allow bar position at the bottom of screen --- src/bar.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bar.cpp b/src/bar.cpp index 9c7d1889..fdbacb06 100644 --- a/src/bar.cpp +++ b/src/bar.cpp @@ -17,22 +17,25 @@ waybar::Bar::Bar(Client &client, std::unique_ptr &&p_output) .done = _handleDone, .scale = _handleScale, }; + wl_output_add_listener(*output, &outputListener, this); window.set_title("waybar"); window.set_decorated(false); _setupConfig(); _setupCss(); _setupWidgets(); + bool positionBottom = (_config["position"] == "bottom"); gtk_widget_realize(GTK_WIDGET(window.gobj())); GdkWindow *gdkWindow = gtk_widget_get_window(GTK_WIDGET(window.gobj())); 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, ZWLR_LAYER_SHELL_V1_LAYER_TOP, + client.layer_shell, surface, *output, + (positionBottom ? ZWLR_LAYER_SHELL_V1_LAYER_BOTTOM : ZWLR_LAYER_SHELL_V1_LAYER_TOP), "waybar"); zwlr_layer_surface_v1_set_anchor(layerSurface, - ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | - ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT); + ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT | + (positionBottom ? ZWLR_LAYER_SURFACE_V1_ANCHOR_BOTTOM : ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP)); zwlr_layer_surface_v1_set_size(layerSurface, _width, client.height); static const struct zwlr_layer_surface_v1_listener layerSurfaceListener = { .configure = _layerSurfaceHandleConfigure,