Fixes for size setting and config

+ height is optional
+ width is optional
+ make location enum into bitmask
This commit is contained in:
Kyle Gunger 2023-01-17 21:23:47 -05:00
parent 033f21a1f2
commit 37b5b02fc4
6 changed files with 51 additions and 74 deletions

View file

@ -1044,16 +1044,28 @@ update_size(struct wayland_backend *backend)
backend->scale = scale;
int height = bar->height < 0 ? 0 : bar->height_with_border;
int width = bar->width < 0 ? 0 : bar->width_with_border;
LOG_INFO("Attempting to set %dx%d", width, height);
// TODO: Somehow set up width and height properly
// I need to read more to understand how bar->width and bar->height are used
zwlr_layer_surface_v1_set_size(backend->layer_surface, width / scale, height / scale);
zwlr_layer_surface_v1_set_size(
backend->layer_surface,
bar->width_with_border / scale,
bar->height_with_border / scale
);
if (bar->location == BAR_TOP || bar->location == BAR_BOTTOM) {
/* Trigger a 'configure' event, after which we'll have the width */
wl_surface_commit(backend->surface);
wl_display_roundtrip(backend->display);
if (backend->width == -1 || backend->height == -1) {
LOG_ERR("failed to get panel size");
return false;
}
LOG_INFO("backend size: %dx%d", backend->width, backend->height);
bar->width_with_border = backend->width;
bar->height_with_border = backend->height;
if (bar->location & (BAR_TOP | BAR_BOTTOM)) {
zwlr_layer_surface_v1_set_exclusive_zone(
backend->layer_surface,
(bar->height_with_border + (bar->location == BAR_TOP
@ -1076,15 +1088,12 @@ update_size(struct wayland_backend *backend)
bar->border.bottom_margin / scale,
bar->border.left_margin / scale
);
/* Trigger a 'configure' event, after which we'll have the width */
wl_surface_commit(backend->surface);
wl_display_roundtrip(backend->display);
if (backend->width == -1 || backend->height == -1) {
LOG_ERR("failed to get panel size");
return false;
}
// TODO: Figure out why not setting width & height
// make the bar fail to appear. Don't want to have to do this
bar->width = backend->width - (bar->border.left_width + bar->border.right_width);
bar->height = backend->height - (bar->border.top_width + bar->border.bottom_width);
/* Reload buffers */
if (backend->next_buffer != NULL)