From nobody Mon Sep 28 02:05:32 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1785457838; cv=none; d=zohomail.com; s=zohoarc; b=gCVhoNJhIU0MDUiLXXBlQqt/w8vgCwenHedqzJUChPpDA3nuY4gmb55n1pFKM4g/y85t035C74A+BbGTwr8Ha/4xVJagKZgKcbZA0LM3vyrv7cxNeuw9S8m4zYsREXg/EBHqEU3jhbFyhK60vXgkB4lLLouNtTbwsA1IuaOHNeU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1785457838; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=WeoZMFRUcScYUud2h5F047Ygt+CNqlQ41cRVby3nNZ4=; b=e5mRy4HHdU5XsFoVOp+pITXwUgPVwm1nkvfr+1DL0yUA/GIl41NC91/k323QnGiVrdP2N4Mt3cf4luVTq67E/fKFYKQyYTh2rAStXchrRN+bwlOg77/iQSjGH+G/d49XUzw2wy4q3v4S7kACqgMnDVTsh89WIH3Rq1O1iSldrK4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists1p.gnu.org (lists1p.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1785457838927703.5380798146948; Thu, 30 Jul 2026 17:30:38 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists1p.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1wpb8Z-0002oK-Lx; Thu, 30 Jul 2026 20:30:07 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists1p.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1wpZp2-0008F7-Os for qemu-devel@nongnu.org; Thu, 30 Jul 2026 19:05:52 -0400 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1wpZp1-0000hc-D8 for qemu-devel@nongnu.org; Thu, 30 Jul 2026 19:05:52 -0400 Received: by mail-qv1-xf2e.google.com with SMTP id 6a1803df08f44-907ae87ebfcso585646d6.0 for ; Thu, 30 Jul 2026 16:05:50 -0700 (PDT) Received: from DESKTOP-MVROD8J ([147.124.77.95]) by smtp.gmail.com with ESMTPSA id 6a1803df08f44-908324f8805sm28111446d6.35.2026.07.30.16.05.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Jul 2026 16:05:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1785452750; x=1786057550; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to:content-type; bh=WeoZMFRUcScYUud2h5F047Ygt+CNqlQ41cRVby3nNZ4=; b=O+7x55poI3NUpZGUXU/XT70rYwH0C+uCQFCAybrhYKczVGbl8m/xHauj2moH5GRY/N nmpK3IjUTCGorc7OzZQs41/mHvqCrYWvFPHSa2/xvXTRo78XXpEIWNxpGrzMIh4QXoTe 2ZcXIjY0EE2eTQSIS/YBi1XR/u0938XRzvhAw/fjFvCboBnsIpQ/GOLGzsnmiszobPrP vhajgKMNxqKNsCjz+oisHdD3doaeF5ozB2JibjaDGtyN8wfPvJHc0Y7GKh4Tu+ypQto4 NcCZTK0T7B+QlXOLyT2znqUxk1XZJqE0q5k8XMeKwO8UKYnkW+UYtvRJv9BpQY4kmBGg co6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1785452750; x=1786057550; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=WeoZMFRUcScYUud2h5F047Ygt+CNqlQ41cRVby3nNZ4=; b=cOLJQSL3VeUIPpEkGjToUhmjtoYHze9jyA/viMNSuBORuWtW3ZE40wCoR8w1r8dOb3 3WMBDpqDIqCWVK7qJjuLzlVtOYHQsB4ISDHfYqWpMZgbG7LH+xIXubDbD/mJKNW3/xxz 8PVzzBR4mH28alww9A0jSEDGDlMfkF7DyMMUOZrEXW4Wk4ufLsEXcQyVCjhzrywr75TA 7zDM+7nGN1VRQ82kHp+GH4hlbX3g6XQn3yZ0gMaFZPyy9yTJn1pH4YuXoaLSvVTsbyoP l11DVT1nomSG8+Ub8vCBChguEdYxKaJiGO9lYSLXgW9j+hvq2cnMUNnTSNJgdXewhTVi z8yw== X-Gm-Message-State: AOJu0YziuLAcBZy7DwGFHZlEGAsvZ/twg0ECxaEkr7wVM29ssgVDTQ2n nX1e08J1ru6HKPjuI8/ci0z3V7zh2EqwckB+XkCnNGx5Dts6nRhKd+54Mzq6yPVTkwc= X-Gm-Gg: AR+sD120p8S1MM5lt+Q6LdnE9ff8hJvDzvcWy+HgIWMDCnI2chX5N/hLQWXoYcY8R5X gqlXICa4GJ18hWLPKyoBlczRTrKoD13W+Tt258PZbkkNIR5jqmH5CHmzRCI5Be+uTyvsKtLtisV k/c+ddwoBkv7gFABjOHimwcQu4QoT3X8Xw7s+xVQJiR6LrALV/TsuHx+oedoOEklaexHBwt5D1I bKzIsIuh+eGynQ+swXo7MR6Lc1X22td4Loj8vHCZA6eaOP5vHTJck6nOl1gKOSbE4/RAhDRPjVp /M3iTpNsa4UMMNKkAn3JVEO55forIo9bDus8qTene97rDpBYCrP6EpAewyY8m/uRxI1t4htNlg1 AbAX3/jB6OxvLNDrn+TdRndVsvEzbPLUohQixoJ6/sFZmAVw6q6p3b8i0QmYHLzbWScP7My8P5D ywFjUWnVfuhxdWf3qHlSqjfwkjTHbVLfvdGTcdBjrOEc42esGyIHtMnkggj8OQBEYlOV1I7h7Gf ACOdldtK9janItZLsqNMC7S4WjRqmZKCCFNog== X-Received: by 2002:a05:6214:e84:b0:8e9:ee1f:6631 with SMTP id 6a1803df08f44-9083be78c93mr33422606d6.3.1785452749712; Thu, 30 Jul 2026 16:05:49 -0700 (PDT) From: Oliver Clarke To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, marcandre.lureau@redhat.com, Oliver Clarke Subject: [PATCH] sdl2: fix HighDPI display scaling Date: Thu, 30 Jul 2026 19:04:48 -0400 Message-ID: <20260730230449.963-1-oliverhenryc@gmail.com> X-Mailer: git-send-email 2.51.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists1p.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2e; envelope-from=oliverhenryc@gmail.com; helo=mail-qv1-xf2e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Thu, 30 Jul 2026 20:30:04 -0400 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1785457839919158500 Content-Type: text/plain; charset="utf-8" This makes sdl2 windows work well with dpi scaling. It fixes the issue of t= he display surface being stretched to fit the dpi corrected window (which c= reated a blurry result). Note, this does not do any scaling, it just tells the os to not scale the w= indow. Before, when the console requested size 640x480, the logical size of= the window was 640x480, and the physical size was scaled by the dpi scalin= g. Now, both the logical and physical size will be 640x480. This is unlike = most dpi aware programs which usually do have the scaled physical size, the= n also make the render target that scaled size as well. This doesn't make a= s much sense for QEMU, since the guest is responsible for modesetting, and = they should get the exact physical pixels they request (if i modeset to 384= 0x2160, I wouldn't want this to be scaled in any way). Signed-off-by: Oliver Clarke --- ui/sdl2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ui/sdl2.c b/ui/sdl2.c index 1c97d23a47..1910477db4 100644 --- a/ui/sdl2.c +++ b/ui/sdl2.c @@ -102,7 +102,7 @@ void sdl2_window_create(struct sdl2_console *scon) flags |=3D SDL_WINDOW_OPENGL; } #endif - + flags |=3D SDL_WINDOW_ALLOW_HIGHDPI; scon->real_window =3D SDL_CreateWindow("", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, surface_width(scon->surface), @@ -907,6 +907,7 @@ static void sdl2_display_init(DisplayState *ds, Display= Options *o) char *dir; =20 assert(o->type =3D=3D DISPLAY_TYPE_SDL); + SDL_SetHint(SDL_HINT_WINDOWS_DPI_AWARENESS, "permonitorv2"); =20 if (SDL_GetHintBoolean("QEMU_ENABLE_SDL_LOGGING", SDL_FALSE)) { SDL_LogSetAllPriority(SDL_LOG_PRIORITY_VERBOSE); --=20 2.51.0.windows.1