Skip to content

Commit

Permalink
wayland: cairo/wl scale are different concepts
Browse files Browse the repository at this point in the history
Sepearate BEMENU_SCALE from wayland's buffer scale
  • Loading branch information
Cloudef committed Feb 2, 2024
1 parent 826b895 commit 3156dac
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
5 changes: 0 additions & 5 deletions lib/renderers/wayland/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,6 @@ window_update_output(struct window *window)
};
}

const char *scale = getenv("BEMENU_SCALE");
if (scale) {
max_scale = fmax(strtof(scale, NULL), 1.0f);
}

if (min_max_height != window->max_height) {
window->max_height = min_max_height;
}
Expand Down
17 changes: 11 additions & 6 deletions lib/renderers/wayland/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,12 @@ create_buffer(struct wl_shm *shm, struct buffer *buffer, int32_t width, int32_t
if (!(surf = cairo_image_surface_create_for_data(data, CAIRO_FORMAT_ARGB32, width, height, stride)))
goto fail;

buffer->cairo.scale = scale;
const char *env_scale = getenv("BEMENU_SCALE");
if (env_scale) {
buffer->cairo.scale = fmax(strtof(env_scale, NULL), 1.0f);
} else {
buffer->cairo.scale = scale;
}

if (!bm_cairo_create_for_surface(&buffer->cairo, surf)) {
cairo_surface_destroy(surf);
Expand Down Expand Up @@ -253,17 +258,17 @@ bm_wl_window_render(struct window *window, struct wl_display *display, struct bm
window->notify.render(&buffer->cairo, buffer->width, window->max_height, menu, &result);
window->displayed = result.displayed;

if (window->height == result.height / buffer->cairo.scale)
if (window->height == result.height / window->scale)
break;

window->height = result.height / buffer->cairo.scale;
window->height = result.height / window->scale;
zwlr_layer_surface_v1_set_size(window->layer_surface, window->width, window->height);
destroy_buffer(buffer);
}

assert(window->width * buffer->cairo.scale == buffer->width);
assert(window->height * buffer->cairo.scale == buffer->height);
wl_surface_set_buffer_scale(window->surface, buffer->cairo.scale);
assert(window->width * window->scale == buffer->width);
assert(window->height * window->scale == buffer->height);
wl_surface_set_buffer_scale(window->surface, window->scale);
wl_surface_damage_buffer(window->surface, 0, 0, buffer->width, buffer->height);
wl_surface_attach(window->surface, buffer->buffer, 0, 0);
wl_surface_commit(window->surface);
Expand Down

0 comments on commit 3156dac

Please sign in to comment.