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.
-- 
|=- 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  -=| 
diff -ru qemu-0.8.0-orig/qemu.1 qemu-0.8.0-new/qemu.1
--- qemu-0.8.0-orig/qemu.1      2005-12-19 22:51:53.000000000 +0000
+++ qemu-0.8.0-new/qemu.1       2006-01-03 13:06:01.000000000 +0000
@@ -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~
diff -ru qemu-0.8.0-orig/sdl.c qemu-0.8.0-new/sdl.c
--- qemu-0.8.0-orig/sdl.c       2005-12-19 22:51:53.000000000 +0000
+++ qemu-0.8.0-new/sdl.c        2006-01-03 12:51:57.000000000 +0000
@@ -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~
diff -ru qemu-0.8.0-orig/vl.c qemu-0.8.0-new/vl.c
--- qemu-0.8.0-orig/vl.c        2005-12-19 22:51:53.000000000 +0000
+++ qemu-0.8.0-new/vl.c 2006-01-03 13:10:18.000000000 +0000
@@ -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~
diff -ru qemu-0.8.0-orig/vl.h qemu-0.8.0-new/vl.h
--- qemu-0.8.0-orig/vl.h        2005-12-19 22:51:53.000000000 +0000
+++ qemu-0.8.0-new/vl.h 2006-01-03 12:49:22.000000000 +0000
@@ -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~
_______________________________________________
Qemu-devel mailing list
Qemu-devel@nongnu.org
http://lists.nongnu.org/mailman/listinfo/qemu-devel

Reply via email to