From nobody Sun Apr 28 00:14:11 2024 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1549005240817599.7181349491492; Thu, 31 Jan 2019 23:14:00 -0800 (PST) Received: from localhost ([127.0.0.1]:39994 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpT1H-0000Fx-Kn for importer@patchew.org; Fri, 01 Feb 2019 02:13:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:59143) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gpT0T-0008N6-Gm for qemu-devel@nongnu.org; Fri, 01 Feb 2019 02:12:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gpT0S-0007BV-No for qemu-devel@nongnu.org; Fri, 01 Feb 2019 02:12:57 -0500 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:41798) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gpT0S-0007Ag-Em for qemu-devel@nongnu.org; Fri, 01 Feb 2019 02:12:56 -0500 Received: by mail-pg1-x544.google.com with SMTP id m1so2512792pgq.8 for ; Thu, 31 Jan 2019 23:12:55 -0800 (PST) Received: from Brendans-MacBook-Pro.local.net (cpe-107-184-2-226.socal.res.rr.com. [107.184.2.226]) by smtp.gmail.com with ESMTPSA id o85sm5120184pfi.105.2019.01.31.23.12.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 31 Jan 2019 23:12:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bslabs-net.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=zEMpOnYLO1+l59yV9F6Z2yoyxa0ptJ1invJxSlKEZEk=; b=nyUxGE78RYVov8ZtJDJlrFyvugF12ZJoLHKWGUDsael+dRP50kMCmQYjX5cC5uo1th u80UiMbbdP7d6uwmWJ83zMJ8n+G53I5b/en/uzIiv85X/HTIjqoBN+m120b3vld/1kyU itE8HcseyNq+c9+YY2N6u5gE0BwG5BAnf591sE/h8/KKHw2S0Q3CAjLBckILsJS1499k MuW/WUVYznEPzE8/8TCMUCY7bVHyC59ai+LVZTmom0Z0K75Nb74UrGi3y2bTmPC3A7ZV hmVlIYTA1o9PN55/y+USWN4yPKdShnkUVe0chxLrgZt3loivWJ42t3JZ0RZFP01ADzRI vxOg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=zEMpOnYLO1+l59yV9F6Z2yoyxa0ptJ1invJxSlKEZEk=; b=WfjlAymJeg7pjxyVCni5S/9hwwW7XGNdUJb8Ba+VneTmdn6utLSKk5ToIZzTyYYNRT aMdHGTpxq9vQJdp6nclOIqlzmUmSYFsWv/g9jZz/tOt0kwvCxEyPOLGvuravVKD8HOfS Z8rtahyUKJ7bqQEzg3YSsKRRp0t5h7aHMOcejOoQRkmpiuoRf+XC8R1Vg9oMX5fFiXOY Y6xRjNWh+gJy8rgNh/jhwVl+ey1t0TQhkX7Yu4VnGY4AlRho2eItIOatXZBh+M9Adayy /oCHxkuloGjnpgIYH4NIKwCPsMZ1APP4Z8o5lTPq3OCOKgf54cGMJn2xnv6aU9LZ6BZP b7Sg== X-Gm-Message-State: AJcUukeUQtKDCEC0832IkU3imY4e3a00ToyLX8tGJ15Z1/2vp9FSSbGs A9GL3hkSQe/6dmS9gluqFl2y5i1K0g== X-Google-Smtp-Source: ALg8bN7Ncs2f4KBp0yOlZU0O0DprYtm/9bP+GWM/TwBoFsQo6kbgEyTNCcDJApvtJt/Q3T8OqdOFFw== X-Received: by 2002:a62:e704:: with SMTP id s4mr38573243pfh.124.1549005174008; Thu, 31 Jan 2019 23:12:54 -0800 (PST) From: Brendan Shanks To: qemu-devel@nongnu.org Date: Thu, 31 Jan 2019 23:12:25 -0800 Message-Id: <20190201071225.20576-1-brendan@bslabs.net> X-Mailer: git-send-email 2.17.2 (Apple Git-113) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::544 Subject: [Qemu-devel] [PATCH] ui/cocoa.m: Fix macOS 10.14 deprecation warnings X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Gerd Hoffmann , Brendan Shanks Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" macOS 10.14 deprecated NSOnState/NSOffState in favour of NSControlStateValueOn/NSControlStateValueOff. Use the new constants, and #define them to the old ones when compiling against a pre-10.13 SDK. Also [NSGraphicsContext graphicsPort] is now deprecated, use [NSGraphicsContext CGContext] when available. Signed-off-by: Brendan Shanks --- ui/cocoa.m | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index ddc058e76e..e2567d6946 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -54,6 +54,9 @@ #ifndef MAC_OS_X_VERSION_10_12 #define MAC_OS_X_VERSION_10_12 101200 #endif +#ifndef MAC_OS_X_VERSION_10_13 +#define MAC_OS_X_VERSION_10_13 101300 +#endif =20 /* macOS 10.12 deprecated many constants, #define the new names for older = SDKs */ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_12 @@ -90,6 +93,14 @@ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_9 #define NSModalResponseOK NSFileHandlingPanelOKButton #endif +/* 10.14 deprecates NSOnState and NSOffState in favor of + * NSControlStateValueOn/Off, which were introduced in 10.13. + * Define for older versions + */ +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_13 +#define NSControlStateValueOn NSOnState +#define NSControlStateValueOff NSOffState +#endif =20 //#define DEBUG =20 @@ -377,7 +388,12 @@ - (void) drawRect:(NSRect) rect COCOA_DEBUG("QemuCocoaView: drawRect\n"); =20 // get CoreGraphic context +#if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_10 CGContextRef viewContextRef =3D [[NSGraphicsContext currentContext] gr= aphicsPort]; +#else + CGContextRef viewContextRef =3D [[NSGraphicsContext currentContext] CG= Context]; +#endif + CGContextSetInterpolationQuality (viewContextRef, kCGInterpolationNone= ); CGContextSetShouldAntialias (viewContextRef, NO); =20 @@ -1147,9 +1163,9 @@ - (void)zoomToFit:(id) sender { stretch_video =3D !stretch_video; if (stretch_video =3D=3D true) { - [sender setState: NSOnState]; + [sender setState: NSControlStateValueOn]; } else { - [sender setState: NSOffState]; + [sender setState: NSControlStateValueOff]; } } =20 @@ -1390,15 +1406,15 @@ - (void)adjustSpeed:(id)sender { /* Unselect the currently selected item */ for (NSMenuItem *item in [menu itemArray]) { - if (item.state =3D=3D NSOnState) { - [item setState: NSOffState]; + if (item.state =3D=3D NSControlStateValueOn) { + [item setState: NSControlStateValueOff]; break; } } } =20 // check the menu item - [sender setState: NSOnState]; + [sender setState: NSControlStateValueOn]; =20 // get the throttle percentage throttle_pct =3D [sender tag]; @@ -1502,7 +1518,7 @@ int main (int argc, const char * argv[]) { initWithTitle: [NSString stringWithFormat: @"%d%%", per= centage] action:@selector(adjustSpeed:) keyEquivalent:@""] autorelease]; =20 if (percentage =3D=3D 100) { - [menuItem setState: NSOnState]; + [menuItem setState: NSControlStateValueOn]; } =20 /* Calculate the throttle percentage */ --=20 2.17.2 (Apple Git-113)