summaryrefslogtreecommitdiff
path: root/Userland/Services
diff options
context:
space:
mode:
authorTom <tomut@yahoo.com>2021-02-17 16:12:05 -0700
committerAndreas Kling <kling@serenityos.org>2021-02-18 07:45:22 +0100
commit6af4d35e8e62b21ad1332a787e46a9082ad77e63 (patch)
treee9c3a00304b78f317d1ac4792f53725ba8f5ce22 /Userland/Services
parentb55c9f6bbac562215fa5c078757de8fd235f82d0 (diff)
downloadserenity-6af4d35e8e62b21ad1332a787e46a9082ad77e63.zip
WindowServer: Apply the backing bitmap's scale when alpha hit-testing
Fixes #5390
Diffstat (limited to 'Userland/Services')
-rw-r--r--Userland/Services/WindowServer/Window.cpp3
-rw-r--r--Userland/Services/WindowServer/WindowFrame.cpp8
2 files changed, 6 insertions, 5 deletions
diff --git a/Userland/Services/WindowServer/Window.cpp b/Userland/Services/WindowServer/Window.cpp
index 30937dea14..8887125f6c 100644
--- a/Userland/Services/WindowServer/Window.cpp
+++ b/Userland/Services/WindowServer/Window.cpp
@@ -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;
}
diff --git a/Userland/Services/WindowServer/WindowFrame.cpp b/Userland/Services/WindowServer/WindowFrame.cpp
index 19231b52de..12640b66c5 100644
--- a/Userland/Services/WindowServer/WindowFrame.cpp
+++ b/Userland/Services/WindowServer/WindowFrame.cpp
@@ -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;
}