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. colour of the border for the magnifier window.
'borderWidth' sets the width in pixels of the border for the 'borderWidth' sets the width in pixels of the border for the
magnifier window. magnifier window.
'useFilter' sets whether to use a bilinear filter on the magnified
output or simply to take nearest pixel.
--> -->
<magnifier> <magnifier>
<size>400</size> <size>400</size>
<initScale>2</initScale> <initScale>2</initScale>
<borderColour>#ff0000</borderColour> <borderColour>#ff0000</borderColour>
<borderWidth>1</borderWidth> <borderWidth>1</borderWidth>
<useFilter>true</useFilter>
</magnifier> </magnifier>
</labwc_config> </labwc_config>

View file

@ -149,6 +149,7 @@ struct rcxml {
int mag_size; int mag_size;
struct rgb_colour mag_border_col; struct rgb_colour mag_border_col;
int mag_border_width; int mag_border_width;
bool mag_filter;
}; };
extern struct rcxml rc; 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; ox *= output->wlr_output->scale;
oy *= output->wlr_output->scale; oy *= output->wlr_output->scale;
/* TODO: refactor, to use rc. settings */
int width = rc.mag_size + 1; int width = rc.mag_size + 1;
int height = width; int height = width;
double x = ox - (rc.mag_size / 2.0); 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 = { struct wlr_render_rect_options bg_opts = {
.box = border_box, .box = border_box,
/* TODO: make this a rc. setting */
.color = (struct wlr_render_color) { .color = (struct wlr_render_color) {
.r = rc.mag_border_col.r / 255.0, .r = rc.mag_border_col.r / 255.0,
.g = rc.mag_border_col.g / 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, .alpha = NULL,
.clip = NULL, .clip = NULL,
//.filter_mode = WLR_SCALE_FILTER_NEAREST, .filter_mode = rc.mag_filter ? WLR_SCALE_FILTER_BILINEAR : WLR_SCALE_FILTER_NEAREST,
.filter_mode = WLR_SCALE_FILTER_BILINEAR,
}; };
wlr_render_pass_add_texture(tmp_render_pass, &opts); wlr_render_pass_add_texture(tmp_render_pass, &opts);
if (!wlr_render_pass_submit(tmp_render_pass)) { 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); &rc.mag_border_col.b);
} else if (!strcasecmp(nodename, "borderWidth.magnifier")) { } else if (!strcasecmp(nodename, "borderWidth.magnifier")) {
rc.mag_border_width = atoi(content); 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.g = 0;
rc.mag_border_col.b = 0; rc.mag_border_col.b = 0;
rc.mag_border_width = 1; rc.mag_border_width = 1;
rc.mag_filter = true;
} }
static void static void