summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorofftkp <parisoplop@gmail.com>2022-05-07 23:41:25 +0300
committerLinus Groh <mail@linusgroh.de>2022-05-08 16:36:24 +0200
commit70e2b42b9dc5440d2eefca647a1eacd5a4ba23f4 (patch)
tree1c7e56e3a18842cd964ba9deb10660c8530d8020
parent1830996ac937b39243f5f1a3f451aa9d7588bec3 (diff)
downloadserenity-70e2b42b9dc5440d2eefca647a1eacd5a4ba23f4.zip
WindowServer: Consider screen scaling when getting color under cursor
Multiply the cursor position by the current scaling mode multiplier when getting the color under the cursor. Also multiply the screen rectangle before checking if the cursor is within bounds. Color picker would not account for scaling when getting the color under the cursor. Fixes #13906.
-rw-r--r--Userland/Services/WindowServer/ConnectionFromClient.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/Userland/Services/WindowServer/ConnectionFromClient.cpp b/Userland/Services/WindowServer/ConnectionFromClient.cpp
index 76f05ff10f..e36c2d2774 100644
--- a/Userland/Services/WindowServer/ConnectionFromClient.cpp
+++ b/Userland/Services/WindowServer/ConnectionFromClient.cpp
@@ -1128,12 +1128,14 @@ Messages::WindowServer::GetScreenBitmapAroundCursorResponse ConnectionFromClient
Messages::WindowServer::GetColorUnderCursorResponse ConnectionFromClient::get_color_under_cursor()
{
+ auto screen_scale_factor = ScreenInput::the().cursor_location_screen().scale_factor();
// FIXME: Add a mechanism to get screen bitmap without cursor, so we don't have to do this
// manual translation to avoid sampling the color on the actual cursor itself.
- auto cursor_location = ScreenInput::the().cursor_location().translated(-1, -1);
+ auto cursor_location = (ScreenInput::the().cursor_location() * screen_scale_factor).translated(-1, -1);
auto& screen_with_cursor = ScreenInput::the().cursor_location_screen();
+ auto scaled_screen_rect = screen_with_cursor.rect() * screen_scale_factor;
- if (!screen_with_cursor.rect().contains(cursor_location))
+ if (!scaled_screen_rect.contains(cursor_location))
return Optional<Color> {};
return { Compositor::the().color_at_position({}, screen_with_cursor, cursor_location) };