From 836893fed92c0bf0e893520caa1a38e00f6bab1b Mon Sep 17 00:00:00 2001 From: wm4 Date: Tue, 6 May 2014 22:00:17 +0200 Subject: cocoa: don't use VOCTRL_UPDATE_SCREENINFO --- video/out/cocoa_common.h | 4 +--- video/out/cocoa_common.m | 41 +++++++++++++++++++++++------------------ video/out/gl_cocoa.c | 2 +- 3 files changed, 25 insertions(+), 22 deletions(-) diff --git a/video/out/cocoa_common.h b/video/out/cocoa_common.h index 453e52c6c6..e0696eb24a 100644 --- a/video/out/cocoa_common.h +++ b/video/out/cocoa_common.h @@ -29,9 +29,7 @@ void *vo_cocoa_glgetaddr(const char *s); int vo_cocoa_init(struct vo *vo); void vo_cocoa_uninit(struct vo *vo); -int vo_cocoa_config_window(struct vo *vo, uint32_t d_width, - uint32_t d_height, uint32_t flags, - int gl3profile); +int vo_cocoa_config_window(struct vo *vo, uint32_t flags, int gl3profile); void vo_cocoa_set_current_context(struct vo *vo, bool current); void vo_cocoa_swap_buffers(struct vo *vo); diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 0e5d247256..6f375fa5dd 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -36,7 +36,7 @@ #include "options/options.h" #include "video/out/vo.h" -#include "video/out/aspect.h" +#include "win_state.h" #include "input/input.h" #include "talloc.h" @@ -233,17 +233,16 @@ static void vo_cocoa_update_screens_pointers(struct vo *vo) get_screen_handle(vo, opts->fsscreen_id, s->window, &s->fs_screen); } -static void vo_cocoa_update_screen_info(struct vo *vo) +static void vo_cocoa_update_screen_info(struct vo *vo, struct mp_rect *out_rc) { struct vo_cocoa_state *s = vo->cocoa; - struct mp_vo_opts *opts = vo->opts; vo_cocoa_update_screens_pointers(vo); - NSRect r = [s->current_screen frame]; - - opts->screenwidth = r.size.width; - opts->screenheight = r.size.height; + if (out_rc) { + NSRect r = [s->current_screen frame]; + *out_rc = (struct mp_rect){0, 0, r.size.width, r.size.height}; + } } static void resize_window(struct vo *vo) @@ -277,13 +276,13 @@ static void vo_cocoa_ontop(struct vo *vo) vo_set_level(vo, opts->ontop); } -static void create_window(struct vo *vo, uint32_t d_width, uint32_t d_height, - uint32_t flags) +static void create_window(struct vo *vo, struct mp_rect *win, int geo_flags) { struct vo_cocoa_state *s = vo->cocoa; struct mp_vo_opts *opts = vo->opts; - const NSRect contentRect = NSMakeRect(vo->dx, vo->dy, d_width, d_height); + const NSRect contentRect = + NSMakeRect(win->x0, win->y0, win->x1 - win->x0, win->y1 - win->y0); int window_mask = 0; if (opts->border) { @@ -430,8 +429,7 @@ static void cocoa_add_fs_screen_profile_observer(struct vo *vo) usingBlock:nblock]; } -int vo_cocoa_config_window(struct vo *vo, uint32_t width, uint32_t height, - uint32_t flags, int gl3profile) +int vo_cocoa_config_window(struct vo *vo, uint32_t flags, int gl3profile) { struct vo_cocoa_state *s = vo->cocoa; __block int ctxok = 0; @@ -439,6 +437,16 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t width, uint32_t height, dispatch_on_main_thread(vo, ^{ s->enable_resize_redraw = false; + struct mp_rect screenrc; + vo_cocoa_update_screen_info(vo, &screenrc); + + struct vo_win_geometry geo; + vo_calc_window_geometry(vo, &screenrc, &geo); + vo_apply_window_geometry(vo, &geo); + + uint32_t width = vo->dwidth; + uint32_t height = vo->dheight; + bool reset_size = s->old_dwidth != width || s->old_dheight != height; s->old_dwidth = width; s->old_dheight = height; @@ -462,7 +470,7 @@ int vo_cocoa_config_window(struct vo *vo, uint32_t width, uint32_t height, } if (!s->window) - create_window(vo, width, height, flags); + create_window(vo, &geo.win, geo.flags); } if (s->window) { @@ -548,7 +556,7 @@ static void vo_cocoa_fullscreen(struct vo *vo) struct vo_cocoa_state *s = vo->cocoa; struct mp_vo_opts *opts = vo->opts; - vo_cocoa_update_screen_info(vo); + vo_cocoa_update_screen_info(vo, NULL); if (opts->fs_missioncontrol) { [s->window setFullScreen:opts->fullscreen]; @@ -655,7 +663,7 @@ static void vo_cocoa_control_get_icc_profile_path(struct vo *vo, void *arg) struct vo_cocoa_state *s = vo->cocoa; char **p = arg; - vo_cocoa_update_screen_info(vo); + vo_cocoa_update_screen_info(vo, NULL); NSScreen *screen; char **path; @@ -685,9 +693,6 @@ int vo_cocoa_control(struct vo *vo, int *events, int request, void *arg) case VOCTRL_ONTOP: vo_cocoa_ontop(vo); return VO_TRUE; - case VOCTRL_UPDATE_SCREENINFO: - vo_cocoa_update_screen_info(vo); - return VO_TRUE; case VOCTRL_GET_WINDOW_SIZE: { int *s = arg; dispatch_on_main_thread(vo, ^{ diff --git a/video/out/gl_cocoa.c b/video/out/gl_cocoa.c index a6f4acb2f6..91d783df9e 100644 --- a/video/out/gl_cocoa.c +++ b/video/out/gl_cocoa.c @@ -32,7 +32,7 @@ static void gl_clear(void *ctx) static bool config_window_cocoa(struct MPGLContext *ctx, uint32_t d_width, uint32_t d_height, uint32_t flags) { - int rv = vo_cocoa_config_window(ctx->vo, d_width, d_height, flags, + int rv = vo_cocoa_config_window(ctx->vo, flags, ctx->requested_gl_version >= MPGL_VER(3, 0)); if (rv != 0) return false; -- cgit v1.2.3