aboutsummaryrefslogtreecommitdiff
path: root/src/osx/gui/Window.mm
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-12-06 16:36:05 +0800
committercrupest <crupest@outlook.com>2021-12-06 16:36:05 +0800
commit6230b3e2873f2114eead9f3f21ff817cd83058d2 (patch)
tree1d9eb9c2dd75f2f982ec70ab83b2aba51253271b /src/osx/gui/Window.mm
parent6117141e1ff1e464854949c8a792961dbad8ea73 (diff)
downloadcru-6230b3e2873f2114eead9f3f21ff817cd83058d2.tar.gz
cru-6230b3e2873f2114eead9f3f21ff817cd83058d2.tar.bz2
cru-6230b3e2873f2114eead9f3f21ff817cd83058d2.zip
...
Diffstat (limited to 'src/osx/gui/Window.mm')
-rw-r--r--src/osx/gui/Window.mm21
1 files changed, 20 insertions, 1 deletions
diff --git a/src/osx/gui/Window.mm b/src/osx/gui/Window.mm
index 1a42f340..a0542147 100644
--- a/src/osx/gui/Window.mm
+++ b/src/osx/gui/Window.mm
@@ -53,9 +53,28 @@ OsxWindowPrivate::OsxWindowPrivate(OsxWindow* osx_window) : osx_window_(osx_wind
OsxWindowPrivate::~OsxWindowPrivate() {}
void OsxWindowPrivate::OnWindowWillClose() {
- destroy_event_.Raise(nullptr);
+ if (window_) destroy_event_.Raise(nullptr);
window_ = nil;
CGLayerRelease(draw_layer_);
+ draw_layer_ = nullptr;
+
+ if (osx_window_->GetUiApplication()->IsQuitOnAllWindowClosed()) {
+ const auto& all_window = osx_window_->GetUiApplication()->GetAllWindow();
+
+ bool quit = true;
+
+ for (auto window : all_window) {
+ auto w = CheckPlatform<OsxWindow>(window, osx_window_->GetPlatformId());
+ if (w->p_->window_) {
+ quit = false;
+ break;
+ }
+ }
+
+ if (quit) {
+ osx_window_->GetUiApplication()->RequestQuit(0);
+ }
+ }
}
void OsxWindowPrivate::OnWindowDidExpose() { osx_window_->RequestRepaint(); }