1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:27:43 +00:00

WindowServer: Fix alpha hit-test accessing out-of-bounds pixels

It's possible that the backing store hasn't been updated yet, so
when performing an alpha hit-test make sure the bitmap actually
contains it.

Fixes #6731
This commit is contained in:
Tom 2021-04-29 09:52:47 -06:00 committed by Linus Groh
parent ba294efd8e
commit b88b19272e
2 changed files with 24 additions and 10 deletions

View file

@ -955,8 +955,10 @@ bool Window::hit_test(const Gfx::IntPoint& point, bool include_frame) const
if (threshold == 0 || !m_backing_store || !m_backing_store->has_alpha_channel())
return true;
auto relative_point = point.translated(-rect().location()) * m_backing_store->scale();
auto color = m_backing_store->get_pixel(relative_point);
return color.alpha() >= threshold;
u8 alpha = 0xff;
if (m_backing_store->rect().contains(relative_point))
alpha = m_backing_store->get_pixel(relative_point).alpha();
return alpha >= threshold;
}
void Window::set_menubar(Menubar* menubar)