diff --git a/Libraries/LibGUI/Dialog.cpp b/Libraries/LibGUI/Dialog.cpp index 6e5e4701ae..47d3810ae2 100644 --- a/Libraries/LibGUI/Dialog.cpp +++ b/Libraries/LibGUI/Dialog.cpp @@ -25,7 +25,6 @@ */ #include -#include #include #include @@ -45,14 +44,18 @@ int Dialog::exec() { ASSERT(!m_event_loop); m_event_loop = make(); - auto new_rect = rect(); if (parent() && parent()->is_window()) { auto& parent_window = *static_cast(parent()); - new_rect.center_within(parent_window.rect()); + if (parent_window.is_visible()) { + auto new_rect = rect(); + new_rect.center_within(parent_window.rect()); + set_rect(new_rect); + } else { + center_on_screen(); + } } else { - new_rect.center_within(Desktop::the().rect()); + center_on_screen(); } - set_rect(new_rect); show(); auto result = m_event_loop->exec(); m_event_loop = nullptr;