1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:47:45 +00:00

WindowServer: Window iteration should see the highlight window "in front".

This commit is contained in:
Andreas Kling 2019-03-10 02:33:43 +01:00
parent 420ef4da8a
commit a149ad9b44
2 changed files with 19 additions and 15 deletions

View file

@ -177,14 +177,23 @@ private:
template<typename Callback>
IterationDecision WSWindowManager::for_each_visible_window_of_type_from_back_to_front(WSWindowType type, Callback callback)
{
bool do_highlight_window_at_end = false;
for (auto* window = m_windows_in_order.head(); window; window = window->next()) {
if (!window->is_visible())
continue;
if (window->type() != type)
continue;
if (m_highlight_window.ptr() == window) {
do_highlight_window_at_end = true;
continue;
}
if (callback(*window) == IterationDecision::Abort)
return IterationDecision::Abort;
}
if (do_highlight_window_at_end) {
if (callback(*m_highlight_window) == IterationDecision::Abort)
return IterationDecision::Abort;
}
return IterationDecision::Continue;
}
@ -199,11 +208,18 @@ IterationDecision WSWindowManager::for_each_visible_window_from_back_to_front(Ca
template<typename Callback>
IterationDecision WSWindowManager::for_each_visible_window_of_type_from_front_to_back(WSWindowType type, Callback callback)
{
if (m_highlight_window && m_highlight_window->type() == type && m_highlight_window->is_visible()) {
if (callback(*m_highlight_window) == IterationDecision::Abort)
return IterationDecision::Abort;
}
for (auto* window = m_windows_in_order.tail(); window; window = window->prev()) {
if (!window->is_visible())
continue;
if (window->type() != type)
continue;
if (window == m_highlight_window.ptr())
continue;
if (callback(*window) == IterationDecision::Abort)
return IterationDecision::Abort;
}