mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 22:17:45 +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:
parent
79f534ef12
commit
cf586311a6
4 changed files with 30 additions and 24 deletions
|
@ -557,7 +557,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
|
|||
// "Bounce back" the window if it would end up too far outside the screen.
|
||||
// If the user has let go of Mod_Logo, maybe they didn't intentionally press it to begin with. Therefore, refuse to go into a state where knowledge about super-drags is necessary.
|
||||
bool force_titlebar_visible = !(m_keyboard_modifiers & Mod_Logo);
|
||||
m_move_window->normalize_rect(force_titlebar_visible);
|
||||
m_move_window->nudge_into_desktop(force_titlebar_visible);
|
||||
} else if (pixels_moved_from_start > 5) {
|
||||
m_move_window->set_untiled(event.position());
|
||||
m_move_origin = event.position();
|
||||
|
@ -633,10 +633,9 @@ bool WindowManager::process_ongoing_window_resize(const MouseEvent& event, Windo
|
|||
auto new_rect = m_resize_window_original_rect;
|
||||
|
||||
// First, size the new rect.
|
||||
Gfx::IntSize minimum_size { 50, 50 };
|
||||
|
||||
new_rect.set_width(max(minimum_size.width(), new_rect.width() + change_w));
|
||||
new_rect.set_height(max(minimum_size.height(), new_rect.height() + change_h));
|
||||
new_rect.set_width(new_rect.width() + change_w);
|
||||
new_rect.set_height(new_rect.height() + change_h);
|
||||
m_resize_window->apply_minimum_size(new_rect);
|
||||
|
||||
if (!m_resize_window->size_increment().is_null()) {
|
||||
int horizontal_incs = (new_rect.width() - m_resize_window->base_size().width()) / m_resize_window->size_increment().width();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue