From patchwork Thu Sep 17 20:48:04 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dustin Kirkland X-Patchwork-Id: 33801 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id AF4B5B7B6D for ; Fri, 18 Sep 2009 06:48:51 +1000 (EST) Received: from localhost ([127.0.0.1]:57935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MoNuJ-0003hH-Ju for incoming@patchwork.ozlabs.org; Thu, 17 Sep 2009 16:48:47 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1MoNtk-0003eX-G9 for qemu-devel@nongnu.org; Thu, 17 Sep 2009 16:48:12 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1MoNti-0003dp-A5 for qemu-devel@nongnu.org; Thu, 17 Sep 2009 16:48:10 -0400 Received: from [199.232.76.173] (port=36400 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1MoNti-0003dm-1q for qemu-devel@nongnu.org; Thu, 17 Sep 2009 16:48:10 -0400 Received: from adelie.canonical.com ([91.189.90.139]:57881) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1MoNth-0008Ft-J2 for qemu-devel@nongnu.org; Thu, 17 Sep 2009 16:48:09 -0400 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1MoNtf-0003Zg-If; Thu, 17 Sep 2009 21:48:07 +0100 Received: from cpe-66-69-254-183.austin.res.rr.com ([66.69.254.183] helo=[192.168.1.144]) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.69) (envelope-from ) id 1MoNtf-0002Eg-7u; Thu, 17 Sep 2009 21:48:07 +0100 From: Dustin Kirkland To: qemu-devel@nongnu.org Date: Thu, 17 Sep 2009 15:48:04 -0500 Message-Id: <1253220484.12314.39.camel@x200> Mime-Version: 1.0 X-Mailer: Evolution 2.27.92 X-detected-operating-system: by monty-python.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: aliguori@us.ibm.com Subject: [Qemu-devel] [PATCH] offer right-ctrl as a grab option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: kirkland@canonical.com List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org offer right-ctrl as a grab option Add support for -ctrl-grab to use the right-ctrl button to grab/release the mouse in SDL. The multi-button ctrl-alt and ctrl-alt-shift grab buttons present an accessibility problem to users who cannot press more than one button at a time. https://bugs.edge.launchpad.net/ubuntu/+source/qemu-kvm/+bug/237635 Signed-off-by: Dustin Kirkkland --- qemu-options.hx | 10 ++++++++++ sdl.c | 21 ++++++++++++--------- sysemu.h | 1 + vl.c | 4 ++++ 4 files changed, 27 insertions(+), 9 deletions(-) diff --git a/qemu-options.hx b/qemu-options.hx index d3aa55b..19377da 100644 --- a/qemu-options.hx +++ b/qemu-options.hx @@ -478,6 +478,16 @@ Use Ctrl-Alt-Shift to grab mouse (instead of Ctrl-Alt). ETEXI #ifdef CONFIG_SDL +DEF("ctrl-grab", 0, QEMU_OPTION_ctrl_grab, + "-ctrl-grab use Right-Ctrl to grab mouse (instead of Ctrl-Alt)\n") +#endif +STEXI +@item -ctrl-grab + +Use Right-Ctrl to grab mouse (instead of Ctrl-Alt). +ETEXI + +#ifdef CONFIG_SDL DEF("no-quit", 0, QEMU_OPTION_no_quit, "-no-quit disable SDL window close capability\n") #endif diff --git a/sdl.c b/sdl.c index 42b6f37..61e8fdf 100644 --- a/sdl.c +++ b/sdl.c @@ -413,12 +413,13 @@ static void sdl_update_caption(void) if (!vm_running) status = " [Stopped]"; - else if (gui_grab) { - if (!alt_grab) - status = " - Press Ctrl-Alt to exit grab"; - else + else if (gui_grab) + if (alt_grab) status = " - Press Ctrl-Alt-Shift to exit grab"; - } + else if (ctrl_grab) + status = " - Press Right-Ctrl to exit grab"; + else + status = " - Press Ctrl-Alt to exit grab"; if (qemu_name) { snprintf(win_title, sizeof(win_title), "QEMU (%s)%s", qemu_name, status); @@ -557,12 +558,14 @@ static void sdl_refresh(DisplayState *ds) case SDL_KEYDOWN: case SDL_KEYUP: if (ev->type == SDL_KEYDOWN) { - if (!alt_grab) { - mod_state = (SDL_GetModState() & gui_grab_code) == - gui_grab_code; - } else { + if (alt_grab) { mod_state = (SDL_GetModState() & (gui_grab_code | KMOD_LSHIFT)) == (gui_grab_code | KMOD_LSHIFT); + } else if (ctrl_grab) { + mod_state = (SDL_GetModState() & KMOD_RCTRL) == KMOD_RCTRL; + } else { + mod_state = (SDL_GetModState() & gui_grab_code) == + gui_grab_code; } gui_key_modifier_pressed = mod_state; if (gui_key_modifier_pressed) { diff --git a/sysemu.h b/sysemu.h index 644a97d..68b6b0f 100644 --- a/sysemu.h +++ b/sysemu.h @@ -125,6 +125,7 @@ extern const char *keyboard_layout; extern int win2k_install_hack; extern int rtc_td_hack; extern int alt_grab; +extern int ctrl_grab; extern int usb_enabled; extern int smp_cpus; extern int max_cpus; diff --git a/vl.c b/vl.c index eb01da7..1884cf5 100644 --- a/vl.c +++ b/vl.c @@ -242,6 +242,7 @@ int old_param = 0; #endif const char *qemu_name; int alt_grab = 0; +int ctrl_grab = 0; #if defined(TARGET_SPARC) || defined(TARGET_PPC) unsigned int nb_prom_envs = 0; const char *prom_envs[MAX_PROM_ENVS]; @@ -5197,6 +5198,9 @@ int main(int argc, char **argv, char **envp) case QEMU_OPTION_alt_grab: alt_grab = 1; break; + case QEMU_OPTION_ctrl_grab: + ctrl_grab = 1; + break; case QEMU_OPTION_no_quit: no_quit = 1; break;