egl: scale the cursor by the presented view, not the virtual desktop

With a multi-display guest the presented image is the composed view, which
may be a single display's crop, but the cursor scale and position still
divided by the guest's whole virtual desktop. On a two monitor guest this
drew the cursor at half size in X and half way to its true position:
visibly stretched and offset from where clicks landed. Input mapping
already used the view; drawing now does too.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WxYTZ8oBdHX3YrHGgdLKwC
This commit is contained in:
donnyandClaude Fable 5 committed 2026-08-20 16:55:01 -07:00
1 parent c04a12d2b5
commit 9c4216b41c
1 file changed
+28 -11
+28 -11
View File
@@ -373,6 +373,21 @@ static void egl_onRestart(LG_Renderer * renderer)
});
}
/* When the frame is a multi-display atlas the presented image is the composed
* view, so everything cursor related must scale by the view, not the guest's
* whole virtual desktop. */
static inline unsigned int presentedWidth(struct Inst * this)
{
return this->format.displayCount ?
this->format.viewWidth : this->format.screenWidth;
}
static inline unsigned int presentedHeight(struct Inst * this)
{
return this->format.displayCount ?
this->format.viewHeight : this->format.screenHeight;
}
static void egl_calc_mouse_size(struct Inst * this)
{
if (this->showSpice)
@@ -395,18 +410,18 @@ static void egl_calc_mouse_size(struct Inst * this)
{
case LG_ROTATE_0:
case LG_ROTATE_180:
this->mouseScaleX = 2.0f / this->format.screenWidth;
this->mouseScaleY = 2.0f / this->format.screenHeight;
w = this->format.screenWidth;
h = this->format.screenHeight;
this->mouseScaleX = 2.0f / presentedWidth (this);
this->mouseScaleY = 2.0f / presentedHeight(this);
w = presentedWidth (this);
h = presentedHeight(this);
break;
case LG_ROTATE_90:
case LG_ROTATE_270:
this->mouseScaleX = 2.0f / this->format.screenHeight;
this->mouseScaleY = 2.0f / this->format.screenWidth;
w = this->format.screenHeight;
h = this->format.screenWidth;
this->mouseScaleX = 2.0f / presentedHeight(this);
this->mouseScaleY = 2.0f / presentedWidth (this);
w = presentedHeight(this);
h = presentedWidth (this);
break;
default:
@@ -552,8 +567,8 @@ static void egl_onResize(LG_Renderer * renderer, const int width, const int heig
float scale = max(1.0f,
this->formatValid ?
max(
(float)this->format.screenWidth / this->width,
(float)this->format.screenHeight / this->height)
(float)presentedWidth (this) / this->width,
(float)presentedHeight(this) / this->height)
: 1.0f);
egl_cursorSetScale(this->cursor, scale);
}
@@ -701,7 +716,9 @@ static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat fo
if (likely(this->scalePointer))
{
float scale = max(1.0f, (float)format.screenWidth / this->width);
const float presented = format.displayCount ?
format.viewWidth : format.screenWidth;
float scale = max(1.0f, presented / this->width);
egl_cursorSetScale(this->cursor, scale);
}