feat(config): can force width

This commit is contained in:
Alexis 2018-08-11 09:59:35 +02:00
parent 04183dc696
commit 3c66f4baa7
2 changed files with 5 additions and 3 deletions

View File

@ -1,6 +1,8 @@
{ {
// "layer": "top", // Waybar at top layer // "layer": "top", // Waybar at top layer
// "position": "bottom", // Waybar at the bottom of your screen // "position": "bottom", // Waybar at the bottom of your screen
// "height": 30, // Waybar height
// "width": 1280, // Waybar width
// Choose the order of the modules // Choose the order of the modules
"modules-left": ["workspaces", "custom/spotify"], "modules-left": ["workspaces", "custom/spotify"],
"modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"], "modules-right": ["pulseaudio", "network", "cpu", "memory", "battery", "clock"],

View File

@ -98,7 +98,8 @@ void waybar::Bar::_handleMode(void *data, struct wl_output *wl_output,
uint32_t f, int32_t w, int32_t h, int32_t refresh) uint32_t f, int32_t w, int32_t h, int32_t refresh)
{ {
auto o = reinterpret_cast<waybar::Bar *>(data); auto o = reinterpret_cast<waybar::Bar *>(data);
o->setWidth(w); // If the width is configured we force it
o->setWidth(o->_config["width"] ? o->_config["width"].asUInt() : w);
} }
void waybar::Bar::_handleDone(void *data, struct wl_output *) void waybar::Bar::_handleDone(void *data, struct wl_output *)
@ -119,8 +120,7 @@ void waybar::Bar::_layerSurfaceHandleConfigure(
auto o = reinterpret_cast<waybar::Bar *>(data); auto o = reinterpret_cast<waybar::Bar *>(data);
o->window.show_all(); o->window.show_all();
zwlr_layer_surface_v1_ack_configure(surface, serial); zwlr_layer_surface_v1_ack_configure(surface, serial);
if (o->_height != height) if (o->_height != height) {
{
height = o->_height; height = o->_height;
std::cout << fmt::format("New Height: {}", height) << std::endl; std::cout << fmt::format("New Height: {}", height) << std::endl;
zwlr_layer_surface_v1_set_size(surface, width, height); zwlr_layer_surface_v1_set_size(surface, width, height);