1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 16:18:12 +00:00

WindowServer: Split double-duty Window::normalize_rect()

This commit:
- merges the two(!) places that defined independently the minimum size of a window.
- splits Window::normalize_rect(), which was originally just a function to apply
  the minimum size requirement, and has taken on the additional job of nudging
  windows back onto the desktop.

This inadvertantly fixes a crash that happens when a malicious program creates a
window of size (0, 0). Now, a window at [0,0 50x50] is created instead.
This commit is contained in:
Ben Wiederhake 2021-01-28 22:47:32 +01:00 committed by Andreas Kling
parent 79f534ef12
commit cf586311a6
4 changed files with 30 additions and 24 deletions

View file

@ -394,8 +394,10 @@ OwnPtr<Messages::WindowServer::SetWindowRectResponse> ClientConnection::handle(c
if (message.rect().location() != window.rect().location()) {
window.set_default_positioned(false);
}
window.set_rect(message.rect());
window.normalize_rect();
auto rect = message.rect();
window.apply_minimum_size(rect);
window.set_rect(rect);
window.nudge_into_desktop();
window.request_update(window.rect());
return make<Messages::WindowServer::SetWindowRectResponse>(window.rect());
}
@ -452,8 +454,9 @@ OwnPtr<Messages::WindowServer::CreateWindowResponse> ClientConnection::handle(co
rect = { WindowManager::the().get_recommended_window_position({ 100, 100 }), message.rect().size() };
window->set_default_positioned(true);
}
window->apply_minimum_size(rect);
window->set_rect(rect);
window->normalize_rect();
window->nudge_into_desktop();
}
if (window->type() == WindowType::Desktop) {
window->set_rect(WindowManager::the().desktop_rect());