From nobody Mon Feb 9 11:37:30 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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1730910172; cv=none; d=zohomail.com; s=zohoarc; b=J65fcf9jWRCnL5rFzf0Bcm9uzZOUkhRbkAXofTqtAejga/gbnm92Adlofoxendhuitfp4cUJ0JSslX28u+sSsoqcvtGQcrxPK7DDz6qZFKEfCrWzxCriVxZfyPvREt11imA/rXyxGM1/WKHUy+UVrOKV6KhBq+ErPbt9YZWHGxI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730910172; 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=NQvBjLobvmM1bkG98S18JcM/uZx1quEAFCJC3F0rSqI=; b=ENeAtT6byv/gvWV2QlgG3GpWwkVKYKELx6xU706cgH2UHLElHbdFFpXag7OVBwvxoE1GpHKV84ECe2fdAQUl96/zVwcgKCgvHCs3BPMwGqhO1FEXNZynYBfNaAVKMpXKBGFIb3AlIIDnT6NDnXmA5DIeV1M6juxrW37L6ejpInY= 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 1730910172231388.198955737824; Wed, 6 Nov 2024 08:22:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t8inH-0008Im-7g; Wed, 06 Nov 2024 11:22:07 -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 1t8inF-0008IU-Sv for qemu-devel@nongnu.org; Wed, 06 Nov 2024 11:22:05 -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 1t8inB-0000CH-NP for qemu-devel@nongnu.org; Wed, 06 Nov 2024 11:22:04 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-644-n2fAmXABO0OzvmKAzimSwg-1; Wed, 06 Nov 2024 11:21:55 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d43e7acd9so3382964f8f.2 for ; Wed, 06 Nov 2024 08:21:55 -0800 (PST) Received: from [192.168.10.3] ([151.49.226.83]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381c113e6b5sm19845061f8f.88.2024.11.06.08.21.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Nov 2024 08:21:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730910118; 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=NQvBjLobvmM1bkG98S18JcM/uZx1quEAFCJC3F0rSqI=; b=aXLaTjHgr8IZuIVJ3TzX+Tf98dicMLlvo5TdQD8wIrAYULr+uPMeoTAr0IbXpg+SAQTwbZ YgBnfJh+IpJjiWLU9fEWUmt5HDsPiXfK0lTBCFhjGL3Zhbfj6vC9e32dCIvUk374KNCXtv j2tTG80N5bMlxdkIJD3kevEg/4cPgs8= X-MC-Unique: n2fAmXABO0OzvmKAzimSwg-1 X-Mimecast-MFC-AGG-ID: n2fAmXABO0OzvmKAzimSwg X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730910113; x=1731514913; 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=NQvBjLobvmM1bkG98S18JcM/uZx1quEAFCJC3F0rSqI=; b=KQMvdO+m5KroZG8y4gzws6rMFZsWyX7UE6q3ZrzdAkx3HkMG6CjnoqFThpeNgp6POf no4/J8/YUEG+zPA5/Mimbhiya6tWqJKSML4eMa/xzlSnYek9dpW4A0JGQuHJDyYnOVfW BeOoNlrlWMYYytfwrutQcx0tenty/8+KF96s/0BcOKx9ubkCAIIR/iPmBUBfJEOFnOYk c8OSU14ndRCPlB4pUUU0r5/MgaXrEmIbZEiQwz15FJu2qVUKE/lk9XwrjgKDFKLtYaEL 1GoKqxd74BNKFPVqoaEvTEGrbkEpzJsbXuNeAY8erhnITgbWgU52rUuppUrfZf/W38pW GJIA== X-Gm-Message-State: AOJu0YwjVGeCxqVZ/XZSbEXBMNfokndYo9580Ja97Pn87torqqHsjcFP XHsQ/rUX7xaUeUsdJ/BKxCjNbjmHP2fi64qoyLrKi54gvmMRO49WFOMF2LGzkxkelgCxsqgYHJx 8dFSRRmSRoW9pLXLy4ioEca9RuMCYlkP5hKx2d0sIPbh0GhZqmAfaKf8KGmdB5JyIaVVhvLID4H tQidGFwHniCxih5A071/AfK9YFMRtqhyHJdXVQe6A= X-Received: by 2002:a5d:5cce:0:b0:37d:446a:9e60 with SMTP id ffacd0b85a97d-38060ffe8cbmr28392053f8f.0.1730910113602; Wed, 06 Nov 2024 08:21:53 -0800 (PST) X-Google-Smtp-Source: AGHT+IFGP5tVfjHKTJNUYjj7QP0lNuSpwb5/UI4PxWH/FRU9TCC3c4zIuPkYPf+H0XKzlnmGXaLsdA== X-Received: by 2002:a5d:5cce:0:b0:37d:446a:9e60 with SMTP id ffacd0b85a97d-38060ffe8cbmr28391999f8f.0.1730910112162; Wed, 06 Nov 2024 08:21:52 -0800 (PST) From: Paolo Bonzini To: qemu-devel@nongnu.org Cc: philmd@linaro.org Subject: [PATCH RFT] cocoa: Remove deprecated CVDisplayLinkCreateWithCGDisplay() calls Date: Wed, 6 Nov 2024 17:21:50 +0100 Message-ID: <20241106162150.522782-1-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: 1730910173129116600 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 Signed-off-by: Paolo Bonzini --- 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..e3330d41500 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(kIOMasterPortDefault, + 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