From c06e765a5a70f62b6bf4926f2fada85bbac95f00 Mon Sep 17 00:00:00 2001 From: Tom Date: Fri, 2 Jul 2021 11:02:54 -0600 Subject: [PATCH] WindowServer: Show window's desktop in window switcher if needed If there are windows on more than one desktop then the window switcher should show on which one they are located. --- Userland/Services/WindowServer/WindowSwitcher.cpp | 15 ++++++++++++--- Userland/Services/WindowServer/WindowSwitcher.h | 1 + 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/Userland/Services/WindowServer/WindowSwitcher.cpp b/Userland/Services/WindowServer/WindowSwitcher.cpp index f7054c1c17..26d29325e5 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.cpp +++ b/Userland/Services/WindowServer/WindowSwitcher.cpp @@ -191,7 +191,8 @@ void WindowSwitcher::draw() painter.fill_rect(icon_rect, palette.window()); painter.blit(icon_rect.location(), window.icon(), window.icon().rect()); painter.draw_text(item_rect.translated(thumbnail_width() + 12, 0), window.computed_title(), WindowManager::the().window_title_font(), Gfx::TextAlignment::CenterLeft, text_color); - painter.draw_text(item_rect, window.rect().to_string(), Gfx::TextAlignment::CenterRight, rect_text_color); + auto window_details = m_windows_on_multiple_stacks ? String::formatted("{} on {}:{}", window.rect().to_string(), window.outer_stack()->row() + 1, window.outer_stack()->column() + 1) : window.rect().to_string(); + painter.draw_text(item_rect, window_details, Gfx::TextAlignment::CenterRight, rect_text_color); } } @@ -204,10 +205,12 @@ void WindowSwitcher::refresh() if (!selected_window) selected_window = wm.highlight_window() ? wm.highlight_window() : wm.active_window(); m_windows.clear(); + m_windows_on_multiple_stacks = false; m_selected_index = 0; int window_count = 0; int longest_title_width = 0; + WindowStack* last_added_on_window_stack = nullptr; auto add_window_stack_windows = [&](WindowStack& window_stack) { window_stack.for_each_window_of_type_from_front_to_back( WindowType::Normal, [&](Window& window) { @@ -218,6 +221,12 @@ void WindowSwitcher::refresh() if (selected_window == &window) m_selected_index = m_windows.size(); m_windows.append(window); + if (!last_added_on_window_stack) { + last_added_on_window_stack = window.outer_stack(); + } else if (last_added_on_window_stack != window.outer_stack()) { + last_added_on_window_stack = window.outer_stack(); + m_windows_on_multiple_stacks = true; + } return IterationDecision::Continue; }, true); @@ -235,8 +244,8 @@ void WindowSwitcher::refresh() hide(); return; } - int space_for_window_rect = 180; - m_rect.set_width(thumbnail_width() + longest_title_width + space_for_window_rect + padding() * 2 + item_padding() * 2); + int space_for_window_details = 200; + m_rect.set_width(thumbnail_width() + longest_title_width + space_for_window_details + padding() * 2 + item_padding() * 2); m_rect.set_height(window_count * item_height() + padding() * 2); m_rect.center_within(Screen::main().rect()); if (!m_switcher_window) diff --git a/Userland/Services/WindowServer/WindowSwitcher.h b/Userland/Services/WindowServer/WindowSwitcher.h index c0997eecfd..a59a20f963 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.h +++ b/Userland/Services/WindowServer/WindowSwitcher.h @@ -67,6 +67,7 @@ private: Mode m_mode { Mode::ShowCurrentDesktop }; Gfx::IntRect m_rect; bool m_visible { false }; + bool m_windows_on_multiple_stacks { false }; Vector> m_windows; int m_selected_index { 0 }; int m_hovered_index { -1 };