aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/detail/win.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-03-16 20:32:28 +0100
committerDavid Robillard <d@drobilla.net>2020-03-16 21:21:15 +0100
commita54361853bdfa08437c2858e603ce6202fb341b2 (patch)
tree5e86a841cc14dd4ca04d7b7b54b05f9c37e6feaf /pugl/detail/win.c
parent7de08cd2a57d26f546060183944632da71f643f2 (diff)
downloadpugl-a54361853bdfa08437c2858e603ce6202fb341b2.tar.gz
pugl-a54361853bdfa08437c2858e603ce6202fb341b2.tar.bz2
pugl-a54361853bdfa08437c2858e603ce6202fb341b2.zip
Add timer events
Diffstat (limited to 'pugl/detail/win.c')
-rw-r--r--pugl/detail/win.c22
1 files changed, 22 insertions, 0 deletions
diff --git a/pugl/detail/win.c b/pugl/detail/win.c
index cb4dfad..971ecdd 100644
--- a/pugl/detail/win.c
+++ b/pugl/detail/win.c
@@ -51,6 +51,7 @@
#define PUGL_LOCAL_CLIENT_MSG (WM_USER + 52)
#define PUGL_RESIZE_TIMER_ID 9461
#define PUGL_URGENT_TIMER_ID 9462
+#define PUGL_USER_TIMER_MIN 9470
typedef BOOL (WINAPI *PFN_SetProcessDPIAware)(void);
@@ -589,6 +590,9 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
RDW_INVALIDATE|RDW_ALLCHILDREN|RDW_INTERNALPAINT);
} else if (wParam == PUGL_URGENT_TIMER_ID) {
FlashWindow(view->impl->hwnd, TRUE);
+ } else if (wParam >= PUGL_USER_TIMER_MIN) {
+ const PuglEventTimer ev = {PUGL_TIMER, 0, wParam - PUGL_USER_TIMER_MIN};
+ puglDispatchEvent(view, (const PuglEvent*)&ev);
}
break;
case WM_EXITSIZEMOVE:
@@ -742,6 +746,24 @@ puglRequestAttention(PuglView* view)
}
PuglStatus
+puglStartTimer(PuglView* view, uintptr_t id, double timeout)
+{
+ const UINT msec = (UINT)floor(timeout * 1000.0);
+
+ return (SetTimer(view->impl->hwnd, PUGL_USER_TIMER_MIN + id, msec, NULL)
+ ? PUGL_SUCCESS
+ : PUGL_UNKNOWN_ERROR);
+}
+
+PuglStatus
+puglStopTimer(PuglView* view, uintptr_t id)
+{
+ return (KillTimer(view->impl->hwnd, PUGL_USER_TIMER_MIN + id)
+ ? PUGL_SUCCESS
+ : PUGL_UNKNOWN_ERROR);
+}
+
+PuglStatus
puglSendEvent(PuglView* view, const PuglEvent* event)
{
if (event->type == PUGL_CLIENT) {