From 7fb2540ffe15da9e02dc3ebcdf598469d617f843 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 14 Nov 2021 12:00:55 +0100 Subject: [PATCH] WindowServer: Clear window switcher's hovered item when cursor leaves When the mouse cursor leaves the switcher window, we'll want to clear the hovered item index so it stops showing as hovered. :^) --- Userland/Services/WindowServer/WindowSwitcher.cpp | 15 ++++++++++++++- Userland/Services/WindowServer/WindowSwitcher.h | 1 + 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/Userland/Services/WindowServer/WindowSwitcher.cpp b/Userland/Services/WindowServer/WindowSwitcher.cpp index 4e738f7a53..656bfade4d 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.cpp +++ b/Userland/Services/WindowServer/WindowSwitcher.cpp @@ -42,7 +42,7 @@ void WindowSwitcher::set_visible(bool visible) m_switcher_window->set_visible(visible); if (!m_visible) return; - m_hovered_index = -1; + clear_hovered_index(); refresh(); } @@ -55,6 +55,11 @@ Window* WindowSwitcher::selected_window() void WindowSwitcher::event(Core::Event& event) { + if (event.type() == Event::WindowLeft) { + clear_hovered_index(); + return; + } + if (!static_cast(event).is_mouse_event()) return; @@ -261,4 +266,12 @@ void WindowSwitcher::refresh_if_needed() refresh(); } +void WindowSwitcher::clear_hovered_index() +{ + if (m_hovered_index == -1) + return; + m_hovered_index = -1; + redraw(); +} + } diff --git a/Userland/Services/WindowServer/WindowSwitcher.h b/Userland/Services/WindowServer/WindowSwitcher.h index a834c8f1cc..21a058e0a5 100644 --- a/Userland/Services/WindowServer/WindowSwitcher.h +++ b/Userland/Services/WindowServer/WindowSwitcher.h @@ -61,6 +61,7 @@ private: void select_window_at_index(int index); Gfx::IntRect item_rect(int index) const; Window* selected_window(); + void clear_hovered_index(); virtual void event(Core::Event&) override;