LibGUI: Calculate Window min_size on show

This commit is contained in:
FrHun 2022-07-04 05:34:09 +02:00 committed by Andreas Kling
parent 53215be7ae
commit 80ea141ffe
Notes: sideshowbarker 2024-07-17 10:54:57 +09:00
2 changed files with 17 additions and 10 deletions

View File

@ -137,6 +137,8 @@ void Window::show()
unsetenv("__libgui_launch_origin_rect");
}
update_min_size();
ConnectionToWindowServer::the().async_create_window(
m_window_id,
m_rect_when_windowless,
@ -1036,21 +1038,24 @@ void Window::set_maximized(bool maximized)
ConnectionToWindowServer::the().async_set_maximized(m_window_id, maximized);
}
void Window::update_min_size()
{
if (main_widget()) {
main_widget()->do_layout();
if (m_obey_widget_min_size) {
auto min_size = main_widget()->effective_min_size();
set_minimum_size(MUST(min_size.width().shrink_value()), MUST(min_size.height().shrink_value()));
}
}
}
void Window::schedule_relayout()
{
if (m_layout_pending)
if (m_layout_pending || !is_visible())
return;
m_layout_pending = true;
deferred_invoke([this] {
if (main_widget()) {
main_widget()->do_layout();
if (m_obey_widget_min_size) {
auto min_size = main_widget()->effective_min_size();
set_minimum_size(
(min_size.width() == GUI::SpecialDimension::Shrink ? 0 : min_size.width().as_int()),
(min_size.height() == GUI::SpecialDimension::Shrink ? 0 : min_size.height().as_int()));
}
}
update_min_size();
update();
m_layout_pending = false;
});

View File

@ -231,6 +231,8 @@ protected:
virtual void leave_event(Core::Event&);
private:
void update_min_size();
void update_cursor();
void focus_a_widget_if_possible(FocusSource);