mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -04:00
cocoadisplay: Capture display before switching to fullscreen mode
This commit is contained in:
parent
4b992105e1
commit
518ee0fb8e
@ -1417,7 +1417,11 @@ do_switch_fullscreen(CFDictionaryRef mode) {
|
|||||||
#else
|
#else
|
||||||
CGDisplaySwitchToMode(_display, _windowed_mode);
|
CGDisplaySwitchToMode(_display, _windowed_mode);
|
||||||
#endif
|
#endif
|
||||||
CGDisplayRelease(_display);
|
if (CGDisplayIsMain(_display)) {
|
||||||
|
CGReleaseAllDisplays();
|
||||||
|
} else {
|
||||||
|
CGDisplayRelease(_display);
|
||||||
|
}
|
||||||
_windowed_mode = NULL;
|
_windowed_mode = NULL;
|
||||||
_context_needs_update = true;
|
_context_needs_update = true;
|
||||||
|
|
||||||
@ -1436,7 +1440,21 @@ do_switch_fullscreen(CFDictionaryRef mode) {
|
|||||||
_fullscreen_mode = mode;
|
_fullscreen_mode = mode;
|
||||||
_context_needs_update = true;
|
_context_needs_update = true;
|
||||||
|
|
||||||
|
// Display must be captured by the application before switching mode.
|
||||||
|
// If not, the change of mode and resolution will be applied on all the other applications,
|
||||||
|
// although they are no longer visible.
|
||||||
|
// This also leads to weird bugs when switching back to the desktop mode.
|
||||||
CGError err;
|
CGError err;
|
||||||
|
if (CGDisplayIsMain(_display)) {
|
||||||
|
// In multidisplay setup, all the displays must be captured or the switch will be notified anyway.
|
||||||
|
err = CGCaptureAllDisplays();
|
||||||
|
} else {
|
||||||
|
err = CGDisplayCapture(_display);
|
||||||
|
}
|
||||||
|
if (err != kCGErrorSuccess) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
#if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060
|
||||||
err = CGDisplaySetDisplayMode(_display, _fullscreen_mode, NULL);
|
err = CGDisplaySetDisplayMode(_display, _fullscreen_mode, NULL);
|
||||||
#else
|
#else
|
||||||
@ -1444,11 +1462,14 @@ do_switch_fullscreen(CFDictionaryRef mode) {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (err != kCGErrorSuccess) {
|
if (err != kCGErrorSuccess) {
|
||||||
|
if (CGDisplayIsMain(_display)) {
|
||||||
|
CGReleaseAllDisplays();
|
||||||
|
} else {
|
||||||
|
CGDisplayRelease(_display);
|
||||||
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
CGDisplayCapture(_display);
|
|
||||||
|
|
||||||
NSRect frame = [[[_view window] screen] frame];
|
NSRect frame = [[[_view window] screen] frame];
|
||||||
if (cocoadisplay_cat.is_debug()) {
|
if (cocoadisplay_cat.is_debug()) {
|
||||||
NSString *str = NSStringFromRect(frame);
|
NSString *str = NSStringFromRect(frame);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user