aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHanspeter Portner <dev@open-music-kontrollers.ch>2021-02-02 15:21:04 +0100
committerHanspeter Portner <dev@open-music-kontrollers.ch>2021-02-02 15:21:04 +0100
commit22368f0f07811c261044f8dda787efa59f3925b1 (patch)
tree8a9a8c1f4f93b3dbea6a1e720c78e3645ebc7f81
parent67581c7a0a90ce13eb1cfaef13106ce6d8b5cccc (diff)
parentbf90ec817f58f0cfcd95ddd8e0e6a04764f6be5c (diff)
downloadpatchmatrix-22368f0f07811c261044f8dda787efa59f3925b1.tar.xz
Merge commit 'bf90ec817f58f0cfcd95ddd8e0e6a04764f6be5c'
-rw-r--r--subprojects/nk_pugl/VERSION2
-rw-r--r--subprojects/nk_pugl/nk_pugl/nk_pugl.h61
2 files changed, 31 insertions, 32 deletions
diff --git a/subprojects/nk_pugl/VERSION b/subprojects/nk_pugl/VERSION
index ae51b49..8ca4b71 100644
--- a/subprojects/nk_pugl/VERSION
+++ b/subprojects/nk_pugl/VERSION
@@ -1 +1 @@
-0.1.169
+0.1.171
diff --git a/subprojects/nk_pugl/nk_pugl/nk_pugl.h b/subprojects/nk_pugl/nk_pugl/nk_pugl.h
index 43b124e..47d51b5 100644
--- a/subprojects/nk_pugl/nk_pugl/nk_pugl.h
+++ b/subprojects/nk_pugl/nk_pugl/nk_pugl.h
@@ -134,7 +134,6 @@ struct _nk_pugl_window_t {
PuglMod state;
#if !defined(__APPLE__) && !defined(_WIN32)
atomic_flag async;
- Display *disp;
#endif
};
@@ -972,39 +971,45 @@ nk_pugl_init(nk_pugl_window_t *win)
const char *NK_SCALE = getenv("NK_SCALE");
const float scale = NK_SCALE ? atof(NK_SCALE) : 1.f;
const float dpi0 = 96.f; // reference DPI we're designing for
+ float dpi1 = dpi0;
#if defined(__APPLE__)
- const float dpi1 = dpi0; //TODO implement this
+ // FIXME
#elif defined(_WIN32)
// GetDpiForSystem/Monitor/Window is Win10 only
HDC screen = GetDC(NULL);
- const float dpi1 = GetDeviceCaps(screen, LOGPIXELSX);
+ dpi1 = GetDeviceCaps(screen, LOGPIXELSX);
ReleaseDC(NULL, screen);
#else
win->async = (atomic_flag)ATOMIC_FLAG_INIT;
- win->disp = XOpenDisplay(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)
+ Display *disp = XOpenDisplay(0);
+ if(disp)
{
- XrmDatabase db = XrmGetStringDatabase(resource_string);
- if(db)
- {
- char *type = NULL;
- XrmValue value;
+ // modern X actually lies here, but proprietary nvidia
+ dpi1 = XDisplayWidth(disp, 0) * 25.4f / XDisplayWidthMM(disp, 0);
- XrmGetResource(db, "Xft.dpi", "String", &type, &value);
- if(value.addr)
+ // read DPI from users's ~/.Xresources
+ char *resource_string = XResourceManagerString(disp);
+ XrmInitialize();
+ if(resource_string)
+ {
+ XrmDatabase db = XrmGetStringDatabase(resource_string);
+ if(db)
{
- dpi1 = atof(value.addr);
- }
+ char *type = NULL;
+ XrmValue value;
- XrmDestroyDatabase(db);
+ XrmGetResource(db, "Xft.dpi", "String", &type, &value);
+ if(value.addr)
+ {
+ dpi1 = atof(value.addr);
+ }
+
+ XrmDestroyDatabase(db);
+ }
}
+
+ XCloseDisplay(disp);
}
#endif
@@ -1166,13 +1171,6 @@ nk_pugl_shutdown(nk_pugl_window_t *win)
puglFreeWorld(win->world);
}
-
-#if !defined(__APPLE__) && !defined(_WIN32)
- if(win->disp)
- {
- XCloseDisplay(win->disp);
- }
-#endif
}
NK_PUGL_API void
@@ -1242,10 +1240,11 @@ nk_pugl_async_redisplay(nk_pugl_window_t *win)
const int status = SendNotifyMessage(widget, WM_PAINT, 0, 0);
(void)status;
#else
+ Display *disp = puglGetNativeWorld(win->world);
const Window widget = (Window)win->widget;
XExposeEvent xevent = {
.type = Expose,
- .display = win->disp,
+ .display = disp,
.window = widget
};
@@ -1254,10 +1253,10 @@ nk_pugl_async_redisplay(nk_pugl_window_t *win)
// spin
}
- const Status status = XSendEvent(win->disp, widget, false, ExposureMask,
+ const Status status = XSendEvent(disp, widget, false, ExposureMask,
(XEvent *)&xevent);
(void)status;
- XFlush(win->disp);
+ XFlush(disp);
atomic_flag_clear_explicit(&win->async, memory_order_release);
#endif