Browse Source

WindowManager: Restore a window's geometry when untiling it
Specifically, when untiling it using the Super-{Left,Right} shortcuts

Fixes #5182

etaIneLp 4 years ago
parent
commit
e625ae1130

+ 8 - 4
Userland/Services/WindowServer/Window.cpp

@@ -702,7 +702,7 @@ Gfx::IntRect Window::tiled_rect(WindowTileType tiled) const
     }
 }
 
-bool Window::set_untiled(const Gfx::IntPoint& fixed_point)
+bool Window::set_untiled(Optional<Gfx::IntPoint> fixed_point)
 {
     if (m_tiled == WindowTileType::None)
         return false;
@@ -710,9 +710,13 @@ bool Window::set_untiled(const Gfx::IntPoint& fixed_point)
 
     m_tiled = WindowTileType::None;
 
-    auto new_rect = Gfx::IntRect(m_rect);
-    new_rect.set_size_around(m_untiled_rect.size(), fixed_point);
-    set_rect(new_rect);
+    if (fixed_point.has_value()) {
+        auto new_rect = Gfx::IntRect(m_rect);
+        new_rect.set_size_around(m_untiled_rect.size(), fixed_point.value());
+        set_rect(new_rect);
+    } else {
+        set_rect(m_untiled_rect);
+    }
 
     Core::EventLoop::current().post_event(*this, make<ResizeEvent>(m_rect));
 

+ 1 - 1
Userland/Services/WindowServer/Window.h

@@ -110,7 +110,7 @@ public:
 
     WindowTileType tiled() const { return m_tiled; }
     void set_tiled(WindowTileType);
-    bool set_untiled(const Gfx::IntPoint& fixed_point);
+    bool set_untiled(Optional<Gfx::IntPoint> fixed_point = {});
 
     bool is_occluded() const { return m_occluded; }
     void set_occluded(bool);

+ 6 - 2
Userland/Services/WindowServer/WindowManager.cpp

@@ -1133,8 +1133,10 @@ void WindowManager::event(Core::Event& event)
                         return;
                     }
                     if (key_event.key() == Key_Left) {
+                        if (m_active_input_window->tiled() == WindowTileType::Left)
+                            return;
                         if (m_active_input_window->tiled() != WindowTileType::None) {
-                            m_active_input_window->set_tiled(WindowTileType::None);
+                            m_active_input_window->set_untiled();
                             return;
                         }
                         if (m_active_input_window->is_maximized())
@@ -1143,8 +1145,10 @@ void WindowManager::event(Core::Event& event)
                         return;
                     }
                     if (key_event.key() == Key_Right) {
+                        if (m_active_input_window->tiled() == WindowTileType::Right)
+                            return;
                         if (m_active_input_window->tiled() != WindowTileType::None) {
-                            m_active_input_window->set_tiled(WindowTileType::None);
+                            m_active_input_window->set_untiled();
                             return;
                         }
                         if (m_active_input_window->is_maximized())