From 72376e95f1aad50009d0bff2c6e3a7e8a09cdf4f Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 18:34:36 +0100 Subject: [PATCH 1/4] cocoadisplay: Even better applicationShouldTerminate handling It seems that performClose doesn't actually work properly for fullscreen windows --- .../src/cocoadisplay/cocoaPandaAppDelegate.mm | 20 ++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm index 5855c3025b..878d5d9267 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm @@ -33,12 +33,26 @@ - (BOOL)applicationShouldTerminate:(NSApplication *)app { if (cocoadisplay_cat.is_debug()) { cocoadisplay_cat.debug() - << "Received applicationShouldTerminate, closing all Cocoa windows\n"; + << "Received applicationShouldTerminate, requesting to close all Cocoa windows\n"; } - // Call performClose on all the windows. This should make ShowBase shut down. + // Ask all the windows whether they are OK to be closed. + bool should_close = true; for (NSWindow *window in [app windows]) { - [window performClose:nil]; + if (![[window delegate] windowShouldClose:window]) { + should_close = false; + } } + if (should_close) { + if (cocoadisplay_cat.is_debug()) { + cocoadisplay_cat.debug() + << "No window objected to close request, closing all windows\n"; + } + // If so (none of them fired a close request event), close them now. + for (NSWindow *window in [app windows]) { + [window close]; + } + } + // Give the application a chance to run its own cleanup functions. return FALSE; } From 5751fc647861ec413439fa9ef95a4ec30ddfb5cc Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 18:58:38 +0100 Subject: [PATCH 2/4] cocoadisplay: Fix a whitespace error --- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 40d6a6ea5f..1b564c0eb1 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -799,7 +799,7 @@ close_window() { if (_window != nil) { [_window close]; - + // Process events once more so any pending NSEvents are cleared. Not doing // this causes the window to stick around after calling [_window close]. process_events(); From bdb55c480b00c6d15cf9e59e3701fe2d74be7296 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 18:58:54 +0100 Subject: [PATCH 3/4] cocoadisplay: Fix missing includes --- panda/src/cocoadisplay/cocoaPandaAppDelegate.mm | 1 + panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm | 1 + 2 files changed, 2 insertions(+) diff --git a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm index 878d5d9267..cbb84bc205 100644 --- a/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaAppDelegate.mm @@ -13,6 +13,7 @@ #import "cocoaPandaAppDelegate.h" #include "graphicsEngine.h" +#include "config_cocoadisplay.h" @implementation CocoaPandaAppDelegate diff --git a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm index dbbbe8e5b2..fe67c50c13 100644 --- a/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm +++ b/panda/src/cocoadisplay/cocoaPandaWindowDelegate.mm @@ -12,6 +12,7 @@ */ #import "cocoaPandaWindowDelegate.h" +#include "config_cocoadisplay.h" @implementation CocoaPandaWindowDelegate - (id) initWithGraphicsWindow:(CocoaGraphicsWindow*)window { From 602bd3e02362d6e11be1247ff30239372c87bac2 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 7 Dec 2022 19:02:30 +0100 Subject: [PATCH 4/4] gobj: Fix Texture render_to_texture flag garbage after CData copy --- panda/src/gobj/texture.I | 1 + panda/src/gobj/texture.cxx | 1 + 2 files changed, 2 insertions(+) diff --git a/panda/src/gobj/texture.I b/panda/src/gobj/texture.I index ce3aa6cffe..5ba9aa0f95 100644 --- a/panda/src/gobj/texture.I +++ b/panda/src/gobj/texture.I @@ -26,6 +26,7 @@ INLINE PT(Texture) Texture:: make_copy() const { PT(Texture) tex = make_copy_impl(); CDWriter cdata_tex(tex->_cycler, true); + cdata_tex->_render_to_texture = false; cdata_tex->inc_properties_modified(); cdata_tex->inc_image_modified(); cdata_tex->inc_simple_image_modified(); diff --git a/panda/src/gobj/texture.cxx b/panda/src/gobj/texture.cxx index 703b70c4ae..7edced0507 100644 --- a/panda/src/gobj/texture.cxx +++ b/panda/src/gobj/texture.cxx @@ -10710,6 +10710,7 @@ CData() { Texture::CData:: CData(const Texture::CData ©) { _num_mipmap_levels_read = 0; + _render_to_texture = copy._render_to_texture; do_assign(©);