Sfoglia il codice sorgente

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.
thankyouverycool 3 anni fa
parent
commit
68570e897d

+ 0 - 10
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
 {

+ 0 - 2
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);

+ 4 - 17
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));
 

+ 3 - 3
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;
     }