From nobody Sun Nov 9 19:09:40 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1551718315031680.1079874035636; Mon, 4 Mar 2019 08:51:55 -0800 (PST) Received: from localhost ([127.0.0.1]:57165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0qoe-0005SC-0h for importer@patchew.org; Mon, 04 Mar 2019 11:51:48 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52481) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1h0qn0-0004N1-4b for qemu-devel@nongnu.org; Mon, 04 Mar 2019 11:50:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1h0qmz-0005ia-6y for qemu-devel@nongnu.org; Mon, 04 Mar 2019 11:50:06 -0500 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]:32889) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1h0qmz-0005hw-0M for qemu-devel@nongnu.org; Mon, 04 Mar 2019 11:50:05 -0500 Received: by mail-wr1-x42a.google.com with SMTP id i12so6325201wrw.0 for ; Mon, 04 Mar 2019 08:50:04 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id x74sm7238018wmf.22.2019.03.04.08.50.02 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 04 Mar 2019 08:50:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=neXd0BAgAY98aNlWcvoddM/ZAlwCNLvn01azSi/sGsw=; b=gexdcUAPy5I26phi/WFc/bD8w4r1MfzdMXSMga3rJGU00JxfkCJGkkVO2fFHmiOXvR k7uL3wUvAx1CVB4WFPEueeYeUcOD8TrM/xX+qQSahdbo2BZdfvuG3cxvVTjkXnfhGuGl 0eEGei0ew2RjFoF5zSzb1JWWXut8qHlCknAt1ueRVWv02agvNFrKMzhluojefAB6K7Ti N5QghJkUNgeOgfBZvT0W26yxGVR7wqqtk1bxKD13OeyOc3mm0HpJ2qO/vF3LkLt0qTYL i4MQkrYBqIFLciFkLIUIHuf0R/KrXTu/SfqTf05DM/ItG6AezmXxpMbdtPy8HbPu4s+J UoLA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=neXd0BAgAY98aNlWcvoddM/ZAlwCNLvn01azSi/sGsw=; b=tgGZrzzqf+roHx+qE1lyWFT3+8B/GZ5UvzFFNjHlx0X3WARuhO0689vL1ZeKI/Tv7v Nk/7QldcZ+1v9Yy/vNK8yzaAVFchAQNfe8kgbHNYJw1N7kflzyj3l1c7qQ+ryhoCSkak 6rg0eaC3DnE4yJaxUfJkplk8S3XDxnSpP/WpR0Ke57ljxiMK7zNm591yH5p9eNM4G4HB iSSkL9gbxiJc8bMd/HXwiUBgr5TwmVISh2gLlYQwrTZiV3dHf2sEtglWWBy/PvXag643 BMsZ+dyhatYukTUSiXxwLwQD4bbVdT874Xq9M35MgcZjRyyseX7uyAc8UqLFgzGZc9W/ SOLA== X-Gm-Message-State: APjAAAVLMaVtAbcg6ss1p5n5J+rFLl0QEpix9FmWy+o/UFeWRFCjVlO7 1IUuN81qfZGe8EOp0R63H+rcdMLsvDo= X-Google-Smtp-Source: APXvYqyc4hbD4hiLK3p0xEyz235XhaWp0UoKrFHGepSJDIDcpp6ywJpC0cUjdkHyoOr67WJwgEJJ2Q== X-Received: by 2002:adf:e90b:: with SMTP id f11mr10082228wrm.36.1551718203668; Mon, 04 Mar 2019 08:50:03 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 4 Mar 2019 16:49:54 +0000 Message-Id: <20190304164958.9362-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190304164958.9362-1-peter.maydell@linaro.org> References: <20190304164958.9362-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::42a Subject: [Qemu-devel] [PULL 3/7] ui/cocoa: Factor out initial menu creation 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Factor out the long code sequence in main() which creates the initial set of menus. This will make later patches which move initialization code around a bit clearer. Signed-off-by: Peter Maydell Reviewed-by: BALATON Zoltan Reviewed-by: Roman Bolshakov Tested-by: Roman Bolshakov Message-id: 20190225102433.22401-4-peter.maydell@linaro.org Message-id: 20190214102816.3393-4-peter.maydell@linaro.org --- ui/cocoa.m | 78 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 41 insertions(+), 37 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index a913a51a2d8..4baec0b2ff7 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1465,43 +1465,8 @@ QemuCocoaView *cocoaView; =20 @end =20 - -int main (int argc, const char * argv[]) { - - gArgc =3D argc; - gArgv =3D (char **)argv; - int i; - - /* In case we don't need to display a window, let's not do that */ - for (i =3D 1; i < argc; i++) { - const char *opt =3D argv[i]; - - if (opt[0] =3D=3D '-') { - /* Treat --foo the same as -foo. */ - if (opt[1] =3D=3D '-') { - opt++; - } - if (!strcmp(opt, "-h") || !strcmp(opt, "-help") || - !strcmp(opt, "-vnc") || - !strcmp(opt, "-nographic") || - !strcmp(opt, "-version") || - !strcmp(opt, "-curses") || - !strcmp(opt, "-display") || - !strcmp(opt, "-qtest")) { - return qemu_main(gArgc, gArgv, *_NSGetEnviron()); - } - } - } - - NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]; - - // Pull this console process up to being a fully-fledged graphical - // app with a menubar and Dock icon - ProcessSerialNumber psn =3D { 0, kCurrentProcess }; - TransformProcessType(&psn, kProcessTransformToForegroundApplication); - - [NSApplication sharedApplication]; - +static void create_initial_menus(void) +{ // Add menus NSMenu *menu; NSMenuItem *menuItem; @@ -1585,6 +1550,45 @@ int main (int argc, const char * argv[]) { menuItem =3D [[[NSMenuItem alloc] initWithTitle:@"Window" action:nil k= eyEquivalent:@""] autorelease]; [menuItem setSubmenu:menu]; [[NSApp mainMenu] addItem:menuItem]; +} + +int main (int argc, const char * argv[]) { + + gArgc =3D argc; + gArgv =3D (char **)argv; + int i; + + /* In case we don't need to display a window, let's not do that */ + for (i =3D 1; i < argc; i++) { + const char *opt =3D argv[i]; + + if (opt[0] =3D=3D '-') { + /* Treat --foo the same as -foo. */ + if (opt[1] =3D=3D '-') { + opt++; + } + if (!strcmp(opt, "-h") || !strcmp(opt, "-help") || + !strcmp(opt, "-vnc") || + !strcmp(opt, "-nographic") || + !strcmp(opt, "-version") || + !strcmp(opt, "-curses") || + !strcmp(opt, "-display") || + !strcmp(opt, "-qtest")) { + return qemu_main(gArgc, gArgv, *_NSGetEnviron()); + } + } + } + + NSAutoreleasePool * pool =3D [[NSAutoreleasePool alloc] init]; + + // Pull this console process up to being a fully-fledged graphical + // app with a menubar and Dock icon + ProcessSerialNumber psn =3D { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + + [NSApplication sharedApplication]; + + create_initial_menus(); =20 // Create an Application controller QemuCocoaAppController *appController =3D [[QemuCocoaAppController all= oc] init]; --=20 2.20.1