diff options
author | thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> | 2022-08-26 16:08:26 -0400 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2022-08-28 16:04:35 +0100 |
commit | b2b68a7551d4a1f45e75a52b5ca33a10a3ecce01 (patch) | |
tree | d58dbcc4d44c9d162aef1f644e35680c87cb56ce /Userland | |
parent | 38e13772e0c0b864736e3da419d8792b39eebdc2 (diff) | |
download | serenity-b2b68a7551d4a1f45e75a52b5ca33a10a3ecce01.zip |
WindowServer: Continue processing ongoing resizes after tiling
Just like tiling behavior during ongoing moves, now resizing
does not finish until a MouseUp event, letting you drag out of
undesired tile states. Resize tiling only works with vertical
and horizontal cursors now to cut down on unintentional tiling
from the corners.
Diffstat (limited to 'Userland')
-rw-r--r-- | Userland/Services/WindowServer/WindowManager.cpp | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 61df10906a..860554dc58 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -864,22 +864,6 @@ bool WindowManager::process_ongoing_window_resize(MouseEvent const& event) if (!m_resize_window) return false; - if (event.type() == Event::MouseMove) { - int const vertical_maximize_deadzone = 5; - auto& cursor_screen = ScreenInput::the().cursor_location_screen(); - if (&cursor_screen == &Screen::closest_to_rect(m_resize_window->rect())) { - auto desktop_rect = this->desktop_rect(cursor_screen); - if (event.y() >= desktop_rect.bottom() - vertical_maximize_deadzone + 1 || event.y() <= desktop_rect.top() + vertical_maximize_deadzone - 1) { - dbgln_if(RESIZE_DEBUG, "Should tile as VerticallyMaximized"); - m_resize_window->set_tiled(WindowTileType::VerticallyMaximized); - m_resize_window = nullptr; - m_geometry_overlay = nullptr; - m_resizing_mouse_button = MouseButton::None; - return true; - } - } - } - if (event.type() == Event::MouseUp && event.button() == m_resizing_mouse_button) { dbgln_if(RESIZE_DEBUG, "[WM] Finish resizing Window({})", m_resize_window); @@ -897,6 +881,23 @@ bool WindowManager::process_ongoing_window_resize(MouseEvent const& event) if (event.type() != Event::MouseMove) return true; + auto& cursor_screen = ScreenInput::the().cursor_location_screen(); + auto& closest_screen = Screen::closest_to_rect(m_resize_window->rect()); + if (&cursor_screen == &closest_screen) { + constexpr auto hot_zone = 10; + Gfx::IntRect tiling_rect = desktop_rect(cursor_screen).shrunken({ hot_zone, hot_zone }); + if ((m_resize_direction == ResizeDirection::Up || m_resize_direction == ResizeDirection::Down) + && (event.y() >= tiling_rect.bottom() || event.y() <= tiling_rect.top())) { + m_resize_window->set_tiled(WindowTileType::VerticallyMaximized); + return true; + } + if ((m_resize_direction == ResizeDirection::Left || m_resize_direction == ResizeDirection::Right) + && (event.x() >= tiling_rect.right() || event.x() <= tiling_rect.left())) { + m_resize_window->set_tiled(WindowTileType::HorizontallyMaximized); + return true; + } + } + int diff_x = event.x() - m_resize_origin.x(); int diff_y = event.y() - m_resize_origin.y(); |