summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefano Pigozzi <stefano.pigozzi@gmail.com>2016-06-11 15:34:50 +0200
committerStefano Pigozzi <stefano.pigozzi@gmail.com>2016-06-11 15:34:50 +0200
commitef49551eb38588caff203ac195ac564065d6b153 (patch)
tree2066b8a6be63bcf91761765af65686fa5dca5857
parentde4c74e5a4a996e8ff431c8f33a32c4b580be203 (diff)
downloadmpv-lockfocus.tar.bz2
mpv-lockfocus.tar.xz
lockfocus test before swap bufferslockfocus
-rw-r--r--video/out/cocoa_common.m8
1 files changed, 8 insertions, 0 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index e1d1e18d57..3f2b32a3b3 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -699,9 +699,15 @@ void vo_cocoa_swap_buffers(struct vo *vo)
pthread_mutex_lock(&s->lock);
bool skip = s->pending_events & VO_EVENT_RESIZE;
pthread_mutex_unlock(&s->lock);
+
if (skip)
return;
+ bool focus = [s->view lockFocusIfCanDraw];
+ if (!focus) {
+ return;
+ }
+
CGLFlushDrawable(s->cgl_ctx);
pthread_mutex_lock(&s->lock);
@@ -710,6 +716,8 @@ void vo_cocoa_swap_buffers(struct vo *vo)
pthread_cond_signal(&s->wakeup);
pthread_mutex_unlock(&s->lock);
+ [s->view unlockFocus];
+
if (atomic_compare_exchange_strong(&s->waiting_frame, &(bool){true}, false))
NSEnableScreenUpdates();
}