diff --git a/client/renderers/EGL/egl.c b/client/renderers/EGL/egl.c index e27aca94..65ceae33 100644 --- a/client/renderers/EGL/egl.c +++ b/client/renderers/EGL/egl.c @@ -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); }