1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 22:07:36 +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

@ -103,13 +103,14 @@ public:
void set_resizable(bool);
bool is_maximized() const { return m_maximized; }
void set_maximized(bool);
void set_maximized(bool, Optional<Gfx::IntPoint> fixed_point = {});
bool is_fullscreen() const { return m_fullscreen; }
void set_fullscreen(bool);
WindowTileType tiled() const { return m_tiled; }
void set_tiled(WindowTileType);
bool set_untiled(const Gfx::IntPoint& fixed_point);
bool is_occluded() const { return m_occluded; }
void set_occluded(bool);
@ -220,7 +221,16 @@ public:
void set_size_increment(const Gfx::IntSize& increment) { m_size_increment = increment; }
const Optional<Gfx::IntSize>& resize_aspect_ratio() const { return m_resize_aspect_ratio; }
void set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio) { m_resize_aspect_ratio = ratio; }
void set_resize_aspect_ratio(const Optional<Gfx::IntSize>& ratio)
{
// "Tiled" means that we take up a chunk of space relative to the screen.
// The screen can change, so "tiled" and "fixed aspect ratio" are mutually exclusive.
// Similarly for "maximized" and "fixed aspect ratio".
// In order to resolve this, undo those properties first:
set_untiled(position());
set_maximized(false);
m_resize_aspect_ratio = ratio;
}
Gfx::IntSize base_size() const { return m_base_size; }
void set_base_size(const Gfx::IntSize& size) { m_base_size = size; }