From a05c5b4ec64da5630a29e9507357e662675e22e4 Mon Sep 17 00:00:00 2001 From: Akemi Date: Fri, 30 Dec 2016 17:46:50 +0100 Subject: cocoa: fix handling of geometry option This flips the y-coordinate to be consistent with other platforms and the manual. furthermore it fixes an unwanted behaviour of the cocoa convertRectFromBacking method, where the x- and y-coordinate was divided by the same factor as the width and height instead of placing the new scaled rectangle at the same relative position as the original unscaled rectangle, by manually calculating the new position. Fixes #3867 --- video/out/cocoa_common.m | 34 +++++++++++++++++++++++++++------- 1 file changed, 27 insertions(+), 7 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 164663c332..f4d2562acd 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -113,14 +113,36 @@ static void run_on_main_thread(struct vo *vo, void(^block)(void)) dispatch_sync(dispatch_get_main_queue(), block); } +static NSRect calculate_window_geometry(struct vo *vo, NSRect rect) +{ + struct vo_cocoa_state *s = vo->cocoa; + struct mp_vo_opts *opts = vo->opts; + + NSRect screenFrame = [s->current_screen frame]; + rect.origin.y = screenFrame.size.height - (rect.origin.y + rect.size.height); + + if(!opts->hidpi_window_scale) { + NSRect oldRect = rect; + rect = [s->current_screen convertRectFromBacking:rect]; + + CGFloat x_per = screenFrame.size.width - oldRect.size.width; + CGFloat y_per = screenFrame.size.height - oldRect.size.height; + if (x_per > 0) x_per = oldRect.origin.x/x_per; + if (y_per > 0) y_per = oldRect.origin.y/y_per; + + rect.origin.x = (screenFrame.size.width - rect.size.width)*x_per; + rect.origin.y = (screenFrame.size.height - rect.size.height)*y_per; + } + + return rect; +} + static void queue_new_video_size(struct vo *vo, int w, int h) { struct vo_cocoa_state *s = vo->cocoa; struct mp_vo_opts *opts = vo->opts; id win = (id) s->window; - NSRect r = NSMakeRect(0, 0, w, h); - if(!opts->hidpi_window_scale) - r = [s->current_screen convertRectFromBacking:r]; + NSRect r = calculate_window_geometry(vo, NSMakeRect(0, 0, w, h)); [win queueNewVideoSize:NSMakeSize(r.size.width, r.size.height)]; } @@ -472,10 +494,8 @@ static void create_ui(struct vo *vo, struct mp_rect *win, int geo_flags) if (s->embedded) { parent = (NSView *) (intptr_t) opts->WinID; } else { - NSRect wr = - NSMakeRect(win->x0, win->y0, win->x1 - win->x0, win->y1 - win->y0); - if(!opts->hidpi_window_scale) - wr = [s->current_screen convertRectFromBacking:wr]; + NSRect wr = calculate_window_geometry(vo, + NSMakeRect(win->x0, win->y0, win->x1 - win->x0, win->y1 - win->y0)); s->window = create_window(wr, s->current_screen, opts->border, adapter); parent = [s->window contentView]; } -- cgit v1.2.3 From 46b74a38f11e9ff2808fc151a329a260d4ac8d90 Mon Sep 17 00:00:00 2001 From: Akemi Date: Thu, 15 Dec 2016 22:12:46 +0100 Subject: cocoa: add border cycling Fixes #2430 --- video/out/cocoa_common.m | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index f4d2562acd..58b0df518f 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -552,6 +552,20 @@ static int cocoa_set_window_title(struct vo *vo) return VO_TRUE; } +static int vo_cocoa_window_border(struct vo *vo) +{ + struct vo_cocoa_state *s = vo->cocoa; + if (s->embedded) + return VO_NOTIMPL; + + struct mp_vo_opts *opts = vo->opts; + [s->window updateBorder:opts->border]; + if (opts->border) + cocoa_set_window_title(vo); + + return VO_TRUE; +} + static void cocoa_screen_reconfiguration_observer( CGDirectDisplayID display, CGDisplayChangeSummaryFlags flags, void *ctx) { @@ -747,6 +761,8 @@ static int vo_cocoa_control_on_main_thread(struct vo *vo, int request, void *arg return VO_TRUE; case VOCTRL_ONTOP: return vo_cocoa_ontop(vo); + case VOCTRL_BORDER: + return vo_cocoa_window_border(vo); case VOCTRL_GET_UNFS_WINDOW_SIZE: { int *sz = arg; NSSize size = [s->view frame].size; -- cgit v1.2.3 From 449eb208f4d312c1bde616259d44d4d36112a603 Mon Sep 17 00:00:00 2001 From: Akemi Date: Sat, 17 Dec 2016 20:53:09 +0100 Subject: cocoa: rate limit video output the display refresh rate can't be estimated correctly in some cases and just increases till it turns off display-resample. cases are off-screen rendering (different space), mpv being completely hidden behind another window or the mission control view. this utilise the unused displaylink callback to limit the refresh rate to the actual display refresh rate. --- video/out/cocoa_common.m | 65 +++++++++++++++++++++++++++++++++++++----------- 1 file changed, 51 insertions(+), 14 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 58b0df518f..0b10217f80 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -87,6 +87,11 @@ struct vo_cocoa_state { uint32_t old_dwidth; uint32_t old_dheight; + CVDisplayLinkRef link; + pthread_mutex_t sync_lock; + pthread_cond_t sync_wakeup; + uint64_t sync_counter; + pthread_mutex_t lock; pthread_cond_t wakeup; @@ -305,6 +310,26 @@ static void vo_cocoa_update_screen_info(struct vo *vo) } } +static void vo_cocoa_init_displaylink(struct vo *vo) +{ + struct vo_cocoa_state *s = vo->cocoa; + + NSDictionary* sinfo = [s->current_screen deviceDescription]; + NSNumber* sid = [sinfo objectForKey:@"NSScreenNumber"]; + CGDirectDisplayID did = [sid longValue]; + + CVDisplayLinkCreateWithCGDisplay(did, &s->link); + CVDisplayLinkSetOutputCallback(s->link, &displayLinkCallback, vo); + CVDisplayLinkStart(s->link); +} + +static void vo_cocoa_uninit_displaylink(struct vo_cocoa_state *s) +{ + if (CVDisplayLinkIsRunning(s->link)) + CVDisplayLinkStop(s->link); + CVDisplayLinkRelease(s->link); +} + void vo_cocoa_init(struct vo *vo) { struct vo_cocoa_state *s = talloc_zero(NULL, struct vo_cocoa_state); @@ -321,6 +346,8 @@ void vo_cocoa_init(struct vo *vo) } pthread_mutex_init(&s->lock, NULL); pthread_cond_init(&s->wakeup, NULL); + pthread_mutex_init(&s->sync_lock, NULL); + pthread_cond_init(&s->sync_wakeup, NULL); vo->cocoa = s; vo_cocoa_update_screen_info(vo); cocoa_init_light_sensor(vo); @@ -362,6 +389,10 @@ void vo_cocoa_uninit(struct vo *vo) run_on_main_thread(vo, ^{ enable_power_management(s); + vo_cocoa_uninit_displaylink(s); + pthread_mutex_lock(&s->sync_lock); + pthread_cond_signal(&s->sync_wakeup); + pthread_mutex_unlock(&s->sync_lock); cocoa_uninit_light_sensor(s); cocoa_rm_screen_reconfiguration_observer(vo); @@ -384,6 +415,8 @@ void vo_cocoa_uninit(struct vo *vo) if (!s->embedded) [s->blankCursor release]; + pthread_cond_destroy(&s->sync_wakeup); + pthread_mutex_destroy(&s->sync_lock); pthread_cond_destroy(&s->wakeup); pthread_mutex_destroy(&s->lock); talloc_free(s); @@ -398,30 +431,19 @@ static void vo_cocoa_update_screen_fps(struct vo *vo) NSNumber* sid = [sinfo objectForKey:@"NSScreenNumber"]; CGDirectDisplayID did = [sid longValue]; - CVDisplayLinkRef link; - CVDisplayLinkCreateWithCGDisplay(did, &link); - CVDisplayLinkSetOutputCallback(link, &displayLinkCallback, NULL); - CVDisplayLinkStart(link); - CVDisplayLinkSetCurrentCGDisplay(link, did); - - double display_period = CVDisplayLinkGetActualOutputVideoRefreshPeriod(link); + CVDisplayLinkSetCurrentCGDisplay(s->link, did); + double display_period = CVDisplayLinkGetActualOutputVideoRefreshPeriod(s->link); if (display_period > 0) { s->screen_fps = 1/display_period; } else { - // Fallback to using Nominal refresh rate from DisplayLink, - // CVDisplayLinkGet *Actual* OutputVideoRefreshPeriod seems to - // return 0 on some Apple devices. Use the nominal refresh period - // instead. - const CVTime t = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(link); + const CVTime t = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(s->link); if (!(t.flags & kCVTimeIsIndefinite)) { s->screen_fps = (t.timeScale / (double) t.timeValue); MP_VERBOSE(vo, "Falling back to %f for display sync.\n", s->screen_fps); } } - CVDisplayLinkRelease(link); - flag_events(vo, VO_EVENT_WIN_STATE); } @@ -429,6 +451,13 @@ static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeSt const CVTimeStamp* outputTime, CVOptionFlags flagsIn, CVOptionFlags* flagsOut, void* displayLinkContext) { + struct vo *vo = displayLinkContext; + struct vo_cocoa_state *s = vo->cocoa; + + pthread_mutex_lock(&s->sync_lock); + s->sync_counter += 1; + pthread_cond_signal(&s->sync_wakeup); + pthread_mutex_unlock(&s->sync_lock); return kCVReturnSuccess; } @@ -603,6 +632,7 @@ int vo_cocoa_config_window(struct vo *vo) struct mp_vo_opts *opts = vo->opts; run_on_main_thread(vo, ^{ + vo_cocoa_init_displaylink(vo); vo_cocoa_update_screen_fps(vo); NSRect r = [s->current_screen frame]; @@ -700,6 +730,13 @@ void vo_cocoa_swap_buffers(struct vo *vo) if (skip) return; + pthread_mutex_lock(&s->sync_lock); + uint64_t old_counter = s->sync_counter; + while(old_counter == s->sync_counter) { + pthread_cond_wait(&s->sync_wakeup, &s->sync_lock); + } + pthread_mutex_unlock(&s->sync_lock); + pthread_mutex_lock(&s->lock); s->frame_w = vo->dwidth; s->frame_h = vo->dheight; -- cgit v1.2.3 From fee5ceccad7d021503b278a7b5dd596efa030ba1 Mon Sep 17 00:00:00 2001 From: Akemi Date: Thu, 29 Dec 2016 20:04:44 +0100 Subject: cocoa: don't change Space on quit in fullscreen circumvent undefined behavior when quitting in fullscreen. Fixes #3957 --- video/out/cocoa_common.m | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 0b10217f80..d00d5d78c7 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -387,6 +387,16 @@ void vo_cocoa_uninit(struct vo *vo) pthread_cond_signal(&s->wakeup); pthread_mutex_unlock(&s->lock); + // close window beforehand to prevent undefined behavior when in fullscreen + // that resets the desktop to space 1 + run_on_main_thread(vo, ^{ + // if using --wid + libmpv there's no window to release + if (s->window) { + [s->window setDelegate:nil]; + [s->window close]; + } + }); + run_on_main_thread(vo, ^{ enable_power_management(s); vo_cocoa_uninit_displaylink(s); @@ -406,12 +416,6 @@ void vo_cocoa_uninit(struct vo *vo) [s->view removeFromSuperview]; [s->view release]; - // if using --wid + libmpv there's no window to release - if (s->window) { - [s->window setDelegate:nil]; - [s->window close]; - } - if (!s->embedded) [s->blankCursor release]; -- cgit v1.2.3 From fe02e5023c4966a4d97a0999eca92c68be8aa15e Mon Sep 17 00:00:00 2001 From: Akemi Date: Sat, 14 Jan 2017 17:10:08 +0100 Subject: cocoa: move updateBorder method to the protocol we are calling the method on a NSWindow object that may not respond to that call, since its a method of MpvVideoWindow. add the method to our protocol and rename that protocol to reflect the change. --- video/out/cocoa_common.m | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index d00d5d78c7..bf702c4cd4 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -146,7 +146,7 @@ static void queue_new_video_size(struct vo *vo, int w, int h) { struct vo_cocoa_state *s = vo->cocoa; struct mp_vo_opts *opts = vo->opts; - id win = (id) s->window; + id win = (id) s->window; NSRect r = calculate_window_geometry(vo, NSMakeRect(0, 0, w, h)); [win queueNewVideoSize:NSMakeSize(r.size.width, r.size.height)]; } @@ -592,7 +592,8 @@ static int vo_cocoa_window_border(struct vo *vo) return VO_NOTIMPL; struct mp_vo_opts *opts = vo->opts; - [s->window updateBorder:opts->border]; + id win = (id) s->window; + [win updateBorder:opts->border]; if (opts->border) cocoa_set_window_title(vo); -- cgit v1.2.3 From 9490b628c57e109b8e504dafeb43f409885c0337 Mon Sep 17 00:00:00 2001 From: Akemi Date: Wed, 18 Jan 2017 17:22:32 +0100 Subject: cocoa: don't init displaylink on reconfig everytime we switched to a new video file a new displaylink was initialised and started, but the old one was not stopped and released beforehand. this lead to several displaylink callback calls per swap, depending on how many files were switched beforehand. moving the displaylink init call to the cocoa init functions will ever only init one displaylink. Fixes #4031 --- video/out/cocoa_common.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index bf702c4cd4..2d4a4c517c 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -350,6 +350,7 @@ void vo_cocoa_init(struct vo *vo) pthread_cond_init(&s->sync_wakeup, NULL); vo->cocoa = s; vo_cocoa_update_screen_info(vo); + vo_cocoa_init_displaylink(vo); cocoa_init_light_sensor(vo); cocoa_add_screen_reconfiguration_observer(vo); if (!s->embedded) { @@ -637,7 +638,6 @@ int vo_cocoa_config_window(struct vo *vo) struct mp_vo_opts *opts = vo->opts; run_on_main_thread(vo, ^{ - vo_cocoa_init_displaylink(vo); vo_cocoa_update_screen_fps(vo); NSRect r = [s->current_screen frame]; -- cgit v1.2.3 From 954625c1655ae9e0c016d6c5ea902ed369510c71 Mon Sep 17 00:00:00 2001 From: Akemi Date: Thu, 19 Jan 2017 20:51:35 +0100 Subject: cocoa: fix unwanted behavior with window level other than the default setting a window level other than NSNormalWindowLevel always sets NSWindowCollectionBehaviorTransient, which prevents certain things to work properly. examples are automatic switching to the active Space when mpv is made active and (de-)miniaturizing. latter always lead to a vanishing window. Fixes #1757 #1884 --- video/out/cocoa_common.m | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 2d4a4c517c..7eeb7163a1 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -478,8 +478,10 @@ static void vo_set_level(struct vo *vo, int ontop) s->window_level = NSNormalWindowLevel; } - [[s->view window] setLevel:s->window_level]; - [s->window setLevel:s->window_level]; + [s->window setLevel:s->window_level]; + NSWindowCollectionBehavior behavior = [s->window collectionBehavior] & + ~NSWindowCollectionBehaviorTransient; + [s->window setCollectionBehavior:behavior|NSWindowCollectionBehaviorManaged]; } static int vo_cocoa_ontop(struct vo *vo) -- cgit v1.2.3 From f39a1cb1b0214ee3fb0640e11c1eeea6b3af47eb Mon Sep 17 00:00:00 2001 From: Akemi Date: Fri, 27 Jan 2017 20:41:40 +0100 Subject: cocoa: fix displaylink refresh rate retrieval we are dealing with several problems here, which weren't apparent because we always initialised a new displaylink for the display refresh rate retrieval, previously to commit 449eb20 and bug 9490b62. just changing the display with CVDisplayLinkSetCurrentCGDisplay can cause inconsistent refresh rates and discontinuity in timestamps. this can either lead to bogus values for the Actual display refresh rate or retrieving the refresh rate of the previous display if we immediately try to get a new value. since the Actual refresh rate is computed i assume that it at least needs one refresh period to actual return something useful. furthermore when changing the screen and updating the displaylink, it seems that the retrieved refresh rates for the screen mpv wasn't opened on are being estimated in a sub-optimal way. as an example, when moving my window to my second screen the Actual refresh rate was always a constant 60Hz, even though it is supposed to fluctuate a little bit. though if mpv was started on the secondary screen the Actual refresh rate fluctuated around 59.94Hz like expected. in that case my primary screen always reported a constant 60Hz instead. for the first problem we moved the actual retrieval of the refresh rate to the very last moment when mpv actual requests a new value and not when the refresh rate changed. we only update the displaylink itself when a possible refresh rate change is detected. this gives the displaylink some time to calculate the new refresh rate. for the second problem, instead of setting the new display we completely uninitialise the old dislaylink and create a new one for the new screen. this gives us properly estimated refresh rates. additionally we also optimised the display refresh rate fallback heuristic. it will never be 0 anymore and we prevent it from returning bogus values with a simple threshold for the difference of the Actual and Nominal refresh rate. --- video/out/cocoa_common.m | 52 +++++++++++++++++++++++++++--------------------- 1 file changed, 29 insertions(+), 23 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 7eeb7163a1..5dda9c578c 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -69,7 +69,6 @@ struct vo_cocoa_state { NSOpenGLContext *nsgl_ctx; NSScreen *current_screen; - double screen_fps; NSInteger window_level; int fullscreen; @@ -428,28 +427,39 @@ void vo_cocoa_uninit(struct vo *vo) }); } -static void vo_cocoa_update_screen_fps(struct vo *vo) +static void vo_cocoa_update_displaylink(struct vo *vo) { struct vo_cocoa_state *s = vo->cocoa; - NSDictionary* sinfo = [s->current_screen deviceDescription]; - NSNumber* sid = [sinfo objectForKey:@"NSScreenNumber"]; - CGDirectDisplayID did = [sid longValue]; + vo_cocoa_uninit_displaylink(s); + vo_cocoa_init_displaylink(vo); - CVDisplayLinkSetCurrentCGDisplay(s->link, did); - double display_period = CVDisplayLinkGetActualOutputVideoRefreshPeriod(s->link); + flag_events(vo, VO_EVENT_WIN_STATE); +} - if (display_period > 0) { - s->screen_fps = 1/display_period; - } else { - const CVTime t = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(s->link); - if (!(t.flags & kCVTimeIsIndefinite)) { - s->screen_fps = (t.timeScale / (double) t.timeValue); - MP_VERBOSE(vo, "Falling back to %f for display sync.\n", s->screen_fps); +static double vo_cocoa_update_screen_fps(struct vo *vo) +{ + struct vo_cocoa_state *s = vo->cocoa; + double actual_fps = CVDisplayLinkGetActualOutputVideoRefreshPeriod(s->link); + const CVTime t = CVDisplayLinkGetNominalOutputVideoRefreshPeriod(s->link); + + if (!(t.flags & kCVTimeIsIndefinite)) { + double nominal_fps = (t.timeScale / (double) t.timeValue); + + if (actual_fps > 0) + actual_fps = 1/actual_fps; + + if (fabs(actual_fps - nominal_fps) > 0.1) { + MP_VERBOSE(vo, "Falling back to nominal display " + "refresh rate: %fHz\n", nominal_fps); + return nominal_fps; + } else { + return actual_fps; } } - flag_events(vo, VO_EVENT_WIN_STATE); + MP_WARN(vo, "Falling back to standard display refresh rate: 60Hz\n"); + return 60.0; } static CVReturn displayLinkCallback(CVDisplayLinkRef displayLink, const CVTimeStamp* now, @@ -609,7 +619,7 @@ static void cocoa_screen_reconfiguration_observer( if (flags & kCGDisplaySetModeFlag) { struct vo *vo = ctx; MP_WARN(vo, "detected display mode change, updating screen info\n"); - vo_cocoa_update_screen_fps(vo); + vo_cocoa_update_displaylink(vo); } } @@ -640,8 +650,6 @@ int vo_cocoa_config_window(struct vo *vo) struct mp_vo_opts *opts = vo->opts; run_on_main_thread(vo, ^{ - vo_cocoa_update_screen_fps(vo); - NSRect r = [s->current_screen frame]; struct mp_rect screenrc = {0, 0, r.size.width, r.size.height}; struct vo_win_geometry geo; @@ -844,10 +852,8 @@ static int vo_cocoa_control_on_main_thread(struct vo *vo, int request, void *arg vo_cocoa_control_get_icc_profile(vo, arg); return VO_TRUE; case VOCTRL_GET_DISPLAY_FPS: - if (s->screen_fps > 0.0) { - *(double *)arg = s->screen_fps; - return VO_TRUE; - } + *(double *)arg = vo_cocoa_update_screen_fps(vo); + return VO_TRUE; break; case VOCTRL_GET_AMBIENT_LUX: if (s->light_sensor != IO_OBJECT_NULL) { @@ -965,7 +971,7 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) - (void)windowDidChangeScreen:(NSNotification *)notification { vo_cocoa_update_screen_info(self.vout); - vo_cocoa_update_screen_fps(self.vout); + vo_cocoa_update_displaylink(self.vout); } - (void)windowDidEnterFullScreen:(NSNotification *)notification -- cgit v1.2.3 From 6da224b1ddc6f28fe38900b6146f739d3acfb648 Mon Sep 17 00:00:00 2001 From: Akemi Date: Sat, 28 Jan 2017 16:29:22 +0100 Subject: cocoa: optimise screen event handling this optimises two things and fix a minor bug. 1. we always updated the display refresh rate on any mode change whether it was the current screen or not. now we only update the refresh rate when the mode changed happened on the current screen. 2. the windowDidChangeScreen event doesn't exclusively trigger on screen changes so we updated the display refresh rate in cases where it wasn't needed at all. since we manually keep track of the current screen, we can easily test if the screen really changed. 3. weirdly on initWithContentRect accessing the screen of the window always returned the main screen instead of the screen the window is created on. since we already use the window init method with the screen as argument, overwrite that method instead and use the screen argument. --- video/out/cocoa_common.m | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 5dda9c578c..6eb3dac6a9 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -433,8 +433,6 @@ static void vo_cocoa_update_displaylink(struct vo *vo) vo_cocoa_uninit_displaylink(s); vo_cocoa_init_displaylink(vo); - - flag_events(vo, VO_EVENT_WIN_STATE); } static double vo_cocoa_update_screen_fps(struct vo *vo) @@ -618,8 +616,16 @@ static void cocoa_screen_reconfiguration_observer( { if (flags & kCGDisplaySetModeFlag) { struct vo *vo = ctx; - MP_WARN(vo, "detected display mode change, updating screen info\n"); - vo_cocoa_update_displaylink(vo); + struct vo_cocoa_state *s = vo->cocoa; + + NSDictionary* sinfo = [s->current_screen deviceDescription]; + NSNumber* sid = [sinfo objectForKey:@"NSScreenNumber"]; + CGDirectDisplayID did = [sid longValue]; + + if (did == display) { + MP_VERBOSE(vo, "detected display mode change, updating screen refresh rate\n"); + flag_events(vo, VO_EVENT_WIN_STATE); + } } } @@ -972,6 +978,7 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) { vo_cocoa_update_screen_info(self.vout); vo_cocoa_update_displaylink(self.vout); + flag_events(self.vout, VO_EVENT_WIN_STATE); } - (void)windowDidEnterFullScreen:(NSNotification *)notification -- cgit v1.2.3 From d11c03faeec257e1f38886e3eb79a977d41127cb Mon Sep 17 00:00:00 2001 From: Akemi Date: Tue, 31 Jan 2017 16:45:15 +0100 Subject: cocoa: fix color profile retrieval when the color profile was changed it used the right NSScreen but with the old colorSpace. this was optimised out by a previous commit because of a wrong assumption. we need to update the screen so we can get the new colorSpace. this adds a bit of redundancy since on screen change it will update screen pointer twice. --- video/out/cocoa_common.m | 1 + 1 file changed, 1 insertion(+) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 6eb3dac6a9..0420b0dda2 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -1008,6 +1008,7 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) - (void)didChangeWindowedScreenProfile:(NSNotification *)notification { + vo_cocoa_update_screen_info(self.vout); flag_events(self.vout, VO_EVENT_ICC_PROFILE_CHANGED); } -- cgit v1.2.3