diff options
| author | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-03-11 16:20:29 +0100 |
|---|---|---|
| committer | ManoloFLTK <41016272+ManoloFLTK@users.noreply.github.com> | 2019-03-11 16:20:29 +0100 |
| commit | 4e2ba8c888d650f566d43f58a525566c97f55a35 (patch) | |
| tree | 96da156f00820720ee66e371dc4731fa4312cc5c /src/Fl_x.cxx | |
| parent | 347581e3b4d6ee47a05c9dacba79684a623f6f0f (diff) | |
X11 platform: follow when the OS changes the Xft.dpi resource
Under gnome, Tweaks -> Fonts ->Scaling factor allows to change
the size of all fonts handled by gnome.
With that change, FLTK apps obey to changes to Xft.dpi.
Diffstat (limited to 'src/Fl_x.cxx')
| -rw-r--r-- | src/Fl_x.cxx | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/Fl_x.cxx b/src/Fl_x.cxx index 212f14db2..0d63218cd 100644 --- a/src/Fl_x.cxx +++ b/src/Fl_x.cxx @@ -1267,6 +1267,28 @@ static void react_to_screen_reconfiguration() { } #endif // USE_XRANDR +#if USE_XFT +static void after_display_rescale(float *p_current_xft_dpi) { + FILE *pipe = popen("xrdb -query", "r"); + if (!pipe) return; + char line[100]; + while (fgets(line, sizeof(line), pipe) != NULL) { + if (memcmp(line, "Xft.dpi:", 8)) continue; + float dpi; + if (sscanf(line+8, "%f", &dpi) == 1) { + //fprintf(stderr," previous=%g dpi=%g \n", *p_current_xft_dpi, dpi); + if (fabs(dpi - *p_current_xft_dpi) > 0.01) { + *p_current_xft_dpi = dpi; + float f = dpi/96.; + for (int i = 0; i < Fl::screen_count(); i++) + Fl::screen_driver()->rescale_all_windows_from_screen(i, f); + } + } + break; + } + pclose(pipe); +} +#endif // USE_XFT int fl_handle(const XEvent& thisevent) { @@ -1305,7 +1327,11 @@ int fl_handle(const XEvent& thisevent) #endif // USE_XRANDR if (xevent.type == PropertyNotify && xevent.xproperty.atom == fl_NET_WORKAREA) { - ((Fl_X11_Screen_Driver*)Fl::screen_driver())->init_workarea(); + Fl_X11_Screen_Driver *d = (Fl_X11_Screen_Driver*)Fl::screen_driver(); + d->init_workarea(); +#if USE_XFT + after_display_rescale(&(d->current_xft_dpi)); +#endif // USE_XFT } switch (xevent.type) { |
