* [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu @ 2015-01-24 1:56 Programmingkid 2015-02-12 3:39 ` Peter Maydell 0 siblings, 1 reply; 7+ messages in thread From: Programmingkid @ 2015-01-24 1:56 UTC (permalink / raw) To: Peter Maydell; +Cc: qemu-devel qemu-devel This patch adds these consoles to the View menu: VGA QEMU Monitor Parallel Serial Signed-off-by: John Arbuckle <programmingkidx@gmail.com> --- ui/cocoa.m | 34 ++++++++++++++++++++++++++++++++++ 1 files changed, 34 insertions(+), 0 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index d37c29b..c88c0d0 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -801,6 +801,10 @@ QemuCocoaView *cocoaView; - (void)toggleFullScreen:(id)sender; - (void)showQEMUDoc:(id)sender; - (void)showQEMUTec:(id)sender; +- (void)displayVGA:(id)sender; +- (void)displayMonitor:(id)sender; +- (void)displayParallel:(id)sender; +- (void)displaySerial:(id)sender; @end @implementation QemuCocoaAppController @@ -943,6 +947,31 @@ QemuCocoaView *cocoaView; [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-tech.html", [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; } + +/* Displays the VGA screen */ +- (void)displayVGA:(id)sender +{ + console_select(0); +} + +/* Displays the QEMU Monitor screen */ +- (void)displayMonitor:(id)sender +{ + console_select(1); +} + +/* Displays the parallel port screen */ +- (void)displayParallel:(id)sender +{ + console_select(3); +} + +/* Displays the serial port screen */ +- (void)displaySerial:(id)sender +{ + console_select(2); +} + @end @@ -1006,6 +1035,11 @@ int main (int argc, const char * argv[]) { // View menu menu = [[NSMenu alloc] initWithTitle:@"View"]; [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen + [menu addItem:[NSMenuItem separatorItem]]; //Separator + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"VGA" action:@selector(displayVGA:) keyEquivalent:@""] autorelease]]; // VGA + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"QEMU Monitor" action:@selector(displayMonitor:) keyEquivalent:@""] autorelease]]; // QEMU Monitor + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Parallel" action:@selector(displayParallel:) keyEquivalent:@""] autorelease]]; // Parallel + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Serial" action:@selector(displaySerial:) keyEquivalent:@""] autorelease]]; // Serial menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""] autorelease]; [menuItem setSubmenu:menu]; [[NSApp mainMenu] addItem:menuItem]; -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu 2015-01-24 1:56 [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu Programmingkid @ 2015-02-12 3:39 ` Peter Maydell 2015-02-12 16:10 ` Programmingkid ` (2 more replies) 0 siblings, 3 replies; 7+ messages in thread From: Peter Maydell @ 2015-02-12 3:39 UTC (permalink / raw) To: Programmingkid; +Cc: qemu-devel qemu-devel, Gerd Hoffmann On 24 January 2015 at 01:56, Programmingkid <programmingkidx@gmail.com> wrote: > This patch adds these consoles to the View menu: > VGA > QEMU Monitor > Parallel > Serial > > Signed-off-by: John Arbuckle <programmingkidx@gmail.com> > +/* Displays the VGA screen */ > +- (void)displayVGA:(id)sender > +{ > + console_select(0); > +} > + > +/* Displays the QEMU Monitor screen */ > +- (void)displayMonitor:(id)sender > +{ > + console_select(1); > +} > + > +/* Displays the parallel port screen */ > +- (void)displayParallel:(id)sender > +{ > + console_select(3); > +} > + > +/* Displays the serial port screen */ > +- (void)displaySerial:(id)sender > +{ > + console_select(2); > +} I'm afraid this doesn't work, because there's no guarantee that these consoles will be created or in this order. They just happen to be the set you get for the x86 PC model. If you boot a versatilepb ARM image with the serial output directed to stdio, for instance, then the "serial" entry in the menu gets you the parallel port console, and the parallel port entry does nothing, because this board and config happens to end up creating only 3 consoles, not 4 (graphics, monitor, parallel). We're going to need to automatically create and update the menu entries based on which consoles get created if we want this to work properly, I think. Gerd, any suggestions? Is there a hook for "list of active consoles has changed"? What's the right way to get the printable name of a console? thanks -- PMM ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu 2015-02-12 3:39 ` Peter Maydell @ 2015-02-12 16:10 ` Programmingkid 2015-02-12 22:03 ` Programmingkid 2015-02-13 7:45 ` Gerd Hoffmann 2 siblings, 0 replies; 7+ messages in thread From: Programmingkid @ 2015-02-12 16:10 UTC (permalink / raw) To: Peter Maydell; +Cc: qemu-devel qemu-devel, Gerd Hoffmann On Feb 11, 2015, at 10:39 PM, Peter Maydell wrote: > On 24 January 2015 at 01:56, Programmingkid <programmingkidx@gmail.com> wrote: >> This patch adds these consoles to the View menu: >> VGA >> QEMU Monitor >> Parallel >> Serial >> >> Signed-off-by: John Arbuckle <programmingkidx@gmail.com> > >> +/* Displays the VGA screen */ >> +- (void)displayVGA:(id)sender >> +{ >> + console_select(0); >> +} >> + >> +/* Displays the QEMU Monitor screen */ >> +- (void)displayMonitor:(id)sender >> +{ >> + console_select(1); >> +} >> + >> +/* Displays the parallel port screen */ >> +- (void)displayParallel:(id)sender >> +{ >> + console_select(3); >> +} >> + >> +/* Displays the serial port screen */ >> +- (void)displaySerial:(id)sender >> +{ >> + console_select(2); >> +} > > I'm afraid this doesn't work, because there's no guarantee > that these consoles will be created or in this order. > They just happen to be the set you get for the x86 > PC model. If you boot a versatilepb ARM image with the > serial output directed to stdio, for instance, then the > "serial" entry in the menu gets you the parallel > port console, and the parallel port entry does nothing, > because this board and config happens to end up creating > only 3 consoles, not 4 (graphics, monitor, parallel). > > We're going to need to automatically create and update > the menu entries based on which consoles get created > if we want this to work properly, I think. Gerd, any > suggestions? Is there a hook for "list of active > consoles has changed"? What's the right way to get > the printable name of a console? > I was hoping the gtk.c file would have some code I could use, but it doesn't. My model for these menu items came from a YouTube video demonstrating the GTK UI in QEMU. Does QEMU still have these menu items in the GTK UI? The gtk.c file does not seem to indicate that. ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu 2015-02-12 3:39 ` Peter Maydell 2015-02-12 16:10 ` Programmingkid @ 2015-02-12 22:03 ` Programmingkid 2015-02-13 7:45 ` Gerd Hoffmann 2 siblings, 0 replies; 7+ messages in thread From: Programmingkid @ 2015-02-12 22:03 UTC (permalink / raw) To: Peter Maydell; +Cc: qemu-devel qemu-devel, Gerd Hoffmann On Feb 11, 2015, at 10:39 PM, Peter Maydell wrote: > On 24 January 2015 at 01:56, Programmingkid <programmingkidx@gmail.com> wrote: >> This patch adds these consoles to the View menu: >> VGA >> QEMU Monitor >> Parallel >> Serial >> >> Signed-off-by: John Arbuckle <programmingkidx@gmail.com> > >> +/* Displays the VGA screen */ >> +- (void)displayVGA:(id)sender >> +{ >> + console_select(0); >> +} >> + >> +/* Displays the QEMU Monitor screen */ >> +- (void)displayMonitor:(id)sender >> +{ >> + console_select(1); >> +} >> + >> +/* Displays the parallel port screen */ >> +- (void)displayParallel:(id)sender >> +{ >> + console_select(3); >> +} >> + >> +/* Displays the serial port screen */ >> +- (void)displaySerial:(id)sender >> +{ >> + console_select(2); >> +} > > I'm afraid this doesn't work, because there's no guarantee > that these consoles will be created or in this order. > They just happen to be the set you get for the x86 > PC model. If you boot a versatilepb ARM image with the > serial output directed to stdio, for instance, then the > "serial" entry in the menu gets you the parallel > port console, and the parallel port entry does nothing, > because this board and config happens to end up creating > only 3 consoles, not 4 (graphics, monitor, parallel). > > We're going to need to automatically create and update > the menu entries based on which consoles get created > if we want this to work properly, I think. Gerd, any > suggestions? Is there a hook for "list of active > consoles has changed"? What's the right way to get > the printable name of a console? Do you know where the code is that creates the consoles? ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu 2015-02-12 3:39 ` Peter Maydell 2015-02-12 16:10 ` Programmingkid 2015-02-12 22:03 ` Programmingkid @ 2015-02-13 7:45 ` Gerd Hoffmann 2015-02-13 15:37 ` Programmingkid 2015-02-14 5:48 ` [Qemu-devel] [PATCH v2] ui/cocoa.m: Adds console items to the View menu Programmingkid 2 siblings, 2 replies; 7+ messages in thread From: Gerd Hoffmann @ 2015-02-13 7:45 UTC (permalink / raw) To: Peter Maydell; +Cc: Programmingkid, qemu-devel qemu-devel Hi, > We're going to need to automatically create and update > the menu entries based on which consoles get created > if we want this to work properly, I think. Gerd, any > suggestions? Is there a hook for "list of active > consoles has changed"? No. consoles are not hotpluggable. > What's the right way to get > the printable name of a console? gd_vc_gfx_init() has code for gfx consoles (qemu_console_is_graphic() == true). There is nothing for text consoles. Guess we should create a qemu_console_get_label() helper function in ui/console.c, then move the code from gd_vc_gfx_init() to that place, and for text consoles use QemuConsole->chr->label. cheers, Gerd ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu 2015-02-13 7:45 ` Gerd Hoffmann @ 2015-02-13 15:37 ` Programmingkid 2015-02-14 5:48 ` [Qemu-devel] [PATCH v2] ui/cocoa.m: Adds console items to the View menu Programmingkid 1 sibling, 0 replies; 7+ messages in thread From: Programmingkid @ 2015-02-13 15:37 UTC (permalink / raw) To: Gerd Hoffmann; +Cc: Peter Maydell, qemu-devel qemu-devel On Feb 13, 2015, at 2:45 AM, Gerd Hoffmann wrote: > Hi, > >> We're going to need to automatically create and update >> the menu entries based on which consoles get created >> if we want this to work properly, I think. Gerd, any >> suggestions? Is there a hook for "list of active >> consoles has changed"? > > No. consoles are not hotpluggable. > >> What's the right way to get >> the printable name of a console? > > gd_vc_gfx_init() has code for gfx consoles (qemu_console_is_graphic() == > true). > > There is nothing for text consoles. > > Guess we should create a qemu_console_get_label() helper function in > ui/console.c, then move the code from gd_vc_gfx_init() to that place, > and for text consoles use QemuConsole->chr->label. > > cheers, > Gerd Thank you Gerd for your suggestion. Here is my suggestion: int get_Graphics_Console_Index() int get_Serial_Console_Index() int get_Parallel_Console_Index() int get_Monitor_Console_Index() Then I would be able to do this: console_select(get_Serial_Console_Index()); The is simple and to the point. No having to have to search for a console. If the console does not exist, the function could return -1. Then the code would something like this: if(get_Serial_Console_Index() != -1) console_select(get_Serial_Console_Index()); else printf("Sorry but Serial console does not exist\n\a"); ^ permalink raw reply [flat|nested] 7+ messages in thread
* [Qemu-devel] [PATCH v2] ui/cocoa.m: Adds console items to the View menu 2015-02-13 7:45 ` Gerd Hoffmann 2015-02-13 15:37 ` Programmingkid @ 2015-02-14 5:48 ` Programmingkid 1 sibling, 0 replies; 7+ messages in thread From: Programmingkid @ 2015-02-14 5:48 UTC (permalink / raw) To: Gerd Hoffmann; +Cc: Peter Maydell, qemu-devel qemu-devel Adds these items to the View menu: VGA Monitor Serial Parallel Signed-off-by: John Arbuckle <programmingkidx@gmail.com> --- Implemented new function that gives you the index for a given console name. Moved View menu code to its own function. Console menu items are now checked before being adding to the View menu. include/ui/console.h | 1 + ui/cocoa.m | 61 ++++++++++++++++++++++++++++++++++++++++++++----- ui/console.c | 38 +++++++++++++++++++++++++++++++ 3 files changed, 93 insertions(+), 7 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 8a4d671..efe5517 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -323,6 +323,7 @@ void qemu_console_copy(QemuConsole *con, int src_x, int src_y, int dst_x, int dst_y, int w, int h); DisplaySurface *qemu_console_surface(QemuConsole *con); DisplayState *qemu_console_displaystate(QemuConsole *console); +int get_console_index(const char *name); /* sdl.c */ void sdl_display_init(DisplayState *ds, int full_screen, int no_frame); diff --git a/ui/cocoa.m b/ui/cocoa.m index d37c29b..54012b6 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -801,6 +801,10 @@ QemuCocoaView *cocoaView; - (void)toggleFullScreen:(id)sender; - (void)showQEMUDoc:(id)sender; - (void)showQEMUTec:(id)sender; +- (void)displayVGA:(id)sender; +- (void)displayMonitor:(id)sender; +- (void)displayParallel:(id)sender; +- (void)displaySerial:(id)sender; @end @implementation QemuCocoaAppController @@ -943,6 +947,32 @@ QemuCocoaView *cocoaView; [[NSWorkspace sharedWorkspace] openFile:[NSString stringWithFormat:@"%@/../doc/qemu/qemu-tech.html", [[NSBundle mainBundle] resourcePath]] withApplication:@"Help Viewer"]; } + +/* Displays the VGA screen */ +- (void)displayVGA:(id)sender +{ + console_select(get_console_index("graphic")); +} + +/* Displays the QEMU Monitor screen */ +- (void)displayMonitor:(id)sender +{ + //console_select(1); + console_select(get_console_index("monitor")); +} + +/* Displays the serial port screen */ +- (void)displaySerial:(id)sender +{ + console_select(get_console_index("serial")); +} + +/* Displays the parallel port screen */ +- (void)displayParallel:(id)sender +{ + console_select(get_console_index("parallel")); +} + @end @@ -1003,13 +1033,6 @@ int main (int argc, const char * argv[]) { [[NSApp mainMenu] addItem:menuItem]; [NSApp performSelector:@selector(setAppleMenu:) withObject:menu]; // Workaround (this method is private since 10.4+) - // View menu - menu = [[NSMenu alloc] initWithTitle:@"View"]; - [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen - menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""] autorelease]; - [menuItem setSubmenu:menu]; - [[NSApp mainMenu] addItem:menuItem]; - // Window menu menu = [[NSMenu alloc] initWithTitle:@"Window"]; [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Minimize" action:@selector(performMiniaturize:) keyEquivalent:@"m"] autorelease]]; // Miniaturize @@ -1116,6 +1139,27 @@ static const DisplayChangeListenerOps dcl_ops = { .dpy_refresh = cocoa_refresh, }; +// Creates the view menu +static void create_view_menu() +{ + NSMenu * menu; + NSMenuItem * menuItem; + menu = [[NSMenu alloc] initWithTitle:@"View"]; + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Enter Fullscreen" action:@selector(toggleFullScreen:) keyEquivalent:@"f"] autorelease]]; // Fullscreen + [menu addItem:[NSMenuItem separatorItem]]; //Separator + if(get_console_index("graphic") != -1) + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"VGA" action:@selector(displayVGA:) keyEquivalent:@""] autorelease]]; // VGA + if(get_console_index("monitor") != -1) + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"QEMU Monitor" action:@selector(displayMonitor:) keyEquivalent:@""] autorelease]]; // QEMU Monitor + if (get_console_index("serial") != -1) + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Serial" action:@selector(displaySerial:) keyEquivalent:@""] autorelease]]; // Serial + if(get_console_index("parallel") != -1) + [menu addItem: [[[NSMenuItem alloc] initWithTitle:@"Parallel" action:@selector(displayParallel:) keyEquivalent:@""] autorelease]]; // Parallel + menuItem = [[[NSMenuItem alloc] initWithTitle:@"View" action:nil keyEquivalent:@""] autorelease]; + [menuItem setSubmenu:menu]; + [[NSApp mainMenu] insertItem: menuItem atIndex: 1]; // insert View menu after Application menu +} + void cocoa_display_init(DisplayState *ds, int full_screen) { COCOA_DEBUG("qemu_cocoa: cocoa_display_init\n"); @@ -1128,4 +1172,7 @@ void cocoa_display_init(DisplayState *ds, int full_screen) // register cleanup function atexit(cocoa_cleanup); + + // called here because QEMU needs to be running first + create_view_menu(); } diff --git a/ui/console.c b/ui/console.c index 87574a7..620a029 100644 --- a/ui/console.c +++ b/ui/console.c @@ -2071,3 +2071,41 @@ static void register_types(void) } type_init(register_types); + +/* + Returns the console index associated with the name. + name can be graphic, monitor, serial, or parallel. +*/ +int get_console_index(const char *name) +{ + int i; + /* If looking for the graphic console */ + if (strcmp("graphic", name) == 0) { + for (i = 0; i < nb_consoles; i++) { + /* If we found the console */ + if (consoles[i]->console_type == GRAPHIC_CONSOLE) { + return i; + } + } + /* If we failed to find the console */ + return -1; + } + + /* If looking for QEMU monitor, serial, or parallel console */ + CharDriverState *chr; + for (i = 0; i < nb_consoles; i++) { + chr = consoles[i]->chr; + + /* Can't do anything but skip it */ + if (chr == NULL) { + continue; + } + /* If we found the console */ + if (strstr(chr->label, name)) { + return i; + } + } + + /* Could not find console */ + return -1; +} -- 1.7.5.4 ^ permalink raw reply related [flat|nested] 7+ messages in thread
end of thread, other threads:[~2015-02-14 5:48 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2015-01-24 1:56 [Qemu-devel] [PATCH] cocoa.m: Adds console items to the view menu Programmingkid 2015-02-12 3:39 ` Peter Maydell 2015-02-12 16:10 ` Programmingkid 2015-02-12 22:03 ` Programmingkid 2015-02-13 7:45 ` Gerd Hoffmann 2015-02-13 15:37 ` Programmingkid 2015-02-14 5:48 ` [Qemu-devel] [PATCH v2] ui/cocoa.m: Adds console items to the View menu Programmingkid
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).