diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..521d1a0 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +FROM debian:bookworm +RUN apt-get update +RUN apt-get install -y libwlroots-dev xwayland meson cmake libcairo2-dev libpango1.0-dev +ADD * ./ +ADD examples ./examples +RUN meson build +RUN ninja -C build \ No newline at end of file diff --git a/examples/config b/examples/config index e6a6cb5..7eddad1 100644 --- a/examples/config +++ b/examples/config @@ -95,6 +95,7 @@ definekey top XF86MonBrightnessUp exec xbacklight -inc 1 #output eDP-1 disable #output eDP-1 enable #output eDP-1 prio 1 +#output eDP-2 pos 0 0 res 1366x768 rate 60 scale 2.0 ##################### #Input configuration diff --git a/man/cagebreak-config.5.md b/man/cagebreak-config.5.md index 1f0293f..ba8b3b0 100644 --- a/man/cagebreak-config.5.md +++ b/man/cagebreak-config.5.md @@ -242,12 +242,13 @@ message *only* Remove all splits and make current window fill the entire screen -*output [[pos res x rate ] | enable | disable | prio ]* +*output [[pos res x rate [scale ]] | enable | disable | prio ]* Configure output "" - - and are the position of the monitor in pixels. The top-left monitor should have the coordinates 0 0. - and specify the resolution in pixels. - sets the refresh rate of the monitor (often this is 50 or 60). + - sets the output scale (default is 1.0) - enable and disable enable or disable . Note that if is the only enabled output, *output disable* has no effect. diff --git a/message.c b/message.c index 444406a..f80dcef 100644 --- a/message.c +++ b/message.c @@ -140,7 +140,6 @@ create_message_texture(const char *string, const struct cg_output *output) { float *bg_col = output->server->message_config.bg_color; cairo_set_source_rgba(cairo, bg_col[0], bg_col[1], bg_col[2], bg_col[3]); cairo_paint(cairo); - PangoContext *pango = pango_cairo_create_context(cairo); float *fg_col = output->server->message_config.fg_color; cairo_set_source_rgba(cairo, fg_col[0], fg_col[1], fg_col[2], fg_col[3]); cairo_set_line_width(cairo, 2); @@ -168,7 +167,6 @@ create_message_texture(const char *string, const struct cg_output *output) { wlr_buffer_end_data_ptr_access(&buf->base); cairo_surface_destroy(surface); - g_object_unref(pango); cairo_destroy(cairo); return buf; } @@ -196,8 +194,9 @@ message_set_output(struct cg_output *output, const char *string, message->position = box; wl_list_insert(&output->messages, &message->link); - int width = buf->base.width; - int height = buf->base.height; + double scale = output->wlr_output->scale; + int width = buf->base.width/scale; + int height = buf->base.height/scale; message->position->width = width; message->position->height = height; switch(align) { @@ -235,6 +234,7 @@ message_set_output(struct cg_output *output, const char *string, wlr_scene_node_set_enabled(&message->message->node, true); struct wlr_box *outp_box = wlr_output_layout_get_box( output->server->output_layout, output->wlr_output); + wlr_scene_buffer_set_dest_size(message->message,width,height); wlr_scene_node_set_position(&message->message->node, message->position->x + outp_box->x, message->position->y + outp_box->y); diff --git a/output.c b/output.c index 74201ca..aa3d87a 100644 --- a/output.c +++ b/output.c @@ -178,7 +178,7 @@ output_find_config(struct cg_server *server, struct wlr_output *output) { static int output_set_mode(struct wlr_output *output, int width, int height, - float refresh_rate) { + float refresh_rate, float *scale) { int mhz = (int)(refresh_rate * 1000); if(wl_list_empty(&output->modes)) { @@ -209,6 +209,10 @@ output_set_mode(struct wlr_output *output, int width, int height, wlr_log(WLR_DEBUG, "Assigning configured mode to %s", output->name); } wlr_output_set_mode(output, best); + if (scale != NULL) { + wlr_log(WLR_INFO, "Setting output scale to %f", *scale); + wlr_output_set_scale(output, *scale); + } wlr_output_commit(output); if(!wlr_output_test(output)) { wlr_log(WLR_ERROR, @@ -294,7 +298,7 @@ output_configure(struct cg_server *server, struct cg_output *output) { if(config->pos.x != -1) { if(output_set_mode(wlr_output, config->pos.width, config->pos.height, - config->refresh_rate) != 0) { + config->refresh_rate, config->scale) != 0) { wlr_log(WLR_ERROR, "Setting output mode failed, disabling output."); output_clear(output); diff --git a/output.h b/output.h index 390e5f1..f53821f 100644 --- a/output.h +++ b/output.h @@ -40,6 +40,7 @@ struct cg_output_config { struct wlr_box pos; char *output_name; float refresh_rate; + float *scale; int priority; struct wl_list link; // cg_server::output_config }; diff --git a/parse.c b/parse.c index 474a456..29d4fe1 100644 --- a/parse.c +++ b/parse.c @@ -532,6 +532,7 @@ parse_output_config(char **saveptr, char **errstr) { cfg->output_name = NULL; cfg->refresh_rate = 0; cfg->priority = -1; + cfg->scale = NULL; char *name = strtok_r(NULL, " ", saveptr); if(name == NULL) { *errstr = @@ -619,6 +620,19 @@ parse_output_config(char **saveptr, char **errstr) { goto error; } + char *scale_str = strtok_r(NULL, " ", saveptr); + if(scale_str != NULL && strcmp(scale_str, "scale") == 0) { + cfg->scale = malloc(sizeof(float)); + *cfg->scale = parse_float(saveptr, " "); + if(*cfg->scale <= 0.0) { + *errstr = + log_error("Error parsing scale of output configuration for " + "output %s, expected positive float", + name); + goto error; + } + } + cfg->output_name = strdup(name); return cfg; error: