mirror of
https://cagebreak.project-repo.co/cagebreak.git
synced 2026-08-09 15:19:11 +02:00
Add output scaling (#34)
* feat: output scaling * chore: update man file * fix: message when scaling
This commit is contained in:
parent
4077064bc8
commit
29943b50e6
7 changed files with 35 additions and 7 deletions
7
Dockerfile
Normal file
7
Dockerfile
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -242,12 +242,13 @@ message <text>
|
|||
*only*
|
||||
Remove all splits and make current window fill the entire screen
|
||||
|
||||
*output <name> [[pos <xpos> <ypos> res <width>x<height> rate <rate>] | enable | disable | prio <n> ]*
|
||||
*output <name> [[pos <xpos> <ypos> res <width>x<height> rate <rate> [scale <scale>]] | enable | disable | prio <n> ]*
|
||||
Configure output "<name>" -
|
||||
- <xpos> and <ypos> are the position of the
|
||||
monitor in pixels. The top-left monitor should have the coordinates 0 0.
|
||||
- <width> and <height> specify the resolution in pixels.
|
||||
- <rate> sets the refresh rate of the monitor (often this is 50 or 60).
|
||||
- <scale> sets the output scale (default is 1.0)
|
||||
- enable and disable enable or disable <name>. Note that if
|
||||
<output> is the only enabled output, *output <output> disable* has
|
||||
no effect.
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
8
output.c
8
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);
|
||||
|
|
|
|||
1
output.h
1
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
|
||||
};
|
||||
|
|
|
|||
14
parse.c
14
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:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue