From c083a7f53e21ee1d7c1260401de92b30f674e79b Mon Sep 17 00:00:00 2001 From: Akemi Date: Tue, 14 Mar 2017 02:38:54 +0100 Subject: cocoa: fix retrieval of unfs window size there are two minor bugs. mpv could try to retrieve the size when in fullscreen and would get the fullscreen size. to fix that we keep track of the window size before going into fullscreen. the second small bug is when using HiDPI resolution and the --hidpi-window-scale option. we actually want the OSD to show the proper window scale depending on the hidpi settings. before when resizing the window to double the size it could show "window-scale: 1.0" or "window-scale: 0.5" when resizing to normal size. now it considers the backing scale factor and the hidpi option to return a logical correct window size. --- video/out/cocoa_common.m | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'video/out/cocoa_common.m') diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 5e295ec8ef..4db1ac2371 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -73,6 +73,7 @@ struct vo_cocoa_state { NSInteger window_level; int fullscreen; + NSRect unfs_window; bool cursor_visibility; bool cursor_visibility_wanted; @@ -694,6 +695,8 @@ int vo_cocoa_config_window(struct vo *vo) create_ui(vo, &geo.win, geo.flags); } + s->unfs_window = NSMakeRect(0, 0, width, height); + if (!s->embedded && s->window) { if (reset_size) queue_new_video_size(vo, width, height); @@ -809,6 +812,9 @@ static int vo_cocoa_fullscreen(struct vo *vo) if (s->embedded) return VO_NOTIMPL; + if (!s->fullscreen) + s->unfs_window = [s->view frame]; + [s->window toggleFullScreen:nil]; return VO_TRUE; @@ -841,9 +847,11 @@ static int vo_cocoa_control_on_main_thread(struct vo *vo, int request, void *arg return vo_cocoa_window_border(vo); case VOCTRL_GET_UNFS_WINDOW_SIZE: { int *sz = arg; - NSSize size = [s->view frame].size; - sz[0] = size.width; - sz[1] = size.height; + NSRect rect = s->fullscreen ? s->unfs_window : [s->view frame]; + if(!vo->opts->hidpi_window_scale) + rect = [s->current_screen convertRectToBacking:rect]; + sz[0] = rect.size.width; + sz[1] = rect.size.height; return VO_TRUE; } case VOCTRL_SET_UNFS_WINDOW_SIZE: { -- cgit v1.2.3