From nobody Tue May 21 20:58:19 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=1655757392; cv=none; d=zohomail.com; s=zohoarc; b=kfq2Td7Pccx3VvLVI7mveVm5aRLAwfE33uHTRCU+TuUgF7jzs/Yu//ILs82OdbSBVPtum4TdoF8ob85U5ZFu1UQT56PolfxhsbyJ+5jdxb97LSLDQTm2nTa9KP0wghq8LjXOEqdhbEBjm3Ko1psHFSwL0sXLcuFQ1nV4CzG/RA0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1655757392; 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=/31GHgPwc38/P7VhJ785CAYgmQ8Ze6Y5TLzEVb/KrKA=; b=bcwJ3ux5hY/CMlXVSaMkYmLSUvKPS+echo2eW9n3Lpdpf6fEDSOA50cMsnIiGn/B4sif2DWFX/Zo8VEpBQOxCyHmCZrTIYYhU0ZJnDoU5ehRsDfr6dg8GxXpkb99xC4rzVh0Fh3u1nN8RfRV3l3zh0MBhtFfD6G0bAIcI3JboUs= 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 165575739294492.82981811432524; Mon, 20 Jun 2022 13:36:32 -0700 (PDT) Received: from localhost ([::1]:37700 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1o3O8N-0008VR-Cu for importer@patchew.org; Mon, 20 Jun 2022 16:36:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:45430) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1o3O1c-0002t9-Tk for qemu-devel@nongnu.org; Mon, 20 Jun 2022 16:29:33 -0400 Received: from mail-pj1-x1033.google.com ([2607:f8b0:4864:20::1033]:56041) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1o3O1b-0000Lu-BT for qemu-devel@nongnu.org; Mon, 20 Jun 2022 16:29:32 -0400 Received: by mail-pj1-x1033.google.com with SMTP id w24so2820776pjg.5 for ; Mon, 20 Jun 2022 13:29:30 -0700 (PDT) Received: from localhost.localdomain ([2400:4050:c360:8200:650a:2825:1:f038]) by smtp.gmail.com with ESMTPSA id q3-20020a170902f78300b0016788487357sm9119947pln.132.2022.06.20.13.29.27 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 20 Jun 2022 13:29:29 -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=/31GHgPwc38/P7VhJ785CAYgmQ8Ze6Y5TLzEVb/KrKA=; b=SMPJ7rIe9XtcQ7nVBcY2Qk9tQAIpmCOc6I+IT8AdpsGkpuB83qhcBLp8WMhYaPo5Zb VjkQW6Hy9HZpzH50gxiHaiGZriUhteQFZ/Bbf45I9VAH++Zow7SLMlMBt4wEQ86dab/v 56eYC1yewJT4rjFLP6oP7iMMK+WMNL5RNPJQYHauf9cyBa6/yigS7AglOAiQ2nF8gmv2 u9MTdTC3KE/QVoGAWCfk8y4Yti9WcBOcDO4l6qjRVY52whBn0agPWrxO/pOzQMpQbxYE v2oBtuymXyJ5va1brAtKF5t5s/kDHAmXkQizFJij25oQdDF5Q4QyN9YisFFfDbmtJyDu etsw== 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=/31GHgPwc38/P7VhJ785CAYgmQ8Ze6Y5TLzEVb/KrKA=; b=kQdsMF3TYaBUUZmfH5/5A1GRJ1H5UGCP/CtNwcYqh7raLxqRSVg/HsVD76+vPQLpsr 237AKrnnXwWhl0a/i6it95whoh9FEVP7WnhpJp6B3Ss2keatHiu1EqnGNJQvDY527AYk 48UvLFuVB0u+be9dKXWCGS5ikooNjakTIgwpNCD/lsM24IpipVhG/eJQkakbvcpHvl98 hTGPqbXEW20vrTZTjsJcVo2BXExXhBb4CQg6BH7LrZsjeb4q97FABWwXpqAyz4XIDG81 kLV35XEFpM2l5/A0vCwXG0xihmu5fX7W8HiMH3Y/jUB2Kwe1bbptNAYUQoHcmUC3+N2w JNog== X-Gm-Message-State: AJIora/G8gJN86Exg27t86CzQ6y/q0Iwel4+TW9ZciGook2CW2pPQ7UV KeT4x6TXrgR3j42vDty3PqI= X-Google-Smtp-Source: AGRyM1t6X16GTKt6q5yt+0PcpoXLGlDQAKgmaI1MDrlrYAUDn8RPh+U6SdfCYZMYkdU0Holv8u0fMA== X-Received: by 2002:a17:90b:4b82:b0:1e6:7853:c004 with SMTP id lr2-20020a17090b4b8200b001e67853c004mr39766769pjb.136.1655756969876; Mon, 20 Jun 2022 13:29:29 -0700 (PDT) From: Akihiko Odaki To: Cc: Peter Maydell , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Gerd Hoffmann , qemu-devel@nongnu.org, Akihiko Odaki Subject: [PATCH v3] ui/cocoa: Take refresh rate into account Date: Tue, 21 Jun 2022 05:29:21 +0900 Message-Id: <20220620202921.21062-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::1033; envelope-from=akihiko.odaki@gmail.com; helo=mail-pj1-x1033.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: 1655757393737100001 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. Signed-off-by: Akihiko Odaki --- 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)