Patch to allow window title to be set
When running many copies of QEMU on a single desktop it gets difficult to keep track of what OS is running in each window. So I wrote a very simple patch adding a '-title <STRING>' argument to QEMU, which is used to set the SDL window title. eg qemu -hda foo.img -title "Fedora Core 5 builder" It would be great if a patch providing this type of capability were to be included in the next release. My proof of concept patch is attached, but there's a few things it could do better, such as not fixing the title length a 128 chars.
Regards,
Dan.
Signature · 4 lines
|=- Red Hat, Engineering, Emerging Technologies, Boston. +1 978 392 2496 -=| |=- Perl modules: http://search.cpan.org/~danberr/ -=| |=- Projects: http://freshmeat.net/~danielpb/ -=| |=- GnuPG: 7D3B9505 F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 -=|
qemu.1 +3 -0
@@ -266,6 +266,9 @@ .IP "\fB\-full\-screen\fR" 4 .IX Item "-full-screen" Start in full screen. +.IP "\fB\-title window-title\fR" 4 +.IX Item "-title window-title" +Set the title for the display window .IP "\fB\-pidfile file\fR" 4 .IX Item "-pidfile file" Store the \s-1QEMU\s0 process \s-1PID\s0 in \fIfile\fR. It is useful if you launch \s-1QEMU\s0
Only in qemu-0.8.0-new/: qemu.1~
sdl.c +10 -3
@@ -40,6 +40,8 @@static int gui_grab_code =KMOD_LALT |KMOD_LCTRL ;static uint8_t modifiers_state[256 ]; +static char base_caption[128 ] ="QEMU" ; +static void sdl_update (DisplayState *ds,int x,int y,int w,int h) {// printf("updating x=%d y=%d w=%d h=%d\n", x, y, w, h);
@@ -261,14 +263,14 @@static void sdl_update_caption (void ) {char buf[1024 ]; -strcpy (buf,"QEMU" ); +strcpy (buf, base_caption);if (!vm_running) {strcat (buf," [Stopped]" ); }if (gui_grab) {strcat (buf," - Press Ctrl-Alt to exit grab" ); } -SDL_WM_SetCaption (buf,"QEMU" ); +SDL_WM_SetCaption (buf, base_caption); }static void sdl_grab_start (void )
@@ -472,10 +474,15 @@SDL_Quit (); } -void sdl_display_init (DisplayState *ds,int full_screen) +void sdl_display_init (DisplayState *ds,int full_screen,char *title) {int flags; +if (title) { +strncpy (base_caption, title,sizeof (base_caption)-2 ); + base_caption[sizeof (base_caption)-1 ] ='\0' ; + } +#if defined(__APPLE__)/* always use generic keymaps */ if (!keyboard_layout)
Only in qemu-0.8.0-new/: sdl.c~
vl.c +12 -1
@@ -4126,6 +4126,7 @@ QEMU_OPTION_usb, QEMU_OPTION_usbdevice, QEMU_OPTION_smp, + QEMU_OPTION_title, }; typedef struct QEMUOption {
@@ -4196,6 +4197,9 @@/* temporary options */ { "usb", 0, QEMU_OPTION_usb }, { "cirrusvga", 0, QEMU_OPTION_cirrusvga }, + +/* Custom patches */ + { "title", HAS_ARG, QEMU_OPTION_title }, { NULL }, };
@@ -4403,6 +4407,9 @@QEMUMachine *machine;char usb_devices[MAX_VM_USB_PORTS ][128 ];int usb_devices_index; +char title[128 ]; + + title[0 ] ='\0' ;LIST_INIT (&vm_change_state_head);#if !defined(CONFIG_SOFTMMU )
@@ -4773,6 +4780,10 @@exit (1 ); }break ; +case QEMU_OPTION_title: +strncpy (title, optarg,sizeof (title)-2 ); + title[sizeof (title)-1 ] ='\0' ; +break ; } } }
@@ -4932,7 +4943,7 @@dumb_display_init (ds); }else {#if defined(CONFIG_SDL ) -sdl_display_init (ds, full_screen); +sdl_display_init (ds, full_screen, title[0 ] ? title :NULL );#elif defined(CONFIG_COCOA )cocoa_display_init (ds, full_screen);#else
Only in qemu-0.8.0-new/: vl.c~
vl.h +1 -1
@@ -670,7 +670,7 @@ unsigned long vga_ram_offset, int vga_ram_size);/* sdl.c */ -void sdl_display_init (DisplayState *ds,int full_screen); +void sdl_display_init (DisplayState *ds,int full_screen,char *title);/* cocoa.m */ void cocoa_display_init (DisplayState *ds,int full_screen);
Only in qemu-0.8.0-new/: vl.h~