From 24b8301a0ed1b738850443ad126a272786ec8ad3 Mon Sep 17 00:00:00 2001 From: thankyouverycool <66646555+thankyouverycool@users.noreply.github.com> Date: Wed, 17 Aug 2022 22:16:43 -0400 Subject: [PATCH] WindowServer: Get taskbar height from TaskbarWindow directly Fixes incorrect hardcoded heights and a failure to get taskbar height when tiling on new workspaces. --- .../Services/WindowServer/WindowManager.cpp | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/Userland/Services/WindowServer/WindowManager.cpp b/Userland/Services/WindowServer/WindowManager.cpp index 481121ffc0..cee35cdb93 100644 --- a/Userland/Services/WindowServer/WindowManager.cpp +++ b/Userland/Services/WindowServer/WindowManager.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -1427,7 +1428,7 @@ Gfx::IntRect WindowManager::desktop_rect(Screen& screen) const return Screen::main().rect(); // TODO: we should support fullscreen windows on any screen auto screen_rect = screen.rect(); if (screen.is_main_screen()) - screen_rect.set_height(screen.height() - 28); + screen_rect.set_height(screen.height() - TaskbarWindow::taskbar_height()); return screen_rect; } @@ -2012,13 +2013,8 @@ Gfx::IntRect WindowManager::tiled_window_rect(Window const& window, WindowTileTy auto& screen = Screen::closest_to_rect(window.frame().rect()); Gfx::IntRect rect = screen.rect(); - if (screen.is_main_screen()) { - // Subtract taskbar window height if present - const_cast(this)->current_window_stack().for_each_visible_window_of_type_from_back_to_front(WindowType::Taskbar, [&rect](Window& taskbar_window) { - rect.set_height(rect.height() - taskbar_window.height()); - return IterationDecision::Break; - }); - } + if (screen.is_main_screen()) + rect.set_height(rect.height() - TaskbarWindow::taskbar_height()); if (tile_type == WindowTileType::Maximized) { auto border_thickness = palette().window_border_thickness(); @@ -2217,9 +2213,6 @@ Gfx::IntPoint WindowManager::get_recommended_window_position(Gfx::IntPoint const // FIXME: Find a better source for the width and height to shift by. Gfx::IntPoint shift(8, Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, palette()) + 10); - // FIXME: Find a better source for this. - int taskbar_height = 28; - Window const* overlap_window = nullptr; current_window_stack().for_each_visible_window_of_type_from_front_to_back(WindowType::Normal, [&](Window& window) { if (window.is_default_positioned() && (!overlap_window || overlap_window->window_id() < window.window_id())) { @@ -2233,7 +2226,7 @@ Gfx::IntPoint WindowManager::get_recommended_window_position(Gfx::IntPoint const auto& screen = Screen::closest_to_location(desired); point = overlap_window->position() + shift; point = { point.x() % screen.width(), - (point.y() >= (screen.height() - (screen.is_main_screen() ? taskbar_height : 0))) + (point.y() >= (screen.height() - (screen.is_main_screen() ? TaskbarWindow::taskbar_height() : 0))) ? Gfx::WindowTheme::current().titlebar_height(Gfx::WindowTheme::WindowType::Normal, palette()) : point.y() }; } else {