QEMU developers: I have been using QEMU off and on for some time. Recently I had a need for a Windows XP VM to be joined to a domain. I discovered a rather annoying issue in the form of the key-grab: NT-based Microsoft operating systems make heavy use of Ctrl-Alt-Delete, i.e. to sign on, open the task manager, change your password, lock your screen, etc. I've started using the tablet USB device specifically because I don't like this grabby behaviour, and it started becoming a real problem for everyday use.
I wrote a patch that adds a command-line switch to qemu (-alt-grab). It allows you to remap the keygrab combination to Ctrl-Alt-Shift when using SDL-based displays. It has only been tested on Linux / AMD64. Please reply to me off-list, as I am not subscribed. Comments are appreciated, and I would like to see this make it into the mainline QEMU branch. --------------------------------------------------------------------- Patches below are against kvm-26. The included patches were written by Michael Mohr. They are licensed to you under the GNU GPL version 2 or (at your discretion) any later version. Michael Mohr can be contacted at [EMAIL PROTECTED] June 06, 2007 diff -urN qemu-org/sdl.c qemu/sdl.c --- qemu-org/sdl.c 2007-06-06 23:58:13.000000000 -0700 +++ qemu/sdl.c 2007-06-06 23:57:41.000000000 -0700 @@ -223,7 +223,11 @@ strcat(buf, " [Stopped]"); } if (gui_grab) { - strcat(buf, " - Press Ctrl-Alt to exit grab"); + if (!alt_grab) { + strcat(buf, " - Press Ctrl-Alt to exit grab"); + } else { + strcat(buf, " - Press Ctrl-Alt-Shift to exit grab"); + } } SDL_WM_SetCaption(buf, "QEMU"); } @@ -331,8 +335,13 @@ case SDL_KEYDOWN: case SDL_KEYUP: if (ev->type == SDL_KEYDOWN) { - mod_state = (SDL_GetModState() & gui_grab_code) == + if (!alt_grab) { + mod_state = (SDL_GetModState() & gui_grab_code) == gui_grab_code; + } else { + mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) == + (gui_grab_code | KMOD_LSHIFT); + } gui_key_modifier_pressed = mod_state; if (gui_key_modifier_pressed) { int keycode; @@ -392,7 +401,11 @@ } } } else if (ev->type == SDL_KEYUP) { - mod_state = (ev->key.keysym.mod & gui_grab_code); + if (!alt_grab) { + mod_state = (ev->key.keysym.mod & gui_grab_code); + } else { + mod_state = (ev->key.keysym.mod & (gui_grab_code | KMOD_LSHIFT)); + } if (!mod_state) { if (gui_key_modifier_pressed) { gui_key_modifier_pressed = 0; diff -urN qemu-org/vl.c qemu/vl.c --- qemu-org/vl.c 2007-06-06 23:58:13.000000000 -0700 +++ qemu/vl.c 2007-06-06 23:57:41.000000000 -0700 @@ -182,6 +182,7 @@ int autostart = 1; int time_drift_fix = 0; const char *cpu_vendor_string; +int alt_grab = 0; /***********************************************************/ /* x86 ISA bus support */ @@ -6341,6 +6342,7 @@ "-boot [a|c|d|n] boot on floppy (a), hard disk (c), CD-ROM (d), or network (n)\n" "-snapshot write to temporary files instead of disk image files\n" #ifdef CONFIG_SDL + "-alt-grab use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt)\n" "-no-quit disable SDL window close capability\n" #endif #ifdef TARGET_I386 @@ -6541,6 +6543,7 @@ QEMU_OPTION_no_rtc, #endif QEMU_OPTION_cpu_vendor, + QEMU_OPTION_alt_grab }; typedef struct QEMUOption { @@ -6638,6 +6641,7 @@ { "no-rtc", 0, QEMU_OPTION_no_rtc }, #endif { "cpu-vendor", HAS_ARG, QEMU_OPTION_cpu_vendor }, + { "alt-grab", 0, QEMU_OPTION_alt_grab }, { NULL }, }; @@ -7364,6 +7368,9 @@ case QEMU_OPTION_cpu_vendor: cpu_vendor_string = optarg; break; + case QEMU_OPTION_alt_grab: + alt_grab = 1; + break; } } } diff -urN qemu-org/vl.h qemu/vl.h --- qemu-org/vl.h 2007-06-06 23:58:13.000000000 -0700 +++ qemu/vl.h 2007-06-06 23:57:41.000000000 -0700 @@ -159,6 +159,7 @@ extern int kqemu_allowed; extern int kvm_allowed; extern int win2k_install_hack; +extern int alt_grab; extern int usb_enabled; extern int smp_cpus; extern int no_quit;