mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 00:25:12 +00:00
LibGUI+WindowServer: Provide default placement to windows
This prevents windows from being opened directly on top of eachother, and provides default behavior for when window position is not specified. The new behavior is as follows: - Windows that have been created without a set position are assigned one by WindowServer. - The assigned position is either offset from the last window that is still in an assigned position, or a default position if no such window is available.
This commit is contained in:
committed by
Andreas Kling
parent
586ada7a14
commit
5ae9eee4a3
@@ -407,6 +407,10 @@ OwnPtr<Messages::WindowServer::SetWindowRectResponse> ClientConnection::handle(c
|
||||
dbg() << "ClientConnection: Ignoring SetWindowRect request for fullscreen window";
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
if (message.rect().location() != window.rect().location()) {
|
||||
window.set_default_positioned(false);
|
||||
}
|
||||
auto normalized_rect = normalize_window_rect(message.rect(), window.type());
|
||||
window.set_rect(normalized_rect);
|
||||
window.request_update(normalized_rect);
|
||||
@@ -460,7 +464,12 @@ OwnPtr<Messages::WindowServer::CreateWindowResponse> ClientConnection::handle(co
|
||||
window->set_has_alpha_channel(message.has_alpha_channel());
|
||||
window->set_title(message.title());
|
||||
if (!message.fullscreen()) {
|
||||
auto normalized_rect = normalize_window_rect(message.rect(), window->type());
|
||||
auto rect = message.rect();
|
||||
if (message.auto_position() && window->type() == WindowType::Normal) {
|
||||
rect = { WindowManager::the().get_recommended_window_position({ 100, 100 }), message.rect().size() };
|
||||
window->set_default_positioned(true);
|
||||
}
|
||||
auto normalized_rect = normalize_window_rect(rect, window->type());
|
||||
window->set_rect(normalized_rect);
|
||||
}
|
||||
if (window->type() == WindowType::Desktop) {
|
||||
|
||||
Reference in New Issue
Block a user