mirror of
https://github.com/opencv/opencv.git
synced 2025-06-10 11:03:03 +08:00
Merge pull request #24098 from 0xMihir:4.x
Fix fullscreen behavior for macOS
This commit is contained in:
commit
e274e72869
@ -195,6 +195,9 @@ CV_IMPL void cvDestroyWindow( const char* name)
|
||||
//cout << "cvDestroyWindow" << endl;
|
||||
CVWindow *window = cvGetWindow(name);
|
||||
if(window) {
|
||||
if ([window styleMask] & NSFullScreenWindowMask) {
|
||||
[window toggleFullScreen:nil];
|
||||
}
|
||||
[window close];
|
||||
[windows removeObjectForKey:[NSString stringWithFormat:@"%s", name]];
|
||||
}
|
||||
@ -701,7 +704,11 @@ double cvGetModeWindow_COCOA( const char* name )
|
||||
void cvSetModeWindow_COCOA( const char* name, double prop_value )
|
||||
{
|
||||
CVWindow *window = nil;
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
|
||||
NSDictionary *fullscreenOptions = nil;
|
||||
#endif
|
||||
|
||||
NSAutoreleasePool* localpool = nil;
|
||||
|
||||
CV_FUNCNAME( "cvSetModeWindow_COCOA" );
|
||||
@ -725,6 +732,31 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value )
|
||||
|
||||
localpool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_6
|
||||
if ( ([window styleMask] & NSFullScreenWindowMask) && prop_value==CV_WINDOW_NORMAL )
|
||||
{
|
||||
[window toggleFullScreen:nil];
|
||||
|
||||
window.status=CV_WINDOW_NORMAL;
|
||||
}
|
||||
else if( !([window styleMask] & NSFullScreenWindowMask) && prop_value==CV_WINDOW_FULLSCREEN )
|
||||
{
|
||||
[window setCollectionBehavior:NSWindowCollectionBehaviorFullScreenPrimary];
|
||||
|
||||
NSScreen* screen = [window screen];
|
||||
|
||||
NSRect frame = [screen frame];
|
||||
[window setFrame:frame display:YES];
|
||||
|
||||
[window setContentSize:frame.size];
|
||||
|
||||
[window toggleFullScreen:nil];
|
||||
|
||||
[window setFrameTopLeftPoint: frame.origin];
|
||||
|
||||
window.status=CV_WINDOW_FULLSCREEN;
|
||||
}
|
||||
#else
|
||||
fullscreenOptions = [NSDictionary dictionaryWithObject:[NSNumber numberWithBool:YES] forKey:NSFullScreenModeSetting];
|
||||
if ( [[window contentView] isInFullScreenMode] && prop_value==CV_WINDOW_NORMAL )
|
||||
{
|
||||
@ -736,7 +768,7 @@ void cvSetModeWindow_COCOA( const char* name, double prop_value )
|
||||
[[window contentView] enterFullScreenMode:[NSScreen mainScreen] withOptions:fullscreenOptions];
|
||||
window.status=CV_WINDOW_FULLSCREEN;
|
||||
}
|
||||
|
||||
#endif
|
||||
[localpool drain];
|
||||
|
||||
__END__;
|
||||
@ -810,7 +842,7 @@ void cvSetPropTopmost_COCOA( const char* name, const bool topmost )
|
||||
CV_ERROR( CV_StsNullPtr, "NULL window" );
|
||||
}
|
||||
|
||||
if ([[window contentView] isInFullScreenMode])
|
||||
if (([window styleMask] & NSFullScreenWindowMask))
|
||||
{
|
||||
EXIT;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user