Make initial scaling a float; prevent divide by zero

This commit is contained in:
Simon Long 2024-05-15 22:50:45 +01:00
parent 50066161b0
commit ae2638b238
5 changed files with 8 additions and 5 deletions

View file

@ -932,7 +932,7 @@ situation.
*<magnifier><initScale>* *<magnifier><initScale>*
Initial number of times by which magnified image is scaled. Value Initial number of times by which magnified image is scaled. Value
is the default at boot; can be modified at run-time in a keyboard 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. or mouse binding by calling 'ZoomIn' or 'ZoomOut'. Default is x2.0.
*<magnifier><increment>* *<magnifier><increment>*
Step by which magnification changes on each call to 'ZoomIn' or Step by which magnification changes on each call to 'ZoomIn' or

View file

@ -603,7 +603,7 @@
<magnifier> <magnifier>
<width>400</width> <width>400</width>
<height>400</height> <height>400</height>
<initScale>2</initScale> <initScale>2.0</initScale>
<increment>0.2</increment> <increment>0.2</increment>
<useFilter>true</useFilter> <useFilter>true</useFilter>
</magnifier> </magnifier>

View file

@ -144,7 +144,7 @@ struct rcxml {
/* Magnifier */ /* Magnifier */
int mag_width; int mag_width;
int mag_height; int mag_height;
int mag_scale; float mag_scale;
float mag_increment; float mag_increment;
bool mag_filter; bool mag_filter;
}; };

View file

@ -1041,7 +1041,7 @@ entry(xmlNode *node, char *nodename, char *content)
} else if (!strcasecmp(nodename, "height.magnifier")) { } else if (!strcasecmp(nodename, "height.magnifier")) {
rc.mag_height = atoi(content); rc.mag_height = atoi(content);
} else if (!strcasecmp(nodename, "initScale.magnifier")) { } else if (!strcasecmp(nodename, "initScale.magnifier")) {
rc.mag_scale = atoi(content); set_float(content, &rc.mag_scale);
} else if (!strcasecmp(nodename, "increment.magnifier")) { } else if (!strcasecmp(nodename, "increment.magnifier")) {
set_float(content, &rc.mag_increment); set_float(content, &rc.mag_increment);
} else if (!strcasecmp(nodename, "useFilter.magnifier")) { } else if (!strcasecmp(nodename, "useFilter.magnifier")) {
@ -1255,7 +1255,7 @@ rcxml_init(void)
rc.mag_width = 400; rc.mag_width = 400;
rc.mag_height = 400; rc.mag_height = 400;
rc.mag_scale = 2; rc.mag_scale = 2.0;
rc.mag_increment = 0.2; rc.mag_increment = 0.2;
rc.mag_filter = true; rc.mag_filter = true;
} }

View file

@ -60,6 +60,9 @@ magnify(struct output *output, struct wlr_buffer *output_buffer, struct wlr_box
if (mag_scale == 0.0) { if (mag_scale == 0.0) {
mag_scale = rc.mag_scale; mag_scale = rc.mag_scale;
} }
if (mag_scale == 0.0) {
mag_scale = 1.0;
}
if (fullscreen) { if (fullscreen) {
width = output_buffer->width; width = output_buffer->width;