From 1edceffa31b86e5541f1af96c8895c517473d84b Mon Sep 17 00:00:00 2001 From: volth Date: Sat, 14 Sep 2019 17:57:45 +0000 Subject: [PATCH] avoid blurry filter when scaling factor is 2x, 3x, etc --- client/X11/xf_client.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/client/X11/xf_client.c b/client/X11/xf_client.c index a3b6ad92b..f377fa8ae 100644 --- a/client/X11/xf_client.c +++ b/client/X11/xf_client.c @@ -123,6 +123,7 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) double yScalingFactor; int x2; int y2; + const char* filter; rdpSettings* settings = xfc->context.settings; if (xfc->scaledWidth <= 0 || xfc->scaledHeight <= 0) @@ -167,7 +168,14 @@ static void xf_draw_screen_scaled(xfContext* xfc, int x, int y, int w, int h) CPSubwindowMode, &pa); windowPicture = XRenderCreatePicture(xfc->display, xfc->window->handle, picFormat, CPSubwindowMode, &pa); - XRenderSetPictureFilter(xfc->display, primaryPicture, FilterBilinear, 0, 0); + // avoid blurry filter when scaling factor is 2x, 3x, etc + // useful when the client has high-dpi monitor + if (xScalingFactor == yScalingFactor && abs(1/xScalingFactor - round(1/xScalingFactor)) < 0.001) { + filter = FilterNearest; + } else { + filter = FilterBilinear; + } + XRenderSetPictureFilter(xfc->display, primaryPicture, filter, 0, 0); transform.matrix[0][0] = XDoubleToFixed(xScalingFactor); transform.matrix[0][1] = XDoubleToFixed(0.0); transform.matrix[0][2] = XDoubleToFixed(0.0);