aboutsummaryrefslogtreecommitdiffstats
path: root/pugl/pugl_win.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-21 19:42:50 +0200
committerDavid Robillard <d@drobilla.net>2019-07-21 21:32:55 +0200
commit80191fb070d60e7bffd78c2ef9e43b2610f2b8ff (patch)
tree195be0ccf9b018da9f00e49185290f65a3bb5187 /pugl/pugl_win.c
parent081490898ed788a184eb74074130634ce9067174 (diff)
downloadpugl-80191fb070d60e7bffd78c2ef9e43b2610f2b8ff.tar.gz
pugl-80191fb070d60e7bffd78c2ef9e43b2610f2b8ff.tar.bz2
pugl-80191fb070d60e7bffd78c2ef9e43b2610f2b8ff.zip
Add puglRequestAttention()
Diffstat (limited to 'pugl/pugl_win.c')
-rw-r--r--pugl/pugl_win.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/pugl/pugl_win.c b/pugl/pugl_win.c
index 2e05c71..c91d383 100644
--- a/pugl/pugl_win.c
+++ b/pugl/pugl_win.c
@@ -45,6 +45,7 @@
#define PUGL_LOCAL_CLOSE_MSG (WM_USER + 50)
#define PUGL_RESIZE_TIMER_ID 9461
+#define PUGL_URGENT_TIMER_ID 9462
#define WGL_DRAW_TO_WINDOW_ARB 0x2001
#define WGL_ACCELERATION_ARB 0x2003
@@ -631,6 +632,13 @@ handleCrossing(PuglView* view, const PuglEventType type, POINT pos)
puglDispatchEvent(view, (const PuglEvent*)&ev);
}
+static void
+stopFlashing(PuglView* view)
+{
+ KillTimer(view->impl->hwnd, PUGL_URGENT_TIMER_ID);
+ FlashWindow(view->impl->hwnd, FALSE);
+}
+
static LRESULT
handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
{
@@ -671,6 +679,8 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
case WM_TIMER:
if (wParam == PUGL_RESIZE_TIMER_ID) {
puglPostRedisplay(view);
+ } else if (wParam == PUGL_URGENT_TIMER_ID) {
+ FlashWindow(view->impl->hwnd, TRUE);
}
break;
case WM_EXITSIZEMOVE:
@@ -704,6 +714,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
tme.hwndTrack = view->impl->hwnd;
TrackMouseEvent(&tme);
+ stopFlashing(view);
handleCrossing(view, PUGL_ENTER_NOTIFY, pt);
view->impl->mouseTracked = true;
}
@@ -778,6 +789,7 @@ handleMessage(PuglView* view, UINT message, WPARAM wParam, LPARAM lParam)
}
break;
case WM_SETFOCUS:
+ stopFlashing(view);
event.type = PUGL_FOCUS_IN;
break;
case WM_KILLFOCUS:
@@ -802,6 +814,15 @@ puglGrabFocus(PuglView* view)
SetFocus(view->impl->hwnd);
}
+void
+puglRequestAttention(PuglView* view)
+{
+ if (!view->impl->mouseTracked || GetFocus() != view->impl->hwnd) {
+ FlashWindow(view->impl->hwnd, TRUE);
+ SetTimer(view->impl->hwnd, PUGL_URGENT_TIMER_ID, 500, NULL);
+ }
+}
+
PuglStatus
puglWaitForEvent(PuglView* view)
{