From patchwork Mon Feb 25 10:24:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 1047657 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="cFocpPd9"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 447J6g0XZgz9s1b for ; Mon, 25 Feb 2019 21:27:39 +1100 (AEDT) Received: from localhost ([127.0.0.1]:34779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyDU1-0007ll-1B for incoming@patchwork.ozlabs.org; Mon, 25 Feb 2019 05:27:37 -0500 Received: from eggs.gnu.org ([209.51.188.92]:33049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gyDRE-0006AL-3A for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:24:44 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gyDRC-000302-SJ for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:24:43 -0500 Received: from mail-wm1-x342.google.com ([2a00:1450:4864:20::342]:39455) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gyDRC-0002yz-Ju for qemu-devel@nongnu.org; Mon, 25 Feb 2019 05:24:42 -0500 Received: by mail-wm1-x342.google.com with SMTP id z84so7468446wmg.4 for ; Mon, 25 Feb 2019 02:24:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=i/Mt82y4dHNRk1P+265eWJmzywuWVVP6gso7jf/FCQQ=; b=cFocpPd9Gwptx1TKBkT80B1i9+2VIdupz4itXR8DwZtWjRV4OBgxVedAhDYUgdIze9 CVKLk2yANvU1BoM/wx7dAsiiDMvZ9kKxG08hNMrf+fUEHQ7B633++QcRxwDsnNWStV4c t3ccBicEApm87C8Pu1rs6etdnwF+hePEOfLDgZvvd9urq36brMGmCbHXPhxH6uR/5/Ro jG62wQwcpdQbgYEfTmz5RJvwuBLGyANx8GRj9Zs6K80bqP+C6SzrIWsbuqhCneztHNlV 9LXvtRMxwxLV3Cu6Pdc/8COfgaNqdIKd7Q+q8X6OqoEZcl+YUfpvQIAsyc9LqfrQ7DVU IlEg== 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:in-reply-to :references:mime-version:content-transfer-encoding; bh=i/Mt82y4dHNRk1P+265eWJmzywuWVVP6gso7jf/FCQQ=; b=tCZhtUQk/UXH+JxNc0I/p/qUdrey18DCR7Aqa+djKGYcTRIQUvnVvIfrb1zy1/LQpl 6DSP2+DduiX7ESnzCyef3p7+9MyvbeFzvgH18AjNg06kIEe/cBl23fiC/yplRGA9cNTZ bh9XPtQ/OY3+BoiWxMr7pXKjXO1pcyOiC/l3arv1SrZhj2dgtqqhoD3qxYKMWiIX4vkV T5xynBOq+9lYjFr+xl5V5xMm0rJF32id7AvcUCf8kh1Li0BcypFHxbovTJUic2OQmBQc mmsSkX4ROt4QZIZViHDPrOJ4aB+VnpFJW2LF3Z8pSsUvCSkcWGXcIg60yQy7roP6y8UG y/Hw== X-Gm-Message-State: AHQUAuaAlI0SC1BTb0oijPhjs8LAFGz491uje1BP4U8lPt0X0HLLwegz qC6PirP1HLhuflHZpwA+gPofDGC5UCE= X-Google-Smtp-Source: AHgI3IYn2oS6gdyz96u1iikweLWDY2KJZu3l2g4k/Z9GVVqHvXuucidc88OMRYODTPigTBgoOKLG9g== X-Received: by 2002:a1c:700a:: with SMTP id l10mr10904349wmc.13.1551090281075; Mon, 25 Feb 2019 02:24:41 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id v10sm1764692wrn.26.2019.02.25.02.24.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Feb 2019 02:24:40 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 25 Feb 2019 10:24:29 +0000 Message-Id: <20190225102433.22401-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190225102433.22401-1-peter.maydell@linaro.org> References: <20190225102433.22401-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::342 Subject: [Qemu-devel] [PATCH v3 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: , Cc: Roman Bolshakov , patches@linaro.org, John Arbuckle , Gerd Hoffmann , Ben Hekster , Berkus Decker Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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: 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 a913a51a2d..4baec0b2ff 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -1465,43 +1465,8 @@ - (void)adjustSpeed:(id)sender @end - -int main (int argc, const char * argv[]) { - - gArgc = argc; - gArgv = (char **)argv; - int i; - - /* In case we don't need to display a window, let's not do that */ - for (i = 1; i < argc; i++) { - const char *opt = argv[i]; - - if (opt[0] == '-') { - /* Treat --foo the same as -foo. */ - if (opt[1] == '-') { - 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 = [[NSAutoreleasePool alloc] init]; - - // Pull this console process up to being a fully-fledged graphical - // app with a menubar and Dock icon - ProcessSerialNumber psn = { 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 = [[[NSMenuItem alloc] initWithTitle:@"Window" action:nil keyEquivalent:@""] autorelease]; [menuItem setSubmenu:menu]; [[NSApp mainMenu] addItem:menuItem]; +} + +int main (int argc, const char * argv[]) { + + gArgc = argc; + gArgv = (char **)argv; + int i; + + /* In case we don't need to display a window, let's not do that */ + for (i = 1; i < argc; i++) { + const char *opt = argv[i]; + + if (opt[0] == '-') { + /* Treat --foo the same as -foo. */ + if (opt[1] == '-') { + 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 = [[NSAutoreleasePool alloc] init]; + + // Pull this console process up to being a fully-fledged graphical + // app with a menubar and Dock icon + ProcessSerialNumber psn = { 0, kCurrentProcess }; + TransformProcessType(&psn, kProcessTransformToForegroundApplication); + + [NSApplication sharedApplication]; + + create_initial_menus(); // Create an Application controller QemuCocoaAppController *appController = [[QemuCocoaAppController alloc] init];