Add filtering option to XML

This commit is contained in:
Simon Long 2024-05-03 11:33:33 +01:00
parent 05c89f18fb
commit 94f21ca61c
4 changed files with 8 additions and 4 deletions

View file

@ -595,12 +595,15 @@
colour of the border for the magnifier window.
'borderWidth' sets the width in pixels of the border for the
magnifier window.
'useFilter' sets whether to use a bilinear filter on the magnified
output or simply to take nearest pixel.
-->
<magnifier>
<size>400</size>
<initScale>2</initScale>
<borderColour>#ff0000</borderColour>
<borderWidth>1</borderWidth>
<useFilter>true</useFilter>
</magnifier>
</labwc_config>

View file

@ -149,6 +149,7 @@ struct rcxml {
int mag_size;
struct rgb_colour mag_border_col;
int mag_border_width;
bool mag_filter;
};
extern struct rcxml rc;

View file

@ -74,7 +74,6 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
ox *= output->wlr_output->scale;
oy *= output->wlr_output->scale;
/* TODO: refactor, to use rc. settings */
int width = rc.mag_size + 1;
int height = width;
double x = ox - (rc.mag_size / 2.0);
@ -156,7 +155,6 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
};
struct wlr_render_rect_options bg_opts = {
.box = border_box,
/* TODO: make this a rc. setting */
.color = (struct wlr_render_color) {
.r = rc.mag_border_col.r / 255.0,
.g = rc.mag_border_col.g / 255.0,
@ -188,8 +186,7 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
},
.alpha = NULL,
.clip = NULL,
//.filter_mode = WLR_SCALE_FILTER_NEAREST,
.filter_mode = WLR_SCALE_FILTER_BILINEAR,
.filter_mode = rc.mag_filter ? WLR_SCALE_FILTER_BILINEAR : WLR_SCALE_FILTER_NEAREST,
};
wlr_render_pass_add_texture(tmp_render_pass, &opts);
if (!wlr_render_pass_submit(tmp_render_pass)) {

View file

@ -1056,6 +1056,8 @@ entry(xmlNode *node, char *nodename, char *content)
&rc.mag_border_col.b);
} else if (!strcasecmp(nodename, "borderWidth.magnifier")) {
rc.mag_border_width = atoi(content);
} else if (!strcasecmp(nodename, "useFilter.magnifier")) {
set_bool(content, &rc.mag_filter);
}
}
@ -1267,6 +1269,7 @@ rcxml_init(void)
rc.mag_border_col.g = 0;
rc.mag_border_col.b = 0;
rc.mag_border_width = 1;
rc.mag_filter = true;
}
static void