GWindow: Allow clients to prevent close requests from closing

This is done by hooking the new on_close_request callback and returning
GWindow::CloseRequestDecision::StayOpen (instead of ...::Close.)
This commit is contained in:
Andreas Kling 2019-08-27 20:35:37 +02:00
commit c4b1456c88
Notes: sideshowbarker 2024-07-19 12:29:11 +09:00
2 changed files with 12 additions and 1 deletions

View file

@ -322,6 +322,10 @@ void GWindow::event(CEvent& event)
}
if (event.type() == GEvent::WindowCloseRequest) {
if (on_close_request) {
if (on_close_request() == GWindow::CloseRequestDecision::StayOpen)
return;
}
close();
return;
}