1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 16:07:47 +00:00

WindowServer: Ignore window base size in aspect ratio enforcement

This makes windows with an aspect ratio behave more naturally if they
also have a base size (e.g from the main widget being a GUI::Frame.)
This commit is contained in:
Andreas Kling 2021-05-17 12:01:17 +02:00
parent f0375e3efe
commit 2083d1a3d6

View file

@ -709,10 +709,11 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
if (m_resize_window->resize_aspect_ratio().has_value()) {
auto& ratio = m_resize_window->resize_aspect_ratio().value();
auto base_size = m_resize_window->base_size();
if (abs(change_w) > abs(change_h)) {
new_rect.set_height(new_rect.width() * ratio.height() / ratio.width());
new_rect.set_height(base_size.height() + (new_rect.width() - base_size.width()) * ratio.height() / ratio.width());
} else {
new_rect.set_width(new_rect.height() * ratio.width() / ratio.height());
new_rect.set_width(base_size.width() + (new_rect.height() - base_size.height()) * ratio.width() / ratio.height());
}
}