From nobody Tue May 21 13:10:33 2024 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=1656772033; cv=none; d=zohomail.com; s=zohoarc; b=htaVEvFkciTcK4SCL5FST5VXO5SlTP445BipH20pLD4+NPpQiOuoIRF5pFLZizVq7cxW1osUhZa5dAANQMOuqZ6wCJy4v729+BWJ0RiIS0mfjKSLxs5AQvMScE6VHxa5sedOBYyoT5WxDx2CSXgmwB8KiiaIeGHB3Hc7gmc0ZqM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1656772033; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject; bh=LTTJSLWbh0/gyqLlZr11hkpoMF0B1JSdtXPNYsJ5L9o=; b=doPFaJdlITfUK0jtfhum5d55kV2kV4T5P6krfYbqojuIQQghg4w/g/keXdlugjg7UXoCDphVh7gDVo9Wo7+cq+eCz7aZrmxPwia70pB1MFm+fvTsFraA5v5G4k0gHdBLgrept3+k5pkXpHb0bGlwTrS/Mr8IhnVVFwYavB769ls= 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 lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1656772033666426.27736894255406; Sat, 2 Jul 2022 07:27:13 -0700 (PDT) Received: from localhost ([::1]:47960 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o7e5Y-0002G9-H6 for importer@patchew.org; Sat, 02 Jul 2022 10:27:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:50288) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o7e3w-0001Q4-6R for qemu-devel@nongnu.org; Sat, 02 Jul 2022 10:25:35 -0400 Received: from mail-pf1-x432.google.com ([2607:f8b0:4864:20::432]:39539) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o7e3u-0000y1-HL for qemu-devel@nongnu.org; Sat, 02 Jul 2022 10:25:31 -0400 Received: by mail-pf1-x432.google.com with SMTP id r6so707445pfq.6 for ; Sat, 02 Jul 2022 07:25:29 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:c19f:1986:c0d4:95f6]) by smtp.gmail.com with ESMTPSA id b8-20020a170902650800b00168a651316csm17440666plk.270.2022.07.02.07.25.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sat, 02 Jul 2022 07:25:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LTTJSLWbh0/gyqLlZr11hkpoMF0B1JSdtXPNYsJ5L9o=; b=X1Q8w4kTO12dRApYGhC8K08crczlN6XoQV82UVcQtJ7B0FWVDgS5ynZoAa1q1Mjkgd U04r0PipOKwAh4fnDj/BkqhYHtGhnjEgNx7KuGxctL/qPiQRcpNR1qwPKRWvZBgAQh8s X+56U8AMCiSnMW+L9p9/I9+S6f6+dvAOoms+2IBuOE9AaBIEJZ4K79Mzl8OroEMixGRm Vx4BJ92qb2VKLifjS8U34z+Qq8mO8VNcr1za1Z86Mcpqs1W6R4tlui5UFbXq6DUSynkc n87TmUBKeMfJIm9hBdCzZrOWOGuMuz1Oee22fMH+g+0CCf33GNOwQoYa8EiF1Zp9uir4 j5QQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LTTJSLWbh0/gyqLlZr11hkpoMF0B1JSdtXPNYsJ5L9o=; b=V/+jnNBg8M6SATR3qSo4sXW8IkiBR91/WRLnvgoZuNcmvpfSxRzRF/TLz6CRT6bySk IA6HhzkMQBdfeTPD+TItbxniRbTv21zEBx1fdiy+151+Fugzec4ZX6BCYWyt0biOjn2m K/y8cafVrasKX91llGwPxNsRj+fJp42JC59LWKmT1sF7RlYxunLjMASfnAPiyvxpSrJy mx71LXU7fBceyJkxymyK8H2HZQFlRP58jXF6Lvg0XP+n3iieWYnxjKsKHLMs6Wqmd8yC ZUwJLMrTQOSwQaqeiDl1AZ45VMz9MvcSsG4cLH4csbqq9FxFdQNjaExpIKlE3t5peoUc ql+w== X-Gm-Message-State: AJIora/TL6PCoj9s5hnK8N9KLuNuTK2Qk5XdOjf4zrz5NEU8Nhgqx1ZA wTYHOZAzDvb1Bl8pmRTHdM3hxZXT6eE= X-Google-Smtp-Source: AGRyM1uJfET6+Yt/MtK4ACxadhYb3vAIfZ06zdv0h9bYS8M5I6yWfhkneUpInbmBySEwbNbE0QoeXA== X-Received: by 2002:aa7:9425:0:b0:525:279e:9251 with SMTP id y5-20020aa79425000000b00525279e9251mr27107878pfo.4.1656771927932; Sat, 02 Jul 2022 07:25:27 -0700 (PDT) From: Akihiko Odaki To: Cc: qemu-devel@nongnu.org, Peter Maydell , Gerd Hoffmann , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Akihiko Odaki Subject: [PATCH v4] ui/cocoa: Take refresh rate into account Date: Sat, 2 Jul 2022 23:25:19 +0900 Message-Id: <20220702142519.12188-1-akihiko.odaki@gmail.com> X-Mailer: git-send-email 2.32.1 (Apple Git-133) 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=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::432; envelope-from=akihiko.odaki@gmail.com; helo=mail-pf1-x432.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, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1656772034606100001 Content-Type: text/plain; charset="utf-8" Retreieve the refresh rate of the display and reflect it with dpy_set_ui_info() and update_displaychangelistener(), allowing the guest and DisplayChangeListener to consume the information. The information will be used as a hint how often the display should be updated. For example, when we run 30 Hz physical display updates it is pointless for the guest to update the screen at 60Hz frequency, the guest can spare some work instead. Signed-off-by: Akihiko Odaki Reviewed-by: Peter Maydell --- meson.build | 3 ++- ui/cocoa.m | 12 ++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/meson.build b/meson.build index 0c2e11ff071..0f83f3730af 100644 --- a/meson.build +++ b/meson.build @@ -575,7 +575,8 @@ if get_option('attr').allowed() endif endif =20 -cocoa =3D dependency('appleframeworks', modules: 'Cocoa', required: get_op= tion('cocoa')) +cocoa =3D dependency('appleframeworks', modules: ['Cocoa', 'CoreVideo'], + required: get_option('cocoa')) if cocoa.found() and get_option('sdl').enabled() error('Cocoa and SDL cannot be enabled at the same time') endif diff --git a/ui/cocoa.m b/ui/cocoa.m index 84c84e98fc5..0000a3949c6 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -561,8 +561,20 @@ - (void) updateUIInfoLocked CGDirectDisplayID display =3D [[description objectForKey:@"NSScree= nNumber"] unsignedIntValue]; NSSize screenSize =3D [[[self window] screen] frame].size; CGSize screenPhysicalSize =3D CGDisplayScreenSize(display); + CVDisplayLinkRef displayLink; =20 frameSize =3D isFullscreen ? screenSize : [self frame].size; + + if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink)) { + CVTime period =3D CVDisplayLinkGetNominalOutputVideoRefreshPer= iod(displayLink); + CVDisplayLinkRelease(displayLink); + if (!(period.flags & kCVTimeIsIndefinite)) { + update_displaychangelistener(&dcl, + 1000 * period.timeValue / per= iod.timeScale); + info.refresh_rate =3D (int64_t)1000 * period.timeScale / p= eriod.timeValue; + } + } + info.width_mm =3D frameSize.width / screenSize.width * screenPhysi= calSize.width; info.height_mm =3D frameSize.height / screenSize.height * screenPh= ysicalSize.height; } else { --=20 2.32.1 (Apple Git-133)