diff options
| author | Manolo Gouy <Manolo> | 2018-09-14 14:38:06 +0000 |
|---|---|---|
| committer | Manolo Gouy <Manolo> | 2018-09-14 14:38:06 +0000 |
| commit | d23892ef523d601f68e26079d9a620119956fb21 (patch) | |
| tree | 5281b692b7a1d4f0347b448ff5b7f3f37b3731da /src | |
| parent | a0fcfa55d6a7bed7646acce0bae8da0c1f66bcf7 (diff) | |
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
Diffstat (limited to 'src')
| -rw-r--r-- | src/drivers/X11/Fl_X11_Screen_Driver.cxx | 30 |
1 files changed, 29 insertions, 1 deletions
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 <FL/Fl_Box.H> #include <FL/Fl_Image_Surface.H> #include <FL/Fl_Tooltip.H> - +#include <FL/filename.H> #include <sys/time.h> #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 <scale>#</scale> 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, "<monitors version=\"2\">")) { + while (fgets(line, sizeof(line), in)) { + if( (p = strstr(line, "<scale>")) && strstr(p, "</scale>") ) { + 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; |
