diff options
author | Julian Offenhäuser <metalvoidzz@gmail.com> | 2020-12-05 02:26:21 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-12-06 00:19:04 +0100 |
commit | 503aebaefc7fbda98c3411b927f3c2bea56170aa (patch) | |
tree | 7195e2288806c7d7995cffa8a6fa82e1578a88b2 /Services/WindowServer/Window.cpp | |
parent | 4ec77ba929ed13ed639b803aebb9aa61b1353443 (diff) | |
download | serenity-503aebaefc7fbda98c3411b927f3c2bea56170aa.zip |
WindowServer: Allow for more flexible tiling
The desktop can now be split up into halves (both vertical and
horizontal) and quarters by dragging a window into the corresponding
edge or corner.
This makes tiling behave more like you would expect from similiar
window managers.
Diffstat (limited to 'Services/WindowServer/Window.cpp')
-rw-r--r-- | Services/WindowServer/Window.cpp | 42 |
1 files changed, 38 insertions, 4 deletions
diff --git a/Services/WindowServer/Window.cpp b/Services/WindowServer/Window.cpp index 6c1c5275f3..d1c007dc6a 100644 --- a/Services/WindowServer/Window.cpp +++ b/Services/WindowServer/Window.cpp @@ -598,19 +598,53 @@ void Window::set_fullscreen(bool fullscreen) Gfx::IntRect Window::tiled_rect(WindowTileType tiled) const { int frame_width = (m_frame.rect().width() - m_rect.width()) / 2; + int title_bar_height = m_frame.title_bar_rect().height(); + int menu_height = WindowManager::the().maximized_window_rect(*this).y(); + int max_height = WindowManager::the().maximized_window_rect(*this).height(); + switch (tiled) { case WindowTileType::None: return m_untiled_rect; case WindowTileType::Left: return Gfx::IntRect(0, - WindowManager::the().maximized_window_rect(*this).y(), + menu_height, Screen::the().width() / 2 - frame_width, - WindowManager::the().maximized_window_rect(*this).height()); + max_height); case WindowTileType::Right: return Gfx::IntRect(Screen::the().width() / 2 + frame_width, - WindowManager::the().maximized_window_rect(*this).y(), + menu_height, + Screen::the().width() / 2 - frame_width, + max_height); + case WindowTileType::Top: + return Gfx::IntRect(0, + menu_height, + Screen::the().width() - frame_width, + (max_height - title_bar_height) / 2 - frame_width); + case WindowTileType::Bottom: + return Gfx::IntRect(0, + menu_height + (title_bar_height + max_height) / 2 + frame_width, + Screen::the().width() - frame_width, + (max_height - title_bar_height) / 2 - frame_width); + case WindowTileType::TopLeft: + return Gfx::IntRect(0, + menu_height, + Screen::the().width() / 2 - frame_width, + (max_height - title_bar_height) / 2 - frame_width); + case WindowTileType::TopRight: + return Gfx::IntRect(Screen::the().width() / 2 + frame_width, + menu_height, + Screen::the().width() / 2 - frame_width, + (max_height - title_bar_height) / 2 - frame_width); + case WindowTileType::BottomLeft: + return Gfx::IntRect(0, + menu_height + (title_bar_height + max_height) / 2 + frame_width, + Screen::the().width() / 2 - frame_width, + (max_height - title_bar_height) / 2); + case WindowTileType::BottomRight: + return Gfx::IntRect(Screen::the().width() / 2 + frame_width, + menu_height + (title_bar_height + max_height) / 2 + frame_width, Screen::the().width() / 2 - frame_width, - WindowManager::the().maximized_window_rect(*this).height()); + (max_height - title_bar_height) / 2); default: ASSERT_NOT_REACHED(); } |