diff options
author | Andreas Kling <awesomekling@gmail.com> | 2019-03-19 02:20:00 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2019-03-19 02:22:49 +0100 |
commit | f88e550998440fb2b4b130aade6c7efe2614ca13 (patch) | |
tree | e2312ce8d9da72e7d80fb20dabeee1dbf1c6cc0c /LibGUI/GDialog.cpp | |
parent | a6538feed1c3b26c75f9751522b703fd219ea860 (diff) | |
download | serenity-f88e550998440fb2b4b130aade6c7efe2614ca13.zip |
LibGUI: More work on GInputBox.
- If the GInputBox has a parent and the parent is a GWindow, center the
input box window within the parent window. This looks quite nice.
- Stop processing events in a nested event loop immediately after it's
been asked to quit.
- Fix GWidget::parent_widget() behavior for non-widget parents.
Diffstat (limited to 'LibGUI/GDialog.cpp')
-rw-r--r-- | LibGUI/GDialog.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/LibGUI/GDialog.cpp b/LibGUI/GDialog.cpp index 97f0c103c6..d6a925bfb2 100644 --- a/LibGUI/GDialog.cpp +++ b/LibGUI/GDialog.cpp @@ -14,13 +14,25 @@ GDialog::~GDialog() int GDialog::exec() { - GEventLoop loop; + ASSERT(!m_event_loop); + m_event_loop = make<GEventLoop>(); + if (parent() && parent()->is_window()) { + auto& parent_window = *static_cast<GWindow*>(parent()); + auto new_rect = rect(); + new_rect.center_within(parent_window.rect()); + set_rect(new_rect); + } show(); - return loop.exec(); + auto result = m_event_loop->exec(); + m_event_loop = nullptr; + dbgprintf("event loop returned with result %d\n", result); + return result; } void GDialog::done(int result) { + ASSERT(m_event_loop); m_result = result; - GEventLoop::current().quit(result); + dbgprintf("quit event loop with result %d\n", result); + m_event_loop->quit(result); } |