From: "Daniel P. Berrange" <berrange@redhat.com>
To: qemu-devel@nongnu.org
Subject: [Qemu-devel] Patch to allow window title to be set
Date: Tue, 25 Apr 2006 00:09:55 +0100 [thread overview]
Message-ID: <20060424230954.GA12450@redhat.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 864 bytes --]
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 -=|
[-- Attachment #2: qemu-title.patch --]
[-- Type: text/plain, Size: 3790 bytes --]
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~
reply other threads:[~2006-04-24 23:10 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20060424230954.GA12450@redhat.com \
--to=berrange@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.