mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:15:10 +00:00
Add a simple close button ("X") to windows.
Clicking the button generates a WindowCloseRequest event which the client app then has to deal with. The default behavior for GWindow is to close() itself. I also added a flag, GWindow::should_exit_event_loop_on_close() which does what it sounds like it does. This patch exposed some bugs in GWindow and GWidget teardown.
This commit is contained in:
parent
d0078b6574
commit
11db8c1697
14 changed files with 103 additions and 1 deletions
|
@ -35,11 +35,17 @@ GWindow::GWindow(GObject* parent)
|
|||
|
||||
GWindow::~GWindow()
|
||||
{
|
||||
if (m_main_widget)
|
||||
delete m_main_widget;
|
||||
hide();
|
||||
}
|
||||
|
||||
void GWindow::close()
|
||||
{
|
||||
// FIXME: If we exit the event loop, we're never gonna deal with the delete_later request!
|
||||
// This will become relevant once we support nested event loops.
|
||||
if (should_exit_app_on_close())
|
||||
GEventLoop::main().exit(0);
|
||||
delete_later();
|
||||
}
|
||||
|
||||
|
@ -160,6 +166,11 @@ void GWindow::event(GEvent& event)
|
|||
return;
|
||||
}
|
||||
|
||||
if (event.type() == GEvent::WindowCloseRequest) {
|
||||
close();
|
||||
return;
|
||||
}
|
||||
|
||||
GObject::event(event);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue