osx: Move the detached video dialog to the normal window level when it goes fullscreen as it's hilariously broken otherwise

Originally committed to SVN as r6890.
This commit is contained in:
Thomas Goyne 2012-06-07 21:03:08 +00:00
parent f0f7ad2858
commit 8c17d45e8c
2 changed files with 30 additions and 7 deletions

View file

@ -20,6 +20,7 @@ LDFLAGS += $(LDFLAGS_CCMALLOC)
ifeq (yes, $(BUILD_DARWIN)) ifeq (yes, $(BUILD_DARWIN))
SRC += osx_utils.mm SRC += osx_utils.mm
osx_utils.o: OBJCXXFLAGS += -fobjc-arc
endif endif
############### ###############

View file

@ -23,20 +23,42 @@
#include "config.h" #include "config.h"
// This bit of awfulness is to disable some ARC-incompatible stuff in window.h
// that we don't need
#include <wx/brush.h>
#undef wxOSX_USE_COCOA_OR_IPHONE
#define wxOSX_USE_COCOA_OR_IPHONE 0
class WXDLLIMPEXP_FWD_CORE wxWidgetImpl;
typedef wxWidgetImpl wxOSXWidgetImpl;
#include <wx/window.h> #include <wx/window.h>
#import <AppKit/AppKit.h> #import <AppKit/AppKit.h>
void AddFullScreenButton(wxWindow *window) { void AddFullScreenButton(wxWindow *window) {
NSWindow *nsWindow = [window->GetHandle() window]; NSWindow *nsWindow = [window->GetHandle() window];
if (![nsWindow respondsToSelector:@selector(toggleFullScreen:)]) if (![nsWindow respondsToSelector:@selector(toggleFullScreen:)])
return; return;
NSWindowCollectionBehavior collectionBehavior = [nsWindow collectionBehavior]; NSWindowCollectionBehavior collectionBehavior = [nsWindow collectionBehavior];
collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary; collectionBehavior |= NSWindowCollectionBehaviorFullScreenPrimary;
[nsWindow setCollectionBehavior:collectionBehavior]; [nsWindow setCollectionBehavior:collectionBehavior];
} }
void SetFloatOnParent(wxWindow *window) { void SetFloatOnParent(wxWindow *window) {
[[window->GetHandle() window] setLevel:NSFloatingWindowLevel]; __unsafe_unretained NSWindow *nsWindow = [window->GetHandle() window];
[nsWindow setLevel:NSFloatingWindowLevel];
if (!([nsWindow collectionBehavior] & NSWindowCollectionBehaviorFullScreenPrimary))
return;
NSNotificationCenter *nc = [NSNotificationCenter defaultCenter];
[nc addObserverForName:@"NSWindowWillEnterFullScreenNotification"
object:nsWindow
queue:nil
usingBlock:^(NSNotification *) { [nsWindow setLevel:NSNormalWindowLevel]; }];
[nc addObserverForName:@"NSWindowWillExitFullScreenNotification"
object:nsWindow
queue:nil
usingBlock:^(NSNotification *) { [nsWindow setLevel:NSFloatingWindowLevel]; }];
} }