Merge pull request #7 from Alexays/bar-position

Allow bar position at the bottom of screen
This commit is contained in:
Alex 2018-08-10 00:45:14 +02:00 committed by GitHub
commit 654ceffe19
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 3 deletions

View File

@ -17,22 +17,25 @@ waybar::Bar::Bar(Client &client, std::unique_ptr<struct wl_output *> &&p_output)
.done = _handleDone, .done = _handleDone,
.scale = _handleScale, .scale = _handleScale,
}; };
wl_output_add_listener(*output, &outputListener, this); wl_output_add_listener(*output, &outputListener, this);
window.set_title("waybar"); window.set_title("waybar");
window.set_decorated(false); window.set_decorated(false);
_setupConfig(); _setupConfig();
_setupCss(); _setupCss();
_setupWidgets(); _setupWidgets();
bool positionBottom = (_config["position"] == "bottom");
gtk_widget_realize(GTK_WIDGET(window.gobj())); gtk_widget_realize(GTK_WIDGET(window.gobj()));
GdkWindow *gdkWindow = gtk_widget_get_window(GTK_WIDGET(window.gobj())); GdkWindow *gdkWindow = gtk_widget_get_window(GTK_WIDGET(window.gobj()));
gdk_wayland_window_set_use_custom_surface(gdkWindow); gdk_wayland_window_set_use_custom_surface(gdkWindow);
surface = gdk_wayland_window_get_wl_surface(gdkWindow); surface = gdk_wayland_window_get_wl_surface(gdkWindow);
layerSurface = zwlr_layer_shell_v1_get_layer_surface( 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"); "waybar");
zwlr_layer_surface_v1_set_anchor(layerSurface, zwlr_layer_surface_v1_set_anchor(layerSurface,
ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_TOP | ZWLR_LAYER_SURFACE_V1_ANCHOR_LEFT | ZWLR_LAYER_SURFACE_V1_ANCHOR_RIGHT |
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); zwlr_layer_surface_v1_set_size(layerSurface, _width, client.height);
static const struct zwlr_layer_surface_v1_listener layerSurfaceListener = { static const struct zwlr_layer_surface_v1_listener layerSurfaceListener = {
.configure = _layerSurfaceHandleConfigure, .configure = _layerSurfaceHandleConfigure,