diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp index dadb571e155..304a60a1795 100644 --- a/Userland/Services/WindowServer/Window.cpp +++ b/Userland/Services/WindowServer/Window.cpp @@ -159,6 +159,9 @@ void Window::set_rect(const Gfx::IntRect& rect) m_backing_store = Gfx::Bitmap::try_create(format, m_rect.size()).release_value_but_fixme_should_propagate_errors(); } + if (m_floating_rect.is_empty()) + m_floating_rect = rect; + invalidate(true, old_rect.size() != rect.size()); m_frame.window_rect_changed(old_rect, rect); invalidate_last_rendered_screen_rects(); @@ -481,7 +484,7 @@ void Window::set_maximized(bool maximized, Optional fixed_point) m_maximized = maximized; update_window_menu_items(); if (maximized) { - m_unmaximized_rect = m_rect; + m_unmaximized_rect = m_floating_rect; set_rect(WindowManager::the().maximized_window_rect(*this)); } else { if (fixed_point.has_value()) { @@ -1090,10 +1093,10 @@ bool Window::set_untiled(Optional fixed_point) if (fixed_point.has_value()) { auto new_rect = Gfx::IntRect(m_rect); - new_rect.set_size_around(m_untiled_rect.size(), fixed_point.value()); + new_rect.set_size_around(m_floating_rect.size(), fixed_point.value()); set_rect(new_rect); } else { - set_rect(m_untiled_rect); + set_rect(m_floating_rect); } Core::EventLoop::current().post_event(*this, make(m_rect)); @@ -1111,8 +1114,9 @@ void Window::set_tiled(Screen* screen, WindowTileType tile_type) if (resize_aspect_ratio().has_value()) return; - if (m_tile_type == WindowTileType::None) - m_untiled_rect = m_rect; + if (is_maximized()) + set_maximized(false); + m_tile_type = tile_type; set_rect(tiled_rect(screen, tile_type)); diff --git a/Userland/Services/WindowServer/Window.h b/Userland/Services/WindowServer/Window.h index 261cbcf4f44..89796a99ca4 100644 --- a/Userland/Services/WindowServer/Window.h +++ b/Userland/Services/WindowServer/Window.h @@ -123,6 +123,9 @@ public: void check_untile_due_to_resize(Gfx::IntRect const&); bool set_untiled(Optional fixed_point = {}); + Gfx::IntRect floating_rect() const { return m_floating_rect; } + void set_floating_rect(Gfx::IntRect rect) { m_floating_rect = rect; } + void set_forced_shadow(bool b) { m_forced_shadow = b; } bool has_forced_shadow() const { return m_forced_shadow; } @@ -436,7 +439,7 @@ private: bool m_invalidate_last_render_rects { false }; Vector m_stealable_by_client_ids; WindowTileType m_tile_type { WindowTileType::None }; - Gfx::IntRect m_untiled_rect; + Gfx::IntRect m_floating_rect; bool m_occluded { false }; RefPtr m_backing_store; RefPtr m_last_backing_store; diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 805be5be309..ff9226a2956 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -740,6 +740,9 @@ bool WindowManager::process_ongoing_window_move(MouseEvent& event) dbgln_if(MOVE_DEBUG, "[WM] Finish moving Window({})", m_move_window); + if (!m_move_window->is_tiled() && !m_move_window->is_maximized()) + m_move_window->set_floating_rect(m_move_window->rect()); + m_move_window->invalidate(true, true); if (m_move_window->is_resizable()) { process_event_for_doubleclick(*m_move_window, event); @@ -824,6 +827,9 @@ bool WindowManager::process_ongoing_window_resize(MouseEvent const& event) if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) { dbgln_if(RESIZE_DEBUG, "[WM] Finish resizing Window({})", m_resize_window); + if (!m_resize_window->is_tiled() && !m_resize_window->is_maximized()) + m_resize_window->set_floating_rect(m_resize_window->rect()); + const int vertical_maximize_deadzone = 5; auto& cursor_screen = ScreenInput::the().cursor_location_screen(); if (&cursor_screen == &Screen::closest_to_rect(m_resize_window->rect())) {