WindowServer: Fix the cursor being offset with highlighting enabled

This commit is contained in:
MacDue 2022-06-07 21:12:23 +01:00 committed by Linus Groh
parent fc3fd7212f
commit d3ed490cb4
Notes: sideshowbarker 2024-07-17 10:19:28 +09:00

View File

@ -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;
}