mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-01 16:58:52 +00:00
LibGUI: Get rid of GWindow's destroy-on-close mechanism
Since we're moving to a world of ref-counting, we can't have weird behaviors like "windows delete themselves when you close them." The "close app when there are no more windows" mechanism is moved to GWindow::hide(). Now, we close the app when it has no more windows on screen.
This commit is contained in:
parent
7584480f62
commit
870bc2a4d1
Notes:
sideshowbarker
2024-07-19 12:01:21 +09:00
Author: https://github.com/awesomekling
Commit: 870bc2a4d1
3 changed files with 11 additions and 10 deletions
|
@ -38,15 +38,11 @@ GWindow::~GWindow()
|
|||
{
|
||||
all_windows.remove(this);
|
||||
hide();
|
||||
if (all_windows.is_empty()) {
|
||||
GApplication::the().did_delete_last_window({});
|
||||
}
|
||||
}
|
||||
|
||||
void GWindow::close()
|
||||
{
|
||||
if (should_destroy_on_close())
|
||||
delete_later();
|
||||
hide();
|
||||
}
|
||||
|
||||
void GWindow::move_to_front()
|
||||
|
@ -104,6 +100,16 @@ void GWindow::hide()
|
|||
m_pending_paint_event_rects.clear();
|
||||
m_back_bitmap = nullptr;
|
||||
m_front_bitmap = nullptr;
|
||||
|
||||
bool app_has_visible_windows = false;
|
||||
for (auto& window : all_windows) {
|
||||
if (window->is_visible()) {
|
||||
app_has_visible_windows = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!app_has_visible_windows)
|
||||
GApplication::the().did_delete_last_window({});
|
||||
}
|
||||
|
||||
void GWindow::set_title(const StringView& title)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue