diff options
author | David Robillard <d@drobilla.net> | 2020-03-09 21:49:58 +0100 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-03-09 22:17:44 +0100 |
commit | 9be7bab7cf3c63cafa07e5a70d6c59559ffdc1de (patch) | |
tree | db882f9d08f5b91b31271cd2844cae11f64bf1dd /pugl/detail/win.c | |
parent | a303b9374dbb9eeef1a31dcad3cb0a4e9b7fd5a3 (diff) | |
download | pugl-9be7bab7cf3c63cafa07e5a70d6c59559ffdc1de.tar.gz pugl-9be7bab7cf3c63cafa07e5a70d6c59559ffdc1de.tar.bz2 pugl-9be7bab7cf3c63cafa07e5a70d6c59559ffdc1de.zip |
Add PuglEventClient and puglSendEvent()
This event makes it possible to send an arbitrary event to a view, which is
useful for many things. In particular, this method of communication with views
will wake up the event loop, unlike hacks in applications that share data in
some other way.
Diffstat (limited to 'pugl/detail/win.c')
-rw-r--r-- | pugl/detail/win.c | 29 |
1 files changed, 25 insertions, 4 deletions
diff --git a/pugl/detail/win.c b/pugl/detail/win.c index 2e0cd96..bf60ddb 100644 --- a/pugl/detail/win.c +++ b/pugl/detail/win.c @@ -47,10 +47,11 @@ # define GWLP_USERDATA (-21) #endif -#define PUGL_LOCAL_CLOSE_MSG (WM_USER + 50) -#define PUGL_LOCAL_MARK_MSG (WM_USER + 51) -#define PUGL_RESIZE_TIMER_ID 9461 -#define PUGL_URGENT_TIMER_ID 9462 +#define PUGL_LOCAL_CLOSE_MSG (WM_USER + 50) +#define PUGL_LOCAL_MARK_MSG (WM_USER + 51) +#define PUGL_LOCAL_CLIENT_MSG (WM_USER + 52) +#define PUGL_RESIZE_TIMER_ID 9461 +#define PUGL_URGENT_TIMER_ID 9462 typedef BOOL (WINAPI *PFN_SetProcessDPIAware)(void); @@ -700,6 +701,11 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam) break; case WM_SYSCHAR: return TRUE; + case PUGL_LOCAL_CLIENT_MSG: + event.client.type = PUGL_CLIENT; + event.client.data1 = (uintptr_t)wParam; + event.client.data2 = (uintptr_t)lParam; + break; case WM_QUIT: case PUGL_LOCAL_CLOSE_MSG: event.any.type = PUGL_CLOSE; @@ -738,6 +744,21 @@ puglRequestAttention(PuglView* view) return PUGL_SUCCESS; } +PuglStatus +puglSendEvent(PuglView* view, const PuglEvent* event) +{ + if (event->type == PUGL_CLIENT) { + PostMessage(view->impl->hwnd, + PUGL_LOCAL_CLIENT_MSG, + (WPARAM)event->client.data1, + (LPARAM)event->client.data2); + + return PUGL_SUCCESS; + } + + return PUGL_UNSUPPORTED_TYPE; +} + #ifndef PUGL_DISABLE_DEPRECATED PuglStatus puglWaitForEvent(PuglView* PUGL_UNUSED(view)) |