diff options
author | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-02-03 11:39:30 +0100 |
---|---|---|
committer | Stefano Pigozzi <stefano.pigozzi@gmail.com> | 2013-02-03 11:39:30 +0100 |
commit | 530036e5b34788d23dabadb8896f8e41e8f612d8 (patch) | |
tree | bab5d62b834c248c56770048ba2ff44b9fc1f801 /video | |
parent | ce29e58fe3bd82a53413f79aa59d6c8e0c4a89fd (diff) | |
download | mpv-530036e5b34788d23dabadb8896f8e41e8f612d8.tar.bz2 mpv-530036e5b34788d23dabadb8896f8e41e8f612d8.tar.xz |
cocoa_common: fix focus with --ontop and space switching
The main problem this commit addresses is when you switched spaced back and
forth with `--ontop` active the video window didn't recive focus again.
Turns out that setting a normal window level just before conceding focus to
other apps / spaces fixes the problem. I think Cocoa is misbehaving here, and
should probably file a radar.
I found 3 related improvements while fixing this:
* fullscreen_window_level is a dead body from an older implementation.
* Use NSScreenSaverWindowLevel for ontop. This should be a really high window
level. Definitely higher than NSNormalWindowLevel + 1.
* The window level was set correctly only when out of fullscreen.
Diffstat (limited to 'video')
-rw-r--r-- | video/out/cocoa_common.m | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m index 5822e75431..9ac1334c7f 100644 --- a/video/out/cocoa_common.m +++ b/video/out/cocoa_common.m @@ -107,7 +107,6 @@ struct vo_cocoa_state { NSString *window_title; NSInteger window_level; - NSInteger fullscreen_window_level; int display_cursor; int cursor_timer; @@ -302,13 +301,12 @@ static void vo_set_level(struct vo *vo, int ontop) { struct vo_cocoa_state *s = vo->cocoa; if (ontop) { - s->window_level = NSNormalWindowLevel + 1; + s->window_level = NSScreenSaverWindowLevel; } else { s->window_level = NSNormalWindowLevel; } - if (!vo_fs) - [s->window setLevel:s->window_level]; + [s->window setLevel:s->window_level]; } void vo_cocoa_ontop(struct vo *vo) @@ -826,6 +824,8 @@ void create_menu() - (void)applicationWillBecomeActive:(NSNotification *)aNotification { + struct vo_cocoa_state *s = _vo->cocoa; + [self setLevel:s->window_level]; if (vo_fs && current_screen_has_dock_or_menubar(_vo)) { [NSApp setPresentationOptions:NSApplicationPresentationHideDock| NSApplicationPresentationHideMenuBar]; @@ -834,6 +834,7 @@ void create_menu() - (void)applicationWillResignActive:(NSNotification *)aNotification { + [self setLevel:NSNormalWindowLevel]; if (vo_fs) { [NSApp setPresentationOptions:NSApplicationPresentationDefault]; } |