From 66693662800443fd3e28c57f665d50b232b46596 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Tue, 25 Jun 2013 19:28:08 +0200 Subject: cocoa_common: schedule a redraw frame after a non live resize A redraw forces recalculation of panscan and other stuff not accounted for in the resize_redraw codepath. This is actually a hack but works really well in my tests. Thanks @wm4 and @Cpuroast for the idea. Fixes #86 [ci skip] --- video/out/cocoa_common.m | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'video') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 0e61b7ea71..93491dcf8d 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -82,6 +82,7 @@ struct vo_cocoa_state { bool did_resize; bool did_async_resize; bool out_fs_resize; + bool want_redraw; IOPMAssertionID power_mgmt_assertion; @@ -98,6 +99,7 @@ static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo) *s = (struct vo_cocoa_state){ .did_resize = NO, .did_async_resize = NO, + .want_redraw = NO, .current_video_size = {0,0}, .previous_video_size = {0,0}, .out_fs_resize = NO, @@ -507,6 +509,11 @@ int vo_cocoa_check_events(struct vo *vo) return VO_EVENT_RESIZE; } + if (s->want_redraw) { + s->want_redraw = NO; + vo->want_redraw = true; + } + return 0; } @@ -902,10 +909,18 @@ int vo_cocoa_cgl_color_size(struct vo *vo) struct vo *vo = [self videoOutput]; if (vo && resize_callback_registered(vo)) { - NSSize size = to_pixels(vo, [self bounds]).size; - resize_redraw(vo, size.width, size.height); + if ([self inLiveResize]) { + NSSize size = to_pixels(vo, [self bounds]).size; + resize_redraw(vo, size.width, size.height); + } else { + // If not in live resize window was probably resized from + // fullscreen toggle or resize. Make sure we invoke a real repaint + // ASAP so that the displayed image is correct. + struct vo_cocoa_state *s = vo->cocoa; + s->want_redraw = YES; + } } else { - [[NSColor clearColor] set]; + [[NSColor blackColor] set]; NSRectFill([self bounds]); } } -- cgit v1.2.3