From d23892ef523d601f68e26079d9a620119956fb21 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 14 Sep 2018 14:38:06 +0000 Subject: X11 under Ubuntu: read screen scaling information from file $HOME/.config/monitors.xml git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@13048 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/drivers/X11/Fl_X11_Screen_Driver.cxx | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/drivers/X11/Fl_X11_Screen_Driver.cxx b/src/drivers/X11/Fl_X11_Screen_Driver.cxx index d0274a10e..aceafca0f 100644 --- a/src/drivers/X11/Fl_X11_Screen_Driver.cxx +++ b/src/drivers/X11/Fl_X11_Screen_Driver.cxx @@ -28,7 +28,7 @@ #include #include #include - +#include #include #if HAVE_XINERAMA @@ -1228,6 +1228,30 @@ static bool is_name_in_list(const char *name, const char **list) { } +static bool use_monitors_xml(float &factor) { + // read file $HOME/.config/monitors.xml, search # data therein, and use it + char path[FL_PATH_MAX], line[100], *p; + bool found = false; + p = getenv("HOME"); + if (!p) return false; + strcpy(path, p); + strcat(path, "/.config/monitors.xml"); + FILE *in = fopen(path, "r"); + if (!in) return false; + p = fgets(line, sizeof(line), in); + if (strstr(line, "")) { + while (fgets(line, sizeof(line), in)) { + if( (p = strstr(line, "")) && strstr(p, "") ) { + p += 7; + sscanf(p, "%f", &factor); + found = true; + } + } + } + fclose(in); + return found; +} + // 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, ...); @@ -1267,6 +1291,9 @@ static void* value_of_key_in_schema(const char **known, const char *schema, cons 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 @@ -1351,6 +1378,7 @@ static bool gnome_scale_factor(float& factor) { } if (ubuntu) { + if (use_monitors_xml(factor)) return true; gvar = value_of_key_in_schema(known, "com.ubuntu.user-interface", "scale-factor"); if (gvar) { found = true; -- cgit v1.2.3