From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1FYABy-0007IF-5P for qemu-devel@nongnu.org; Mon, 24 Apr 2006 19:10:06 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1FYABv-0007HQ-FU for qemu-devel@nongnu.org; Mon, 24 Apr 2006 19:10:05 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1FYABv-0007HL-7j for qemu-devel@nongnu.org; Mon, 24 Apr 2006 19:10:03 -0400 Received: from [66.187.233.31] (helo=mx1.redhat.com) by monty-python.gnu.org with esmtp (Exim 4.52) id 1FYAEE-00071s-TS for qemu-devel@nongnu.org; Mon, 24 Apr 2006 19:12:27 -0400 Received: from int-mx1.corp.redhat.com (int-mx1.corp.redhat.com [172.16.52.254]) by mx1.redhat.com (8.12.11.20060308/8.12.11) with ESMTP id k3ON9uVC000785 for ; Mon, 24 Apr 2006 19:09:56 -0400 Received: from file.surrey.redhat.com (file.surrey.redhat.com [172.16.10.4]) by int-mx1.corp.redhat.com (8.12.11.20060308/8.11.6) with ESMTP id k3ON9tR3011223 for ; Mon, 24 Apr 2006 19:09:55 -0400 Received: (from berrange@localhost) by file.surrey.redhat.com (8.13.1/8.13.1/Submit) id k3ON9t9w014216 for qemu-devel@nongnu.org; Tue, 25 Apr 2006 00:09:55 +0100 Date: Tue, 25 Apr 2006 00:09:55 +0100 From: "Daniel P. Berrange" Message-ID: <20060424230954.GA12450@redhat.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="pf9I7BMVVzbSWLtt" Content-Disposition: inline Subject: [Qemu-devel] Patch to allow window title to be set Reply-To: "Daniel P. Berrange" , qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 ' 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 -=| --pf9I7BMVVzbSWLtt Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="qemu-title.patch" 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~ --pf9I7BMVVzbSWLtt--