From patchwork Thu Nov 2 21:39:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Programmingkid X-Patchwork-Id: 833560 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="l5ceDCB3"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ySdn36nD1z9sNd for ; Fri, 3 Nov 2017 08:40:55 +1100 (AEDT) Received: from localhost ([::1]:33995 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eANEM-0003ed-2B for incoming@patchwork.ozlabs.org; Thu, 02 Nov 2017 17:40:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49416) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eANCq-0002pa-Bt for qemu-devel@nongnu.org; Thu, 02 Nov 2017 17:39:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eANCn-0008Vl-9M for qemu-devel@nongnu.org; Thu, 02 Nov 2017 17:39:20 -0400 Received: from mail-io0-x241.google.com ([2607:f8b0:4001:c06::241]:53398) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eANCn-0008Vb-3p for qemu-devel@nongnu.org; Thu, 02 Nov 2017 17:39:17 -0400 Received: by mail-io0-x241.google.com with SMTP id 189so2106536iow.10 for ; Thu, 02 Nov 2017 14:39:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=0pY3fyzFoja5bYNk/RzRfr75ZW8JTdB+UHIHAsjaXlo=; b=l5ceDCB3FDIIQaIvaAAvj1HR9bET8rhtYtzm6RqEJL8La2duC6GuzwDOl8sdT8eMCh 84z5+cyZTU3uAUyUwxjXdUSkOYFGYJ8B8mxFw3ti/wymFjL8kqGwGJYSFbpq7lJmmOeP Sc3FXyzygNxsXGzY9J9cRIWhiv4wbTpHVfPXGwtX6S1BRA6isWnn4ISSin08QPQPeJj3 3Qv0pl5Olu+gokC2e0qVlTDFU2qBWCrAEblCDbmmpDjZ5Y+QQeNNPKJgbWH27xUI0Lu9 lpF1OKBza1kRbebsmTYDe3hfASUYt7rpAHzgxthWnxEKEjKVbkafIJ+9p9AQN2y1LvdD /MxA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=0pY3fyzFoja5bYNk/RzRfr75ZW8JTdB+UHIHAsjaXlo=; b=ICTix1E94W1fh6bq3LZ/YzssHZTt8jkaY4Gr7J8u2H1ZRQTma/iS1YNYTKLvIe5Kog FB0WIKf108DZFN0WeKPIg+eM17meSnRdCioj1IQMSfL/tuABu5j3/JRa4zuN/DMbmbzE MylXBo26dvWkKX7PVcjmgG/Ii0RBBX0rY9vgb/D1yOWVccN4VOmMLvcHCeVd4MARbj+w UGZQzV0keqU42rC7YjMV3OhsicCjCUdCsVZIdF2b8sxlKkLZhEwwqYd3pSlw/VvN9HOh d1r93iR58S4IoUHKsQeTBYywpvUQZmWi92632QFKBaH9OkezbOmblH6PkQVUYfQA95qm 68Mw== X-Gm-Message-State: AMCzsaXsqjfevlewz/Oxkt+EzRiikcOjRqHN6ha6vrlTy9wuWwm//RpQ 5OmaCIkzBNceFueQp4Ah5Bg= X-Google-Smtp-Source: ABhQp+RPbmIgmLrJZAVbyBGnHKBVTVoz+sGaSRDdQOQCbKD9wCAOVTtdcL4o5V/3xKvC1/hN8Tyugw== X-Received: by 10.36.65.200 with SMTP id b69mr4745616itd.116.1509658756427; Thu, 02 Nov 2017 14:39:16 -0700 (PDT) Received: from localhost.localdomain (d14-69-20-184.try.wideopenwest.com. [69.14.184.20]) by smtp.gmail.com with ESMTPSA id i62sm1933083ioe.31.2017.11.02.14.39.15 (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 02 Nov 2017 14:39:15 -0700 (PDT) From: John Arbuckle To: peter.maydell@linaro.org, qemu-devel@nongnu.org Date: Thu, 2 Nov 2017 17:39:06 -0400 Message-Id: <20171102213907.11443-1-programmingkidx@gmail.com> X-Mailer: git-send-email 2.13.5 (Apple Git-94) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c06::241 Subject: [Qemu-devel] [PATCH v3 1/2] ui/cocoa.m: move ungrab to ctrl-alt-g X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: John Arbuckle Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently the cocoa user interface relys on the user pushing control-alt to ungrab the mouse. This is patch changes the key combination to control-alt-g to be in line with the GTK user interface. Signed-off-by: John Arbuckle --- v3 changes - Code is now keyboard layout aware. ui/cocoa.m | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 2794f60b27..e06aa9c65f 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -609,10 +609,6 @@ - (void) handleEvent:(NSEvent *)event } } - // release Mouse grab when pressing ctrl+alt - if (([event modifierFlags] & NSEventModifierFlagControl) && ([event modifierFlags] & NSEventModifierFlagOption)) { - [self ungrabMouse]; - } break; case NSEventTypeKeyDown: keycode = cocoa_keycode_to_qemu([event keyCode]); @@ -625,14 +621,23 @@ - (void) handleEvent:(NSEvent *)event // default - // handle control + alt Key Combos (ctrl+alt is reserved for QEMU) + // handle control + alt Key Combos (ctrl+alt+[1..9,g] is reserved for QEMU) if (([event modifierFlags] & NSEventModifierFlagControl) && ([event modifierFlags] & NSEventModifierFlagOption)) { - switch (keycode) { - - // enable graphic console - case Q_KEY_CODE_1 ... Q_KEY_CODE_9: // '1' to '9' keys - console_select(keycode - Q_KEY_CODE_1); - break; + NSString *keychar = [event charactersIgnoringModifiers]; + if ([keychar length] == 1) { + char key = [keychar characterAtIndex:0]; + switch (key) { + + // enable graphic console + case '1' ... '9': + console_select(key - '0' - 1); /* ascii math */ + return; + + // release the mouse grab + case 'g': + [self ungrabMouse]; + return; + } } // handle keys for graphic console @@ -806,9 +811,9 @@ - (void) grabMouse if (!isFullscreen) { if (qemu_name) - [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt to release Mouse)", qemu_name]]; + [normalWindow setTitle:[NSString stringWithFormat:@"QEMU %s - (Press ctrl + alt + g to release Mouse)", qemu_name]]; else - [normalWindow setTitle:@"QEMU - (Press ctrl + alt to release Mouse)"]; + [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to release Mouse)"]; } [self hideCursor]; if (!isAbsoluteEnabled) {