From 84b069a333a49a15bec23c7501d8da230be66866 Mon Sep 17 00:00:00 2001 From: Xtr126 <80520774+Xtr126@users.noreply.github.com> Date: Sat, 4 May 2024 10:59:34 +0530 Subject: [PATCH 1/1] wlroots wayland backend custom size --- backend/wayland/output.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/backend/wayland/output.c b/backend/wayland/output.c index bc150845..80b5cc55 100644 --- a/backend/wayland/output.c +++ b/backend/wayland/output.c @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -761,6 +762,22 @@ static const struct xdg_toplevel_listener xdg_toplevel_listener = { .close = xdg_toplevel_handle_close, }; +static size_t parse_size_env(const char *name) { + const char *size_str = getenv(name); + if (size_str == NULL) { + return 1; + } + + char *end; + int size = (int)strtol(size_str, &end, 10); + if (*end || size < 0) { + wlr_log(WLR_ERROR, "%s specified with invalid integer, ignoring", name); + return 1; + } + + return size; +} + static struct wlr_wl_output *output_create(struct wlr_wl_backend *backend, struct wl_surface *surface) { struct wlr_wl_output *output = calloc(1, sizeof(*output)); @@ -772,7 +789,12 @@ static struct wlr_wl_output *output_create(struct wlr_wl_backend *backend, struct wlr_output_state state; wlr_output_state_init(&state); - wlr_output_state_set_custom_mode(&state, 1280, 720, 0); + + size_t width = parse_size_env("XTMAPPER_WIDTH"); + size_t height = parse_size_env("XTMAPPER_HEIGHT"); + + if (width > 1 && height > 1) wlr_output_state_set_custom_mode(&state, width, height, 0); + else wlr_output_state_set_custom_mode(&state, 1280, 720, 0); wlr_output_init(wlr_output, &backend->backend, &output_impl, backend->local_display, &state); -- 2.44.0