From d3ed490cb48245485a533ffdad166a586946f410 Mon Sep 17 00:00:00 2001 From: MacDue Date: Tue, 7 Jun 2022 21:12:23 +0100 Subject: [PATCH] WindowServer: Fix the cursor being offset with highlighting enabled --- Userland/Services/WindowServer/Compositor.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Userland/Services/WindowServer/Compositor.cpp b/Userland/Services/WindowServer/Compositor.cpp index 485e5987dc..d41c656355 100644 --- a/Userland/Services/WindowServer/Compositor.cpp +++ b/Userland/Services/WindowServer/Compositor.cpp @@ -846,9 +846,11 @@ Gfx::IntRect Compositor::current_cursor_rect() const Gfx::IntRect cursor_rect { ScreenInput::the().cursor_location().translated(-current_cursor.params().hotspot()), current_cursor.size() }; if (wm.is_cursor_highlight_enabled()) { auto highlight_diameter = wm.cursor_highlight_radius() * 2; - cursor_rect.inflate( - highlight_diameter - cursor_rect.width(), - highlight_diameter - cursor_rect.height()); + auto inflate_w = highlight_diameter - cursor_rect.width(); + auto inflate_h = highlight_diameter - cursor_rect.height(); + cursor_rect.inflate(inflate_w, inflate_h); + // Ensures cursor stays in the same location when highlighting is enabled. + cursor_rect.translate_by(-(inflate_w % 2), -(inflate_h % 2)); } return cursor_rect; }