diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-09-30 00:32:53 +0200 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2012-10-16 07:19:33 +0200 |
commit | e3fe5b873533b786f05beee4a9df7bcf59aee9b9 (patch) | |
tree | a0f5ccec749287fbd9045fd787757e8b07ee30f4 /libvo/cocoa_common.m | |
parent | dd7607756d735453a0d500666220a27edcd978e9 (diff) | |
download | mpv-e3fe5b873533b786f05beee4a9df7bcf59aee9b9.tar.bz2 mpv-e3fe5b873533b786f05beee4a9df7bcf59aee9b9.tar.xz |
cocoa_common: use the same window level when windowed and fullscreen
This greatly simplifies the code and makes alt tab behave like it is supposed
to: it doesn't put the mplayer window behind the other ones when losing focus.
If you have other programs that are displaying themselves above the normal
window level, avoid them or use --ontop.
Diffstat (limited to 'libvo/cocoa_common.m')
-rw-r--r-- | libvo/cocoa_common.m | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/libvo/cocoa_common.m b/libvo/cocoa_common.m index 736aeab639..ef7baf6f89 100644 --- a/libvo/cocoa_common.m +++ b/libvo/cocoa_common.m @@ -102,7 +102,7 @@ struct vo_cocoa_state { NSString *window_title; - NSInteger windowed_window_level; + NSInteger window_level; NSInteger fullscreen_window_level; int display_cursor; @@ -130,7 +130,6 @@ static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo) .windowed_mask = NSTitledWindowMask|NSClosableWindowMask| NSMiniaturizableWindowMask|NSResizableWindowMask, .fullscreen_mask = NSBorderlessWindowMask, - .fullscreen_window_level = NSNormalWindowLevel + 1, .windowed_frame = {{0,0},{0,0}}, .out_fs_resize = NO, .display_cursor = 1, @@ -288,13 +287,13 @@ static void vo_set_level(struct vo *vo, int ontop) { struct vo_cocoa_state *s = vo->cocoa; if (ontop) { - s->windowed_window_level = NSNormalWindowLevel + 1; + s->window_level = NSNormalWindowLevel + 1; } else { - s->windowed_window_level = NSNormalWindowLevel; + s->window_level = NSNormalWindowLevel; } if (!vo_fs) - [s->window setLevel:s->windowed_window_level]; + [s->window setLevel:s->window_level]; } void vo_cocoa_ontop(struct vo *vo) @@ -610,7 +609,6 @@ void create_menu() [self setHasShadow:NO]; [self setStyleMask:s->fullscreen_mask]; [self setFrame:s->screen_frame display:YES animate:NO]; - [self setLevel:s->fullscreen_window_level]; vo_fs = VO_TRUE; vo_cocoa_display_cursor(_vo, 0); [self setMovableByWindowBackground: NO]; @@ -625,7 +623,6 @@ void create_menu() s->out_fs_resize = NO; } [self setContentAspectRatio:s->current_video_size]; - [self setLevel:s->windowed_window_level]; vo_fs = VO_FALSE; vo_cocoa_display_cursor(_vo, 1); [self setMovableByWindowBackground: YES]; @@ -763,23 +760,16 @@ void create_menu() - (void)applicationWillBecomeActive:(NSNotification *)aNotification { - if (vo_fs) { - struct vo_cocoa_state *s = _vo->cocoa; - [s->window makeKeyAndOrderFront:s->window]; - [s->window setLevel:s->fullscreen_window_level]; - if (current_screen_has_dock_or_menubar(_vo)) - [NSApp setPresentationOptions:NSApplicationPresentationHideDock| - NSApplicationPresentationHideMenuBar]; + if (vo_fs && current_screen_has_dock_or_menubar(_vo)) { + [NSApp setPresentationOptions:NSApplicationPresentationHideDock| + NSApplicationPresentationHideMenuBar]; } } - (void)applicationWillResignActive:(NSNotification *)aNotification { if (vo_fs) { - struct vo_cocoa_state *s = _vo->cocoa; [NSApp setPresentationOptions:NSApplicationPresentationDefault]; - [s->window setLevel:s->windowed_window_level]; - [s->window orderBack:s->window]; } } |