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

WindowServer: Fix many subtle bugs in tiling/maximizing

- Unmaximization/untiling had nearly but not quite code duplication;
  this patch replaces the actual "regrabbing" logic with Rect::set_size_around.
- When undoing maximization/untiling, it used to be possible to to grab a window
  "outside" of its frame, and thus drag it off the screen. This is no longer
  possible. Fixes #4644.
- As a side effect, when untiling from the bottom/left/right, the regrab is now
  a much smoother experience.
- Setting the resize aspect ratio while being tiled now untiles and umaximizes
  the window, as these things are incompatible. Fixes an undocumented bug
  (steps to reproduce: maximize, then set aspect ratio).
- When unmaximizing, spurious WindowLeft events were sent, because that path
  didn't set hovered_window. Fixes an undocumented bug.

Since these things are interwoven, this is all a single commit.
This commit is contained in:
Ben Wiederhake 2021-01-23 01:40:19 +01:00 committed by Andreas Kling
parent e8997e1de9
commit 2de471b9f0
3 changed files with 51 additions and 15 deletions

View file

@ -530,9 +530,7 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
m_move_origin = event.position();
if (m_move_origin.y() <= secondary_deadzone)
return true;
auto width_before_resize = m_move_window->width();
m_move_window->set_maximized(false);
m_move_window->move_to(m_move_origin.x() - (m_move_window->width() * ((float)m_move_origin.x() / width_before_resize)), m_move_origin.y());
m_move_window->set_maximized(false, event.position());
m_move_window_origin = m_move_window->position();
}
} else {
@ -558,15 +556,18 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event, Window*& hove
m_move_window->set_tiled(WindowTileType::Top);
} else if (is_resizable && event.y() >= desktop.bottom() - secondary_deadzone) {
m_move_window->set_tiled(WindowTileType::Bottom);
} else if (pixels_moved_from_start > 5 || m_move_window->tiled() == WindowTileType::None) {
m_move_window->set_tiled(WindowTileType::None);
} else if (m_move_window->tiled() == WindowTileType::None) {
Gfx::IntPoint pos = m_move_window_origin.translated(event.position() - m_move_origin);
m_move_window->set_position_without_repaint(pos);
if (m_move_window->rect().contains(event.position()))
hovered_window = m_move_window;
} else if (pixels_moved_from_start > 5) {
m_move_window->set_untiled(event.position());
m_move_origin = event.position();
m_move_window_origin = m_move_window->position();
}
return true;
}
if (m_move_window->rect().contains(event.position()))
hovered_window = m_move_window;
return true;
}
return false;
}