aboutsummaryrefslogtreecommitdiff
path: root/nk_pugl
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2018-01-06 21:50:56 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2018-01-06 21:50:56 +0100
commit88187148733705eecb813d319b909273c457a86f (patch)
tree652a17efd49cdf87a7df901d9291784fb862ad1b /nk_pugl
parent0222ccba317ff65e3635ae27956c50b5c0140305 (diff)
parentce0b15df6dda2a5b882dd757a3eeb8c8f5343cdb (diff)
downloadsynthpod-88187148733705eecb813d319b909273c457a86f.tar.xz
Merge commit 'ce0b15df6dda2a5b882dd757a3eeb8c8f5343cdb'
Diffstat (limited to 'nk_pugl')
-rw-r--r--nk_pugl/nk_pugl.h26
1 files changed, 25 insertions, 1 deletions
diff --git a/nk_pugl/nk_pugl.h b/nk_pugl/nk_pugl.h
index f8b24a23..2734093c 100644
--- a/nk_pugl/nk_pugl.h
+++ b/nk_pugl/nk_pugl.h
@@ -37,6 +37,7 @@ extern C {
#if !defined(__APPLE__) && !defined(_WIN32)
# include "GL/glx.h"
# include "GL/glext.h"
+# include <X11/Xresource.h>
#endif
#define NK_ZERO_COMMAND_MEMORY
@@ -400,6 +401,7 @@ _nk_pugl_font_init(nk_pugl_window_t *win)
nk_pugl_config_t *cfg = &win->cfg;
const int font_size = cfg->font.size * win->scale;
+ fprintf(stderr, ":: %f %i\n", win->scale, font_size);
// init nuklear font
struct nk_font *ttf = NULL;
@@ -999,7 +1001,29 @@ nk_pugl_init(nk_pugl_window_t *win)
#else
win->async = (atomic_flag)ATOMIC_FLAG_INIT;
win->disp = XOpenDisplay(0);
- const float dpi1 = XDisplayWidth(win->disp, 0) * 25.4f / XDisplayWidthMM(win->disp, 0);
+ // modern X actually lies here, but proprietary nvidia
+ float dpi1 = XDisplayWidth(win->disp, 0) * 25.4f / XDisplayWidthMM(win->disp, 0);
+
+ // read DPI from users's ~/.Xresources
+ char *resource_string = XResourceManagerString(win->disp);
+ XrmInitialize();
+ if(resource_string)
+ {
+ XrmDatabase db = XrmGetStringDatabase(resource_string);
+ if(db)
+ {
+ char *type = NULL;
+ XrmValue value;
+
+ XrmGetResource(db, "Xft.dpi", "String", &type, &value);
+ if(value.addr)
+ {
+ dpi1 = atof(value.addr);
+ }
+ }
+ }
+
+ fprintf(stderr, ":: %f\n", dpi1);
#endif
win->scale = scale * dpi1 / dpi0;