Skip to content

Commit

Permalink
cairo: add BEMENU_SCALE env variable
Browse files Browse the repository at this point in the history
Allows overriding the scaling factor for bemenu
  • Loading branch information
Cloudef committed Jun 28, 2020
1 parent 7266ebb commit 65cea5e
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ All dependencies are searched with `pkg-config`
| BEMENU_BACKEND | Force backend by name | x11, wayland, curses |
| BEMENU_RENDERER | Force backend by loading a .so file | Path to the .so file |
| BEMENU_RENDERERS | Override the backend search path | Path to a directory |
| BEMENU_SCALE | Override the rendering scale factor | Float value |

## About Wayland support

Expand Down
8 changes: 7 additions & 1 deletion lib/renderers/wayland/wayland.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,13 @@ recreate_windows(const struct bm_menu *menu, struct wayland *wayland)

struct window *window = calloc(1, sizeof(struct window));
window->bottom = menu->bottom;
window->scale = output->scale;

const char *scale = getenv("BEMENU_SCALE");
if (scale) {
window->scale = fmax(strtof(scale, NULL), 1.0f);
} else {
window->scale = output->scale;
}

if (!bm_wl_window_create(window, wayland->display, wayland->shm, output->output, wayland->layer_shell, surface))
free(window);
Expand Down
7 changes: 6 additions & 1 deletion lib/renderers/x11/window.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,12 @@ create_buffer(struct window *window, struct buffer *buffer, int32_t width, int32

cairo_xlib_surface_set_size(surf, width, height);

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

if (!bm_cairo_create_for_surface(&buffer->cairo, surf)) {
cairo_surface_destroy(surf);
Expand Down
6 changes: 6 additions & 0 deletions man/bemenu.1
Original file line number Diff line number Diff line change
Expand Up @@ -224,3 +224,9 @@ Force backend by loading a .so file.
.RS
Override the backend search path.
.RE

.TP
.B BEMENU_SCALE
.RS
Override the rendering scale factor.
.RE

0 comments on commit 65cea5e

Please sign in to comment.