Remove deprecated, commented-out code.
This code was used in the past to support a deprecated way to obtain the initial value of the GUI scaling factor for the X11 platform.
This commit is contained in:
parent
a206a778b4
commit
257435dca0
@ -1181,206 +1181,6 @@ int Fl_X11_Screen_Driver::screen_num_unscaled(int x, int y)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
#if HAVE_DLSYM && HAVE_DLFCN_H
|
||||
|
||||
// returns true when name is among the list of known names
|
||||
static bool is_name_in_list(const char *name, const char **list) {
|
||||
int i = 0;
|
||||
while (list[i]) {
|
||||
if (strcmp(list[i++], name) == 0) return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// define types needed for dynamic lib functions
|
||||
typedef const char** (*g_settings_list_schemas_ftype)(void);
|
||||
typedef void (*g_variant_get_ftype)(void *value, const char *format_string, ...);
|
||||
typedef bool (*g_variant_iter_loop_ftype)(void *iter, const char *format_string, ...);
|
||||
typedef const char **(*g_settings_list_keys_ftype)(void *);
|
||||
typedef void* (*g_settings_new_ftype)(const char *);
|
||||
typedef void* (*g_settings_get_value_ftype)(void *settings, const char *key);
|
||||
typedef void (*pter_ftype)(void*);
|
||||
|
||||
// define run-time pointers to functions from dynamic libs
|
||||
static g_settings_new_ftype g_settings_new_f;
|
||||
static g_settings_list_keys_ftype g_settings_list_keys_f;
|
||||
static pter_ftype g_object_unref_f;
|
||||
static pter_ftype g_strfreev_f;
|
||||
static g_settings_get_value_ftype g_settings_get_value_f;
|
||||
|
||||
static void* value_of_key_in_schema(const char **known, const char *schema, const char *key) {
|
||||
void *retval = NULL;
|
||||
if (is_name_in_list(schema, known)) {
|
||||
void *gset = g_settings_new_f(schema);
|
||||
const char **list = g_settings_list_keys_f(gset);
|
||||
if (is_name_in_list(key, list)) retval = g_settings_get_value_f(gset, key);
|
||||
g_strfreev_f(list);
|
||||
g_object_unref_f(gset);
|
||||
}
|
||||
return retval;
|
||||
}*/
|
||||
|
||||
// DEPRECATED: gnome apparently no longer stores the display scale factor value
|
||||
// in the gsettings database.
|
||||
/*
|
||||
returns true under Ubuntu or Debian or FreeBSD and when the gnome scaling value has been found
|
||||
|
||||
Ubuntu:
|
||||
Change the gnome scaling factor with:
|
||||
System Settings ==> Displays ==> Scale for menu and title bars
|
||||
Read the current gnome scaling factor with:
|
||||
gsettings get com.ubuntu.user-interface scale-factor
|
||||
Example value: {'VGA-0': 10}
|
||||
Its type is "a{si}". This value should be divided by 8 to get the correct scaling factor.
|
||||
|
||||
In Ubuntu 18, file $HOME/.config/monitors.xml contains the gnome scaling factor value,
|
||||
and FLTK reads that.
|
||||
|
||||
Debian or FreeBSD :
|
||||
Change the gnome scaling factor with:
|
||||
Tweak tools ==> Windows ==> Window scaling
|
||||
Read the current gnome scaling factor with:
|
||||
gsettings get org.gnome.settings-daemon.plugins.xsettings overrides
|
||||
Example value: {'Gdk/WindowScalingFactor': <2>}
|
||||
Its type is "a{sv}" and v itself is of type i
|
||||
|
||||
It's also possible to use 'Tweak tools' under Ubuntu. With the standard Ubuntu desktop,
|
||||
the modified value goes to "org.gnome.settings-daemon.plugins.xsettings" as above.
|
||||
|
||||
With Gnome session flashback under Ubuntu 'Tweak tools' puts the scaling value (1 or 2)
|
||||
in "org.gnome.desktop.interface scaling-factor".
|
||||
Read the current gnome scaling factor with:
|
||||
gsettings get org.gnome.desktop.interface scaling-factor
|
||||
Its type is "u"
|
||||
|
||||
Thus, under Ubuntu, we read the 3 possible factor values and
|
||||
return the first value different from 1 to get the scaling factor.
|
||||
|
||||
=================================================================================================
|
||||
Ubuntu | default ubuntu desktop | System Settings => Displays => Scale for menu and title bars
|
||||
com.ubuntu.user-interface scale-factor
|
||||
-----------------------
|
||||
Tweak tools => Windows => Window scaling
|
||||
org.gnome.settings-daemon.plugins.xsettings overrides
|
||||
-----------------------
|
||||
Gnome session flashback | System Settings => Displays => Scale for menu and title bars
|
||||
no effect
|
||||
-----------------------
|
||||
Tweak tools => Windows => Window scaling
|
||||
org.gnome.desktop.interface scaling-factor
|
||||
=================================================================================================
|
||||
Debian or FreeBSD | gnome | Tweak tools => Windows => Window scaling
|
||||
org.gnome.settings-daemon.plugins.xsettings overrides
|
||||
=================================================================================================
|
||||
*/
|
||||
/*static bool gnome_scale_factor(float& factor) {
|
||||
// open dynamic libs
|
||||
void *glib = dlopen("libglib-2.0.so", RTLD_LAZY);
|
||||
void *gio = dlopen("libgio-2.0.so", RTLD_LAZY);
|
||||
void *gobj = dlopen("libgobject-2.0.so", RTLD_LAZY);
|
||||
//fprintf(stderr,"glib=%p gio=%p gobj=%p\n",glib,gio,gobj);
|
||||
if (!glib || !gio || !gobj) return false;
|
||||
|
||||
// define pters to used functions and variables
|
||||
g_settings_list_schemas_ftype g_settings_list_schemas_f = (g_settings_list_schemas_ftype)dlsym(gio, "g_settings_list_schemas"); // 2.26
|
||||
g_settings_new_f = (g_settings_new_ftype)dlsym(gio, "g_settings_new"); // 2.26
|
||||
g_settings_get_value_f =
|
||||
(g_settings_get_value_ftype)dlsym(gio, "g_settings_get_value"); // 2.26
|
||||
if (!g_settings_list_schemas_f || !g_settings_new_f || !g_settings_get_value_f) return false;
|
||||
g_variant_get_ftype g_variant_get_f = (g_variant_get_ftype)dlsym(glib, "g_variant_get"); //2.24
|
||||
g_variant_iter_loop_ftype g_variant_iter_loop_f = (g_variant_iter_loop_ftype)dlsym(glib, "g_variant_iter_loop"); // 2.24
|
||||
pter_ftype g_variant_iter_free_f = (pter_ftype)dlsym(glib, "g_variant_iter_free"); // 2.24
|
||||
g_object_unref_f = (pter_ftype)dlsym(gobj, "g_object_unref");
|
||||
pter_ftype g_variant_unref_f = (pter_ftype)dlsym(glib, "g_variant_unref"); // 2.24
|
||||
g_settings_list_keys_f = (g_settings_list_keys_ftype)dlsym(gio, "g_settings_list_keys");
|
||||
g_strfreev_f = (pter_ftype)dlsym(glib, "g_strfreev");
|
||||
//g_variant_get_type_ftype g_variant_get_type_f = (g_variant_get_type_ftype)dlsym(glib, "g_variant_get_type"); // 2.24
|
||||
const unsigned *glib_major_version = (const unsigned *)dlsym(glib, "glib_major_version");
|
||||
const unsigned *glib_minor_version = (const unsigned *)dlsym(glib, "glib_minor_version");
|
||||
|
||||
// call dynamic lib functions
|
||||
if (*glib_major_version * 1000 + *glib_minor_version < 2036) {
|
||||
typedef void (*init_ftype)(void);
|
||||
init_ftype g_type_init_f = (init_ftype)dlsym(gobj, "g_type_init");
|
||||
g_type_init_f(); // necessary only if GLib version < 2.36
|
||||
}
|
||||
const char **known = g_settings_list_schemas_f(); // list of available GSettings schemas
|
||||
float ubuntu_f = 1, ubuntu_desktop_f = 1, gnome_f = 1;
|
||||
bool found = false;
|
||||
void *gvar;
|
||||
|
||||
bool ubuntu = false;
|
||||
// determine whether we run Ubuntu
|
||||
char line[400] = "";
|
||||
FILE *in = fopen("/proc/version", "r");
|
||||
if (in) {
|
||||
char *s = fgets(line, sizeof(line), in);
|
||||
fclose(in);
|
||||
if (s && strstr(line, "Ubuntu")) ubuntu = true;
|
||||
}
|
||||
|
||||
if (ubuntu) {
|
||||
gvar = value_of_key_in_schema(known, "com.ubuntu.user-interface", "scale-factor");
|
||||
if (gvar) {
|
||||
found = true;
|
||||
void *iter;
|
||||
char str[10], *str2; int v=8, v2;
|
||||
g_variant_get_f(gvar, "a{si}", &iter);
|
||||
while (g_variant_iter_loop_f(iter, "{si}", &str2, &v2)) { // read the last couple of values
|
||||
strcpy(str, str2); v = v2;
|
||||
}
|
||||
ubuntu_f = v/8.;
|
||||
// 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_unref_f(gvar);
|
||||
if (ubuntu_f != 1) {
|
||||
factor = ubuntu_f;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
gvar = value_of_key_in_schema(known, "org.gnome.desktop.interface", "scaling-factor");
|
||||
if (gvar) {
|
||||
found = true;
|
||||
unsigned v;
|
||||
g_variant_get_f(gvar, "u", &v);
|
||||
ubuntu_desktop_f = v;
|
||||
// printf("org.gnome.desktop.interface scaling-factor value=%u factor=%g\n", v, ubuntu_desktop_f);
|
||||
g_variant_unref_f(gvar);
|
||||
if (ubuntu_desktop_f != 1) {
|
||||
factor = ubuntu_desktop_f;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
gvar = value_of_key_in_schema(known, "org.gnome.settings-daemon.plugins.xsettings", "overrides");
|
||||
if (gvar) {
|
||||
void *iter;
|
||||
char *str; int v;
|
||||
//str = (char*)g_variant_get_type_f(gvar); // -> "a{sv}"
|
||||
g_variant_get_f(gvar, "a{sv}", &iter);
|
||||
g_variant_unref_f(gvar);
|
||||
gvar = NULL;
|
||||
while (g_variant_iter_loop_f(iter, "{sv}", &str, &gvar)) {
|
||||
if (strstr(str, "WindowScalingFactor") == NULL) continue;
|
||||
found = true;
|
||||
//str = (char*)g_variant_get_type_f(gvar); // -> "i"
|
||||
g_variant_get_f(gvar, "i", &v);
|
||||
gnome_f = v;
|
||||
// printf("org.gnome.settings-daemon.plugins.xsettings overrides name=%s value=%d factor=%g\n", str, v, gnome_f);
|
||||
free(str);
|
||||
break;
|
||||
}
|
||||
g_variant_iter_free_f(iter);
|
||||
if (gvar) g_variant_unref_f(gvar);
|
||||
}
|
||||
if (!found) return false;
|
||||
factor = gnome_f;
|
||||
return true;
|
||||
}
|
||||
#endif // HAVE_DLSYM && HAVE_DLFCN_H
|
||||
*/
|
||||
|
||||
// set the desktop's default scaling value
|
||||
void Fl_X11_Screen_Driver::desktop_scale_factor()
|
||||
{
|
||||
|
||||
Loading…
Reference in New Issue
Block a user