From nobody Sat Nov 23 22:03:25 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730915497; cv=none; d=zohomail.com; s=zohoarc; b=AIZHtakAJ2lH+Cqgl14+5KJ3Eu6eUartoUmVakxhVpjiy2f3kcBOTM8+QDKb2R0lQfmKLiaX1NAYnyOTWde73sd9xdueWWLCb+mClfU3ktfYt8ewXkl6JP+OdIXiDszqhuFe++m5O38zVyq0h/rAZerfioc1F9IdKDlZtJEHq9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730915497; h=Content-Type: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=iDwN3Buh859r4KSuAlN/JsBdxt+/lJkLpjgP3QfrTQ0=; b=D/gnFgW66koBg7QUsSmWvFJN703HmOkDB9n2CZusXZDbQSfUCLjLd7WGxQwH0knnTeas6nC3KKA9Y/C8xn4aPTjvYfO5L1vhRUi+6odQXx2h1IH6SvsE+t4qQWfwC8LlsqwwwlxynXuSDR1E6hE+XQVkQhUXtdRjNM/r5wPvCLo= 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 1730915497046999.5492580829767; Wed, 6 Nov 2024 09:51:37 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8kBb-0002ts-MM; Wed, 06 Nov 2024 12:51:19 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8kBa-0002tR-AX for qemu-devel@nongnu.org; Wed, 06 Nov 2024 12:51:18 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t8kBY-0000eN-1L for qemu-devel@nongnu.org; Wed, 06 Nov 2024 12:51:18 -0500 Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-642-Y8uPr9x1Pf208o4y4I1qqA-1; Wed, 06 Nov 2024 12:51:14 -0500 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-37d52ca258eso2244f8f.3 for ; Wed, 06 Nov 2024 09:51:13 -0800 (PST) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113dd7fsm20020729f8f.70.2024.11.06.09.51.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 09:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730915475; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=iDwN3Buh859r4KSuAlN/JsBdxt+/lJkLpjgP3QfrTQ0=; b=CIKyQn7Eh6/ra2QCYjp25m7uQL117OlyTLNu0gL9nyGOxyZXG7N8boEkmOwGKIfVhnY90Q A7ImiOqBXVMb+AexLVZuAKD67tbFDd2fVQvxNvFfLZJw6Yy+zVccZVPC12TOskiYLKbpfG g2zt5s122lmceaIUOnSJGktoSH28fFg= X-MC-Unique: Y8uPr9x1Pf208o4y4I1qqA-1 X-Mimecast-MFC-AGG-ID: Y8uPr9x1Pf208o4y4I1qqA X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730915472; x=1731520272; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=iDwN3Buh859r4KSuAlN/JsBdxt+/lJkLpjgP3QfrTQ0=; b=f8/4fb77f7lX+kii0Vkm5X8Ol5S6NipketYoMdcBadEnFHa/25hVHBYRm7bl3ez+sL TfUVTDzneR6Y4QYMiA6lPn2FuDIY9fnSEdY7ZxOSrsSt4Fbvr6jiKbgwEuIXkZgiUnEQ kRP5pn4H4ol8goBpFYQzNO9grUQISVtHFFe5mZGAgu5Pcm4YlW0qIw/+H50ihR4iJpo4 0CilQ9m9RlHnQhi/CE/AuzDiRgcIm56k1ph7zPxm1Lu7WuXZdprwwT2Uqdf+LU285v/I Y/DK2gBcH4LiiuTDkW+2I8htXogVvX91rXTrDV9z8SS+xi+zCqr0U5HQ+JrS2x8cCrvf Rcqw== X-Gm-Message-State: AOJu0YzYv44Z6qFsWXlC8vGwGXw/yflhcy5ycFfRcW2gAyo96geg2rmw 3jbywAuIuY9jkJPyy+4X1xDdE7JzVSogEw64LxMuqcSjG9jJ1w7k2ENDnzrwoAzrA0Ad8jD6wcV tXan4UTpndqbBSVj0vuQWEKJzUHt6vzTNhggf6mnBMn0fBHJahpgzWzYpyOikfRFpP0r6Zzj0/f K0Xf477wfTESqYNQxazkE5svo4NEMT2xlEeTdJxPI= X-Received: by 2002:a5d:6388:0:b0:374:c059:f2c5 with SMTP id ffacd0b85a97d-381b7076de7mr18614792f8f.22.1730915472071; Wed, 06 Nov 2024 09:51:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IHd8L7PNVS50Z+iuUkCoFfUheUdVAk3rilS6D0TUspwjkpYYLr0pAvr4fLNHJYisJZymhWYhw== X-Received: by 2002:a5d:6388:0:b0:374:c059:f2c5 with SMTP id ffacd0b85a97d-381b7076de7mr18614772f8f.22.1730915471476; Wed, 06 Nov 2024 09:51:11 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Pierrick Bouvier Subject: [PATCH v2 RFT] cocoa: Remove deprecated CVDisplayLinkCreateWithCGDisplay() calls Date: Wed, 6 Nov 2024 18:50:52 +0100 Message-ID: <20241106175051.561352-2-pbonzini@redhat.com> X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" 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=170.10.133.124; envelope-from=pbonzini@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1730915498167116600 When building on macOS 15 we get: ../../ui/cocoa.m:662:14: error: 'CVDisplayLinkCreateWithCGDisplay' is depre= cated: first deprecated in macOS 15.0 - use NSView.displayLink(target:selector:), NSWindow.displayLink(target= :selector:), or NSScreen.displayLink(target:selector:) [-Werror,-Wdeprecated-declarations] 662 | if (!CVDisplayLinkCreateWithCGDisplay(display, &displayLink= )) { | ^ Instead get the refresh rate from either CGDisplayModeGetRefreshRate or IOK= it, following the model of https://github.com/gwm17/glfw/commit/4ec7daf3e92. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/2575 Cc: Philippe Mathieu-Daud=C3=A9 Cc: Pierrick Bouvier Signed-off-by: Paolo Bonzini --- v1->v2: use kIOMainPortDefault meson.build | 2 +- ui/cocoa.m | 90 ++++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 79 insertions(+), 13 deletions(-) diff --git a/meson.build b/meson.build index c386593c527..b12ccc12223 100644 --- a/meson.build +++ b/meson.build @@ -1135,7 +1135,7 @@ if get_option('attr').allowed() endif =20 cocoa =3D dependency('appleframeworks', - modules: ['Cocoa', 'CoreVideo', 'QuartzCore'], + modules: ['Cocoa', 'IOKit', 'QuartzCore'], required: get_option('cocoa')) =20 vmnet =3D dependency('appleframeworks', modules: 'vmnet', required: get_op= tion('vmnet')) diff --git a/ui/cocoa.m b/ui/cocoa.m index 4c2dd335323..c3fa55477fd 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -25,6 +25,7 @@ #include "qemu/osdep.h" =20 #import +#import #import #include =20 @@ -292,6 +293,75 @@ static void handleAnyDeviceErrors(Error * err) } } =20 +static bool get_fallback_refresh_rate(CGDirectDisplayID displayID, double = *p_rate) +{ + bool found =3D false; + io_iterator_t it; + io_service_t service; + CFNumberRef indexRef, clockRef, countRef; + uint32_t clock, count; + + if (IOServiceGetMatchingServices(kIOMainPortDefault, + IOServiceMatching("IOFramebuffer"), + &it) !=3D 0) { + return false; + } + while ((service =3D IOIteratorNext(it)) !=3D 0) { + uint32_t index; + bool found_display_id; + indexRef =3D IORegistryEntryCreateCFProperty(service, + CFSTR("IOFramebufferOpe= nGLIndex"), + kCFAllocatorDefault, + kNilOptions); + if (!indexRef) { + continue; + } + found_display_id =3D + CFNumberGetValue(indexRef, kCFNumberIntType, &index) && + CGOpenGLDisplayMaskToDisplayID(1 << index) =3D=3D displayID; + CFRelease(indexRef); + if (found_display_id) { + break; + } + } + if (!service) { + goto out; + } + + clockRef =3D IORegistryEntryCreateCFProperty(service, + CFSTR("IOFBCurrentPixelCloc= k"), + kCFAllocatorDefault, + kNilOptions); + if (!clockRef) { + goto out; + } + if (!CFNumberGetValue(clockRef, kCFNumberIntType, &clock) || !clock) { + goto out_clock_ref; + } + + countRef =3D IORegistryEntryCreateCFProperty(service, + CFSTR("IOFBCurrentPixelCoun= t"), + kCFAllocatorDefault, + kNilOptions); + if (!countRef) { + goto out_clock_ref; + } + if (!CFNumberGetValue(countRef, kCFNumberIntType, &count) || !count) { + goto out_count_ref; + } + + *p_rate =3D clock / (double) count; + found =3D true; + +out_count_ref: + CFRelease(countRef); +out_clock_ref: + CFRelease(clockRef); +out: + IOObjectRelease(it); + return found; +} + /* ------------------------------------------------------ QemuCocoaView @@ -655,20 +725,16 @@ - (void) updateUIInfoLocked NSSize screenSize =3D [[[self window] screen] frame].size; CGSize screenPhysicalSize =3D CGDisplayScreenSize(display); bool isFullscreen =3D ([[self window] styleMask] & NSWindowStyleMa= skFullScreen) !=3D 0; - CVDisplayLinkRef displayLink; + CGDisplayModeRef mode =3D CGDisplayCopyDisplayMode(display); + double rate =3D CGDisplayModeGetRefreshRate(mode); + + if (rate !=3D 0.0 || get_fallback_refresh_rate(display, &rate)) { + update_displaychangelistener(&dcl, 1000 / rate); + info.refresh_rate =3D (int64_t)1000 * rate; + } + CGDisplayModeRelease(mode); =20 frameSize =3D isFullscreen ? [self screenSafeAreaSize] : [self fra= me].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.47.0