From e9cbda29e95c69a14cf2fd6f94bcc43a14fbbb3a Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sat, 22 Jun 2019 10:37:03 +0200 Subject: [PATCH] GWindow: Make destroy-on-close an optional behavior. Also add missing implementation of GWindow::is_visible(). --- LibGUI/GWindow.cpp | 5 +++-- LibGUI/GWindow.h | 4 ++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/LibGUI/GWindow.cpp b/LibGUI/GWindow.cpp index b404480f87..74e339ff5a 100644 --- a/LibGUI/GWindow.cpp +++ b/LibGUI/GWindow.cpp @@ -47,7 +47,8 @@ void GWindow::close() { if (should_exit_event_loop_on_close()) GEventLoop::current().quit(0); - delete_later(); + if (should_destroy_on_close()) + delete_later(); } void GWindow::move_to_front() @@ -421,7 +422,7 @@ void GWindow::collect_keyboard_activation_targets() bool GWindow::is_visible() const { - return false; + return m_window_id != 0; } void GWindow::update(const Rect& a_rect) diff --git a/LibGUI/GWindow.h b/LibGUI/GWindow.h index 48cee884a2..617d4125c0 100644 --- a/LibGUI/GWindow.h +++ b/LibGUI/GWindow.h @@ -53,6 +53,9 @@ public: Color background_color() const { return m_background_color; } void set_background_color(Color color) { m_background_color = color; } + bool should_destroy_on_close() { return m_destroy_on_close; } + void set_should_destroy_on_close(bool b) { m_destroy_on_close = b; } + int x() const { return rect().x(); } int y() const { return rect().y(); } int width() const { return rect().width(); } @@ -158,6 +161,7 @@ private: GWindowType m_window_type { GWindowType::Normal }; bool m_is_active { false }; bool m_should_exit_app_on_close { false }; + bool m_destroy_on_close { true }; bool m_has_alpha_channel { false }; bool m_double_buffering_enabled { true }; bool m_modal { false };