mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-01-06 02:55:49 +03:00
WindowServer: Apply the backing bitmap's scale when alpha hit-testing
Fixes #5390
This commit is contained in:
parent
b55c9f6bba
commit
6af4d35e8e
Notes:
sideshowbarker
2024-07-18 22:10:03 +09:00
Author: https://github.com/tomuta Commit: https://github.com/SerenityOS/serenity/commit/6af4d35e8e6 Pull-request: https://github.com/SerenityOS/serenity/pull/5394 Issue: https://github.com/SerenityOS/serenity/issues/5390 Reviewed-by: https://github.com/nico
@ -916,7 +916,8 @@ bool Window::hit_test(const Gfx::IntPoint& point, bool include_frame) const
|
||||
u8 threshold = alpha_hit_threshold() * 255;
|
||||
if (threshold == 0 || !m_backing_store || !m_backing_store->has_alpha_channel())
|
||||
return true;
|
||||
auto color = m_backing_store->get_pixel(point.translated(-rect().location()));
|
||||
auto relative_point = point.translated(-rect().location()) * m_backing_store->scale();
|
||||
auto color = m_backing_store->get_pixel(relative_point);
|
||||
return color.alpha() >= threshold;
|
||||
}
|
||||
|
||||
|
@ -560,16 +560,16 @@ bool WindowFrame::hit_test(const Gfx::IntPoint& point) const
|
||||
auto relative_point = point.translated(-render_rect().location());
|
||||
if (point.y() < window_rect.y()) {
|
||||
if (m_top_bottom)
|
||||
alpha = m_top_bottom->get_pixel(relative_point).alpha();
|
||||
alpha = m_top_bottom->get_pixel(relative_point * m_top_bottom->scale()).alpha();
|
||||
} else if (point.y() > window_rect.bottom()) {
|
||||
if (m_top_bottom)
|
||||
alpha = m_top_bottom->get_pixel(relative_point.x(), m_bottom_y + point.y() - window_rect.bottom() - 1).alpha();
|
||||
alpha = m_top_bottom->get_pixel(relative_point.x() * m_top_bottom->scale(), m_bottom_y * m_top_bottom->scale() + point.y() - window_rect.bottom() - 1).alpha();
|
||||
} else if (point.x() < window_rect.x()) {
|
||||
if (m_left_right)
|
||||
alpha = m_left_right->get_pixel(relative_point.x(), relative_point.y() - m_bottom_y).alpha();
|
||||
alpha = m_left_right->get_pixel(relative_point.x() * m_left_right->scale(), (relative_point.y() - m_bottom_y) * m_left_right->scale()).alpha();
|
||||
} else if (point.x() > window_rect.right()) {
|
||||
if (m_left_right)
|
||||
alpha = m_left_right->get_pixel(m_right_x + point.x() - window_rect.right() - 1, relative_point.y() - m_bottom_y).alpha();
|
||||
alpha = m_left_right->get_pixel(m_right_x * m_left_right->scale() + point.x() - window_rect.right() - 1, (relative_point.y() - m_bottom_y) * m_left_right->scale()).alpha();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user