[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 3/5] ui/cocoa: Factor out initial menu creation
From: |
Peter Maydell |
Subject: |
[Qemu-devel] [RFC 3/5] ui/cocoa: Factor out initial menu creation |
Date: |
Sat, 1 Dec 2018 12:30:54 +0000 |
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 <address@hidden>
---
ui/cocoa.m | 78 ++++++++++++++++++++++++++++--------------------------
1 file changed, 41 insertions(+), 37 deletions(-)
diff --git a/ui/cocoa.m b/ui/cocoa.m
index 997b0199c6c..da511bfb4fa 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -1444,43 +1444,8 @@ QemuCocoaView *cocoaView;
@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;
@@ -1564,6 +1529,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];
--
2.19.2
- [Qemu-devel] [RFC 0/5] ui/cocoa: Use OSX's main loop, Peter Maydell, 2018/12/01
- [Qemu-devel] [RFC 1/5] ui/cocoa: Ensure we have the iothread lock when calling into QEMU, Peter Maydell, 2018/12/01
- [Qemu-devel] [RFC 5/5] ui/cocoa: Perform UI operations only on the main thread, Peter Maydell, 2018/12/01
- [Qemu-devel] [RFC 3/5] ui/cocoa: Factor out initial menu creation,
Peter Maydell <=
- [Qemu-devel] [RFC 4/5] ui/cocoa: Move console/device menu creation code up in file, Peter Maydell, 2018/12/01
- [Qemu-devel] [RFC 2/5] ui/cocoa: Use the pixman image directly in switchSurface, Peter Maydell, 2018/12/01
- Re: [Qemu-devel] [RFC 0/5] ui/cocoa: Use OSX's main loop, Richard Henderson, 2018/12/03
- Re: [Qemu-devel] [RFC 0/5] ui/cocoa: Use OSX's main loop, Gerd Hoffmann, 2018/12/05