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

WindowServer: Add WindowStack::window_at() and use it a bunch

This performs a hit test on the window stack to find the window under
a given cursor position.
This commit is contained in:
Andreas Kling 2021-06-18 01:03:15 +02:00
parent 4133caba78
commit f88361fc28
3 changed files with 27 additions and 21 deletions

View file

@ -765,14 +765,7 @@ bool WindowManager::process_ongoing_drag(MouseEvent& event, Window*& hovered_win
if (!(event.type() == Event::MouseUp && event.button() == MouseButton::Left))
return true;
hovered_window = nullptr;
m_window_stack.for_each_visible_window_from_front_to_back([&](auto& window) {
if (window.hit_test(event.position()).has_value()) {
hovered_window = &window;
return IterationDecision::Break;
}
return IterationDecision::Continue;
});
hovered_window = m_window_stack.window_at(event.position());
if (hovered_window) {
m_dnd_client->async_drag_accepted();
@ -995,13 +988,7 @@ void WindowManager::process_mouse_event(MouseEvent& event, Window*& hovered_wind
m_active_input_tracking_window = nullptr;
}
m_window_stack.for_each_visible_window_from_front_to_back([&](auto& window) {
if (window.hit_test(event.position()).has_value()) {
hovered_window = &window;
return IterationDecision::Break;
}
return IterationDecision::Continue;
});
hovered_window = m_window_stack.window_at(event.position());
} else {
auto process_mouse_event_for_window = [&](Window& window) {
if (&window != m_resize_candidate.ptr())
@ -1101,12 +1088,7 @@ void WindowManager::reevaluate_hovered_window(Window* updated_window)
if (fullscreen_window->hit_test(cursor_location).has_value())
hovered_window = fullscreen_window;
} else {
m_window_stack.for_each_visible_window_from_front_to_back([&](Window& window) {
if (!window.hit_test(cursor_location).has_value())
return IterationDecision::Continue;
hovered_window = &window;
return IterationDecision::Break;
});
hovered_window = m_window_stack.window_at(cursor_location);
}
if (set_hovered_window(hovered_window)) {