diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-08-18 06:52:55 -0400 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-08-25 13:28:50 +0200 |
commit | 68570e897d393e4c3f6a2306f938ffe8ff96c00e (patch) | |
tree | 1cd2ec5268e38212217720eafa322a548e3777ec | |
parent | a1dceb5b97480100e5f03aaee53ee3cbfa549c26 (diff) | |
download | serenity-68570e897d393e4c3f6a2306f938ffe8ff96c00e.zip |
LibGfx+WindowServer: Remove set_size_around() from Rect and Window
Superceded by to_floating_cursor_position() as a more accurate way
to reposition windows on untile. Effectively made set_size_around()
dead code, so the remnants can be removed.
-rw-r--r-- | Userland/Libraries/LibGfx/Rect.cpp | 10 | ||||
-rw-r--r-- | Userland/Libraries/LibGfx/Rect.h | 2 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Window.cpp | 21 | ||||
-rw-r--r-- | Userland/Services/WindowServer/Window.h | 6 |
4 files changed, 7 insertions, 32 deletions
diff --git a/Userland/Libraries/LibGfx/Rect.cpp b/Userland/Libraries/LibGfx/Rect.cpp index 64db8e6270..5f99fe2842 100644 --- a/Userland/Libraries/LibGfx/Rect.cpp +++ b/Userland/Libraries/LibGfx/Rect.cpp @@ -309,16 +309,6 @@ void Rect<T>::align_within(Rect<T> const& other, TextAlignment alignment) } } -template<typename T> -void Rect<T>::set_size_around(Size<T> const& new_size, Point<T> const& fixed_point) -{ - const T new_x = fixed_point.x() - (T)(new_size.width() * ((float)(fixed_point.x() - x()) / width())); - const T new_y = fixed_point.y() - (T)(new_size.height() * ((float)(fixed_point.y() - y()) / height())); - - set_location({ new_x, new_y }); - set_size(new_size); -} - template<> String IntRect::to_string() const { diff --git a/Userland/Libraries/LibGfx/Rect.h b/Userland/Libraries/LibGfx/Rect.h index 9c6f63afaf..fcee570127 100644 --- a/Userland/Libraries/LibGfx/Rect.h +++ b/Userland/Libraries/LibGfx/Rect.h @@ -107,8 +107,6 @@ public: m_size = size; } - void set_size_around(Size<T> const&, Point<T> const& fixed_point); - void set_size(T width, T height) { m_size.set_width(width); diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index 43fc259806..c914b8315d 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -415,7 +415,7 @@ void Window::set_occluded(bool occluded) WindowManager::the().notify_occlusion_state_changed(*this); } -void Window::set_maximized(bool maximized, Optional<Gfx::IntPoint> fixed_point) +void Window::set_maximized(bool maximized) { if (is_maximized() == maximized) return; @@ -427,13 +427,7 @@ void Window::set_maximized(bool maximized, Optional<Gfx::IntPoint> fixed_point) m_unmaximized_rect = m_floating_rect; set_rect(WindowManager::the().tiled_window_rect(*this)); } else { - if (fixed_point.has_value()) { - auto new_rect = Gfx::IntRect(m_rect); - new_rect.set_size_around(m_unmaximized_rect.size(), fixed_point.value()); - set_rect(new_rect); - } else { - set_rect(m_unmaximized_rect); - } + set_rect(m_unmaximized_rect); } m_frame.did_set_maximized({}, maximized); Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect)); @@ -920,21 +914,14 @@ void Window::check_untile_due_to_resize(Gfx::IntRect const& new_rect) m_tile_type = new_tile_type; } -bool Window::set_untiled(Optional<Gfx::IntPoint> fixed_point) +bool Window::set_untiled() { if (m_tile_type == WindowTileType::None) return false; VERIFY(!resize_aspect_ratio().has_value()); m_tile_type = WindowTileType::None; - - if (fixed_point.has_value()) { - auto new_rect = Gfx::IntRect(m_rect); - new_rect.set_size_around(m_floating_rect.size(), fixed_point.value()); - set_rect(new_rect); - } else { - set_rect(m_floating_rect); - } + set_rect(m_floating_rect); Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect)); diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h index f3dfc83f02..94ab480be0 100644 --- a/Userland/Services/WindowServer/Window.h +++ b/Userland/Services/WindowServer/Window.h @@ -109,7 +109,7 @@ public: void set_resizable(bool); bool is_maximized() const { return m_tile_type == WindowTileType::Maximized; } - void set_maximized(bool, Optional<Gfx::IntPoint> fixed_point = {}); + void set_maximized(bool); bool is_always_on_top() const { return m_always_on_top; } void set_always_on_top(bool); @@ -122,7 +122,7 @@ public: void set_tiled(WindowTileType); WindowTileType tile_type_based_on_rect(Gfx::IntRect const&) const; void check_untile_due_to_resize(Gfx::IntRect const&); - bool set_untiled(Optional<Gfx::IntPoint> fixed_point = {}); + bool set_untiled(); Gfx::IntRect floating_rect() const { return m_floating_rect; } void set_floating_rect(Gfx::IntRect rect) { m_floating_rect = rect; } @@ -265,7 +265,7 @@ public: // 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_untiled(); set_maximized(false); m_resize_aspect_ratio = ratio; } |