aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2019-07-21 14:31:07 +0200
committerDavid Robillard <d@drobilla.net>2019-07-21 14:44:19 +0200
commitae9a099569c366863ee448b6bdc2c0dec1e45203 (patch)
tree2c6261144859eeeac31901eb63b92dc1a094e414
parent17a09847f45d08056a12b27b0ef665e97626694b (diff)
Draw during resizing on MacOS
Unfortunately drawing still stalls if the user just grabs the resize handle until the first resize event happens, but it seems to be impossible to fix this without using another thread.
-rw-r--r--pugl/pugl_osx.m34
1 files changed, 32 insertions, 2 deletions
diff --git a/pugl/pugl_osx.m b/pugl/pugl_osx.m
index 3b6919d..273002a 100644
--- a/pugl/pugl_osx.m
+++ b/pugl/pugl_osx.m
@@ -115,9 +115,9 @@ struct PuglInternalsImpl {
@interface PuglOpenGLView : NSOpenGLView
{
@public
- PuglView* puglview;
-
+ PuglView* puglview;
NSTrackingArea* trackingArea;
+ NSTimer* timer;
}
- (id) initWithFrame:(NSRect)frame;
@@ -537,6 +537,36 @@ keySymToSpecial(PuglView* view, NSEvent* ev)
puglview->impl->mods = mods;
}
+- (BOOL) preservesContentInLiveResize
+{
+ return NO;
+}
+
+- (void) viewWillStartLiveResize
+{
+ timer = [NSTimer timerWithTimeInterval:(1 / 60.0)
+ target:self
+ selector:@selector(resizeTick)
+ userInfo:nil
+ repeats:YES];
+ [[NSRunLoop currentRunLoop] addTimer:timer
+ forMode:NSRunLoopCommonModes];
+
+ [super viewWillStartLiveResize];
+}
+
+- (void) resizeTick
+{
+ puglPostRedisplay(puglview);
+}
+
+- (void) viewDidEndLiveResize
+{
+ [super viewDidEndLiveResize];
+ [timer invalidate];
+ timer = NULL;
+}
+
@end
PuglInternals*