mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-22 23:50:19 +00:00
LibGUI: Calculate Window min_size on show
This commit is contained in:
parent
53215be7ae
commit
80ea141ffe
Notes:
sideshowbarker
2024-07-17 10:54:57 +09:00
Author: https://github.com/frhun Commit: https://github.com/SerenityOS/serenity/commit/80ea141ffe Pull-request: https://github.com/SerenityOS/serenity/pull/14478 Issue: https://github.com/SerenityOS/serenity/issues/14420
2 changed files with 17 additions and 10 deletions
|
@ -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;
|
||||
});
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in a new issue