Limit initial scaling factor to sensible values.

FLTK_SCALING_FACTOR=0 or negative values would issue unexpected
X11 warnings or crash immediately.

Also commented out scaling factor output statements (printf).


git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12261 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Albrecht Schlosser 2017-06-15 15:39:55 +00:00
parent a10eae7443
commit e14c387e8e
2 changed files with 6 additions and 3 deletions

View File

@ -493,6 +493,9 @@ float Fl_Screen_Driver::default_scale_factor()
else { else {
factor = desktop_scale_factor(); factor = desktop_scale_factor();
} }
// checks to prevent potential crash (factor <= 0) or very large factors
if (factor < 0.25) factor = 0.25;
else if (factor > 10.0) factor = 10.0;
return factor; return factor;
} }

View File

@ -1346,7 +1346,7 @@ static bool gnome_scale_factor(float& factor) {
strcpy(str, str2); v = v2; strcpy(str, str2); v = v2;
} }
ubuntu_f = v/8.; ubuntu_f = v/8.;
printf("com.ubuntu.user-interface scale-factor name=%s value=%d factor=%g\n", str, v, ubuntu_f); // printf("com.ubuntu.user-interface scale-factor name=%s value=%d factor=%g\n", str, v, ubuntu_f);
g_variant_iter_free_f(iter); g_variant_iter_free_f(iter);
g_variant_unref_f(gvar); g_variant_unref_f(gvar);
g_object_unref_f(gset); g_object_unref_f(gset);
@ -1363,7 +1363,7 @@ static bool gnome_scale_factor(float& factor) {
unsigned v; unsigned v;
g_variant_get_f(gvar, "u", &v); g_variant_get_f(gvar, "u", &v);
ubuntu_desktop_f = v; ubuntu_desktop_f = v;
printf("org.gnome.desktop.interface scaling-factor value=%u factor=%g\n", v, ubuntu_desktop_f); // printf("org.gnome.desktop.interface scaling-factor value=%u factor=%g\n", v, ubuntu_desktop_f);
g_variant_unref_f(gvar); g_variant_unref_f(gvar);
g_object_unref_f(gset); g_object_unref_f(gset);
if (ubuntu_desktop_f != 1) { if (ubuntu_desktop_f != 1) {
@ -1388,7 +1388,7 @@ static bool gnome_scale_factor(float& factor) {
//str = (char*)g_variant_get_type_f(gvar); // -> "i" //str = (char*)g_variant_get_type_f(gvar); // -> "i"
g_variant_get_f(gvar, "i", &v); g_variant_get_f(gvar, "i", &v);
gnome_f = v; gnome_f = v;
printf("org.gnome.settings-daemon.plugins.xsettings overrides name=%s value=%d factor=%g\n", str, v, gnome_f); // printf("org.gnome.settings-daemon.plugins.xsettings overrides name=%s value=%d factor=%g\n", str, v, gnome_f);
free(str); free(str);
break; break;
} }