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

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.
This commit is contained in:
thankyouverycool 2022-08-18 06:52:55 -04:00 committed by Andreas Kling
parent a1dceb5b97
commit 68570e897d
4 changed files with 7 additions and 32 deletions

View file

@ -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<> template<>
String IntRect::to_string() const String IntRect::to_string() const
{ {

View file

@ -107,8 +107,6 @@ public:
m_size = size; m_size = size;
} }
void set_size_around(Size<T> const&, Point<T> const& fixed_point);
void set_size(T width, T height) void set_size(T width, T height)
{ {
m_size.set_width(width); m_size.set_width(width);

View file

@ -415,7 +415,7 @@ void Window::set_occluded(bool occluded)
WindowManager::the().notify_occlusion_state_changed(*this); 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) if (is_maximized() == maximized)
return; return;
@ -427,13 +427,7 @@ void Window::set_maximized(bool maximized, Optional<Gfx::IntPoint> fixed_point)
m_unmaximized_rect = m_floating_rect; m_unmaximized_rect = m_floating_rect;
set_rect(WindowManager::the().tiled_window_rect(*this)); set_rect(WindowManager::the().tiled_window_rect(*this));
} else { } else {
if (fixed_point.has_value()) { set_rect(m_unmaximized_rect);
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);
}
} }
m_frame.did_set_maximized({}, maximized); m_frame.did_set_maximized({}, maximized);
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect)); 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; 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) if (m_tile_type == WindowTileType::None)
return false; return false;
VERIFY(!resize_aspect_ratio().has_value()); VERIFY(!resize_aspect_ratio().has_value());
m_tile_type = WindowTileType::None; m_tile_type = WindowTileType::None;
set_rect(m_floating_rect);
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);
}
Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect)); Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));

View file

@ -109,7 +109,7 @@ public:
void set_resizable(bool); void set_resizable(bool);
bool is_maximized() const { return m_tile_type == WindowTileType::Maximized; } 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; } bool is_always_on_top() const { return m_always_on_top; }
void set_always_on_top(bool); void set_always_on_top(bool);
@ -122,7 +122,7 @@ public:
void set_tiled(WindowTileType); void set_tiled(WindowTileType);
WindowTileType tile_type_based_on_rect(Gfx::IntRect const&) const; WindowTileType tile_type_based_on_rect(Gfx::IntRect const&) const;
void check_untile_due_to_resize(Gfx::IntRect 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; } Gfx::IntRect floating_rect() const { return m_floating_rect; }
void set_floating_rect(Gfx::IntRect rect) { m_floating_rect = 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. // The screen can change, so "tiled" and "fixed aspect ratio" are mutually exclusive.
// Similarly for "maximized" and "fixed aspect ratio". // Similarly for "maximized" and "fixed aspect ratio".
// In order to resolve this, undo those properties first: // In order to resolve this, undo those properties first:
set_untiled(position()); set_untiled();
set_maximized(false); set_maximized(false);
m_resize_aspect_ratio = ratio; m_resize_aspect_ratio = ratio;
} }