diff options
author | David Robillard <d@drobilla.net> | 2019-07-21 19:42:50 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2019-07-21 21:32:55 +0200 |
commit | 80191fb070d60e7bffd78c2ef9e43b2610f2b8ff (patch) | |
tree | 195be0ccf9b018da9f00e49185290f65a3bb5187 /pugl/pugl_osx.m | |
parent | 081490898ed788a184eb74074130634ce9067174 (diff) | |
download | pugl-80191fb070d60e7bffd78c2ef9e43b2610f2b8ff.tar.gz pugl-80191fb070d60e7bffd78c2ef9e43b2610f2b8ff.tar.bz2 pugl-80191fb070d60e7bffd78c2ef9e43b2610f2b8ff.zip |
Add puglRequestAttention()
Diffstat (limited to 'pugl/pugl_osx.m')
-rw-r--r-- | pugl/pugl_osx.m | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m index 73fe654..7a804b7 100644 --- a/pugl/pugl_osx.m +++ b/pugl/pugl_osx.m @@ -101,6 +101,7 @@ struct PuglInternalsImpl { PuglView* puglview; NSTrackingArea* trackingArea; NSTimer* timer; + NSTimer* urgentTimer; } @end @@ -544,6 +545,11 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) puglPostRedisplay(puglview); } +- (void) urgentTick +{ + [NSApp requestUserAttention:NSInformationalRequest]; +} + - (void) viewDidEndLiveResize { [super viewDidEndLiveResize]; @@ -582,6 +588,12 @@ handleCrossing(PuglOpenGLView* view, NSEvent* event, const PuglEventType type) - (void) windowDidBecomeKey:(NSNotification*)notification { + PuglOpenGLView* glview = window->puglview->impl->glview; + if (window->puglview->impl->glview->urgentTimer) { + [glview->urgentTimer invalidate]; + glview->urgentTimer = NULL; + } + const PuglEventFocus ev = { PUGL_FOCUS_IN, window->puglview, 0, false }; puglDispatchEvent(window->puglview, (const PuglEvent*)&ev); } @@ -740,6 +752,20 @@ puglGrabFocus(PuglView* view) [view->impl->window makeKeyWindow]; } +void +puglRequestAttention(PuglView* view) +{ + if (![view->impl->window isKeyWindow]) { + [NSApp requestUserAttention:NSInformationalRequest]; + view->impl->glview->urgentTimer = + [NSTimer scheduledTimerWithTimeInterval:2.0 + target:view->impl->glview + selector:@selector(urgentTick) + userInfo:nil + repeats:YES]; + } +} + PuglStatus puglWaitForEvent(PuglView* view) { |