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:
1 parent
c04a12d2b5
commit
9c4216b41c
1 file changed
+28
-11
+28
-11
@@ -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)
|
static void egl_calc_mouse_size(struct Inst * this)
|
||||||
{
|
{
|
||||||
if (this->showSpice)
|
if (this->showSpice)
|
||||||
@@ -395,18 +410,18 @@ static void egl_calc_mouse_size(struct Inst * this)
|
|||||||
{
|
{
|
||||||
case LG_ROTATE_0:
|
case LG_ROTATE_0:
|
||||||
case LG_ROTATE_180:
|
case LG_ROTATE_180:
|
||||||
this->mouseScaleX = 2.0f / this->format.screenWidth;
|
this->mouseScaleX = 2.0f / presentedWidth (this);
|
||||||
this->mouseScaleY = 2.0f / this->format.screenHeight;
|
this->mouseScaleY = 2.0f / presentedHeight(this);
|
||||||
w = this->format.screenWidth;
|
w = presentedWidth (this);
|
||||||
h = this->format.screenHeight;
|
h = presentedHeight(this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case LG_ROTATE_90:
|
case LG_ROTATE_90:
|
||||||
case LG_ROTATE_270:
|
case LG_ROTATE_270:
|
||||||
this->mouseScaleX = 2.0f / this->format.screenHeight;
|
this->mouseScaleX = 2.0f / presentedHeight(this);
|
||||||
this->mouseScaleY = 2.0f / this->format.screenWidth;
|
this->mouseScaleY = 2.0f / presentedWidth (this);
|
||||||
w = this->format.screenHeight;
|
w = presentedHeight(this);
|
||||||
h = this->format.screenWidth;
|
h = presentedWidth (this);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
@@ -552,8 +567,8 @@ static void egl_onResize(LG_Renderer * renderer, const int width, const int heig
|
|||||||
float scale = max(1.0f,
|
float scale = max(1.0f,
|
||||||
this->formatValid ?
|
this->formatValid ?
|
||||||
max(
|
max(
|
||||||
(float)this->format.screenWidth / this->width,
|
(float)presentedWidth (this) / this->width,
|
||||||
(float)this->format.screenHeight / this->height)
|
(float)presentedHeight(this) / this->height)
|
||||||
: 1.0f);
|
: 1.0f);
|
||||||
egl_cursorSetScale(this->cursor, scale);
|
egl_cursorSetScale(this->cursor, scale);
|
||||||
}
|
}
|
||||||
@@ -701,7 +716,9 @@ static bool egl_onFrameFormat(LG_Renderer * renderer, const LG_RendererFormat fo
|
|||||||
|
|
||||||
if (likely(this->scalePointer))
|
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);
|
egl_cursorSetScale(this->cursor, scale);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user