1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 20:28:11 +00:00

WindowServer: Remove nudge_into_desktop() from Window

Positioning windows outside visible coordinates is valid if sometimes
curious behavior, but it shouldn't be considered misbehavior by default.
There are multiple ways to recover windows with obscured title bars,
and this function papers over actual resize bugs and is no longer
needed to normalize window size, so let's remove it for now.
This commit is contained in:
thankyouverycool 2022-08-17 19:43:52 -04:00 committed by Andreas Kling
parent b180132c87
commit a1dceb5b97
4 changed files with 0 additions and 55 deletions

View file

@ -190,52 +190,6 @@ bool Window::apply_minimum_size(Gfx::IntRect& rect)
return did_size_clamp;
}
void Window::nudge_into_desktop(Screen* target_screen, bool force_titlebar_visible)
{
if (!target_screen) {
// If no explicit target screen was supplied,
// guess based on the current frame rectangle
target_screen = &Screen::closest_to_rect(rect());
}
Gfx::IntRect arena = WindowManager::the().arena_rect_for_type(*target_screen, type());
auto min_visible = 1;
switch (type()) {
case WindowType::Normal:
min_visible = 30;
break;
case WindowType::Desktop:
set_rect(arena);
return;
default:
break;
}
// Push the frame around such that at least `min_visible` pixels of the *frame* are in the desktop rect.
auto old_frame_rect = frame().rect();
Gfx::IntRect new_frame_rect = {
clamp(old_frame_rect.x(), arena.left() + min_visible - width(), arena.right() - min_visible),
clamp(old_frame_rect.y(), arena.top() + min_visible - height(), arena.bottom() - min_visible),
old_frame_rect.width(),
old_frame_rect.height(),
};
// Make sure that at least half of the titlebar is visible.
auto min_frame_y = arena.top() - (y() - old_frame_rect.y()) / 2;
if (force_titlebar_visible && new_frame_rect.y() < min_frame_y) {
new_frame_rect.set_y(min_frame_y);
}
// Deduce new window rect:
Gfx::IntRect new_window_rect = {
x() + new_frame_rect.x() - old_frame_rect.x(),
y() + new_frame_rect.y() - old_frame_rect.y(),
width(),
height(),
};
set_rect(new_window_rect);
}
void Window::set_minimum_size(Gfx::IntSize const& size)
{
VERIFY(size.width() >= 0 && size.height() >= 0);