From 530036e5b34788d23dabadb8896f8e41e8f612d8 Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Sun, 3 Feb 2013 11:39:30 +0100 Subject: 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. --- video/out/cocoa_common.m | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'video') 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]; } -- cgit v1.2.3