Skip to content

Commit e9cbda2

Browse files
committed
GWindow: Make destroy-on-close an optional behavior.
Also add missing implementation of GWindow::is_visible().
1 parent ae8eff5 commit e9cbda2

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

LibGUI/GWindow.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ void GWindow::close()
4747
{
4848
if (should_exit_event_loop_on_close())
4949
GEventLoop::current().quit(0);
50-
delete_later();
50+
if (should_destroy_on_close())
51+
delete_later();
5152
}
5253

5354
void GWindow::move_to_front()
@@ -421,7 +422,7 @@ void GWindow::collect_keyboard_activation_targets()
421422

422423
bool GWindow::is_visible() const
423424
{
424-
return false;
425+
return m_window_id != 0;
425426
}
426427

427428
void GWindow::update(const Rect& a_rect)

LibGUI/GWindow.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ class GWindow : public CObject {
5353
Color background_color() const { return m_background_color; }
5454
void set_background_color(Color color) { m_background_color = color; }
5555

56+
bool should_destroy_on_close() { return m_destroy_on_close; }
57+
void set_should_destroy_on_close(bool b) { m_destroy_on_close = b; }
58+
5659
int x() const { return rect().x(); }
5760
int y() const { return rect().y(); }
5861
int width() const { return rect().width(); }
@@ -158,6 +161,7 @@ class GWindow : public CObject {
158161
GWindowType m_window_type { GWindowType::Normal };
159162
bool m_is_active { false };
160163
bool m_should_exit_app_on_close { false };
164+
bool m_destroy_on_close { true };
161165
bool m_has_alpha_channel { false };
162166
bool m_double_buffering_enabled { true };
163167
bool m_modal { false };

0 commit comments

Comments
 (0)