Make magnifier increment a theme parameter

This commit is contained in:
Simon Long 2024-05-13 07:43:07 +01:00
parent 56a86ffeed
commit a64479037f
4 changed files with 17 additions and 6 deletions

View file

@ -296,6 +296,10 @@ elements are not listed here, but are supported.
is the default at boot; can be modified at run-time in a keyboard
or mouse binding by calling 'ZoomIn' or 'ZoomOut'. Default is x2.
*magnifier.increment*
Step by which magnification changes on each call to 'ZoomIn' or
'ZoomOut'. Default is 0.2.
*magnifier.filter*
Set to 1 to apply a bilinear filter to the magnified image.
Set to 0 to use nearest-neighbour. Default is 1 - bilinear filtered.

View file

@ -147,6 +147,7 @@ struct theme {
float mag_border_color[4];
int mag_border_width;
int mag_filter;
float mag_increment;
};
struct server;

View file

@ -14,7 +14,7 @@
#include "common/macros.h"
static bool magnify_on;
static double mag_scale = 0.0;
static double mag_scale = 0.0, mag_increment = 0.0;
struct wlr_surface *
lab_wlr_surface_from_node(struct wlr_scene_node *node)
@ -103,6 +103,9 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
if (mag_scale == 0.0) {
mag_scale = theme->mag_scale;
}
if (mag_increment == 0.0) {
mag_increment = theme->mag_increment;
}
if (fullscreen) {
// The lines below were the first attempt at enabling fullscreen (with no
@ -304,17 +307,16 @@ magnify_toggle(void)
void
magnify_set_scale(enum magnify_dir dir)
{
#define MAG_INCREMENT 0.2
if (dir == MAGNIFY_INCREASE) {
if (magnify_on) {
mag_scale += MAG_INCREMENT;
mag_scale += mag_increment;
} else {
magnify_on = true;
mag_scale = 1.0 + MAG_INCREMENT;
mag_scale = 1.0 + mag_increment;
}
} else {
if (magnify_on && mag_scale > 1.0 + MAG_INCREMENT) {
mag_scale -= MAG_INCREMENT;
if (magnify_on && mag_scale > 1.0 + mag_increment) {
mag_scale -= mag_increment;
} else {
magnify_on = false;
}

View file

@ -579,6 +579,7 @@ theme_builtin(struct theme *theme, struct server *server)
parse_hexstr("#ff0000", theme->mag_border_color);
theme->mag_border_width = 1;
theme->mag_filter = true;
theme->mag_increment = 0.2;
}
static void
@ -853,6 +854,9 @@ entry(struct theme *theme, const char *key, const char *value)
if (match_glob(key, "magnifier.filter")) {
theme->mag_filter = atoi(value);
}
if (match_glob(key, "magnifier.increment")) {
theme->mag_increment = atof(value);
}
}
static void