1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 06:58:11 +00:00

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
parent ecbedda34c
commit c4b1456c88
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;
}