From nobody Sun Apr 28 18:09:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510049840335181.66670218164666; Tue, 7 Nov 2017 02:17:20 -0800 (PST) Received: from localhost ([::1]:52465 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC0wW-0001NZ-Bp for importer@patchew.org; Tue, 07 Nov 2017 05:17:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC0uu-0000Ol-JC for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eC0ur-0007rL-TX for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:36 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:38228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eC0ur-0007lV-MP for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:33 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eC0un-0004Dh-6U; Tue, 07 Nov 2017 10:15:29 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 7 Nov 2017 10:16:00 +0000 Message-Id: <1510049762-4609-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510049762-4609-1-git-send-email-peter.maydell@linaro.org> References: <1510049762-4609-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 1/3] ui/cocoa.m: Make scrolling work again in GUI monitor windows 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: programmingkidx@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: John Arbuckle Make scrolling in the monitor work, by correctly passing through control+key combinations. Signed-off-by: John Arbuckle Message-id: 20171101154607.1582-1-programmingkidx@gmail.com [PMM: fixed coding style nits; cleaned up commit message] Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- ui/cocoa.m | 98 ++++++++++++++++++++++++++++++++++++++++++----------------= ---- 1 file changed, 66 insertions(+), 32 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 2794f60..2f76dac 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -281,6 +281,7 @@ static void handleAnyDeviceErrors(Error * err) - (void) grabMouse; - (void) ungrabMouse; - (void) toggleFullScreen:(id)sender; +- (void) handleMonitorInput:(NSEvent *)event; - (void) handleEvent:(NSEvent *)event; - (void) setAbsoluteEnabled:(BOOL)tIsAbsoluteEnabled; /* The state surrounding mouse grabbing is potentially confusing. @@ -554,6 +555,70 @@ QemuCocoaView *cocoaView; qemu_input_event_send_key_qcode(dcl->con, keycode, false); } =20 +// Does the work of sending input to the monitor +- (void) handleMonitorInput:(NSEvent *)event +{ + int keysym =3D 0; + int control_key =3D 0; + + // if the control key is down + if ([event modifierFlags] & NSEventModifierFlagControl) { + control_key =3D 1; + } + + /* translates Macintosh keycodes to QEMU's keysym */ + + int without_control_translation[] =3D { + [0 ... 0xff] =3D 0, // invalid key + + [kVK_UpArrow] =3D QEMU_KEY_UP, + [kVK_DownArrow] =3D QEMU_KEY_DOWN, + [kVK_RightArrow] =3D QEMU_KEY_RIGHT, + [kVK_LeftArrow] =3D QEMU_KEY_LEFT, + [kVK_Home] =3D QEMU_KEY_HOME, + [kVK_End] =3D QEMU_KEY_END, + [kVK_PageUp] =3D QEMU_KEY_PAGEUP, + [kVK_PageDown] =3D QEMU_KEY_PAGEDOWN, + [kVK_ForwardDelete] =3D QEMU_KEY_DELETE, + [kVK_Delete] =3D QEMU_KEY_BACKSPACE, + }; + + int with_control_translation[] =3D { + [0 ... 0xff] =3D 0, // invalid key + + [kVK_UpArrow] =3D QEMU_KEY_CTRL_UP, + [kVK_DownArrow] =3D QEMU_KEY_CTRL_DOWN, + [kVK_RightArrow] =3D QEMU_KEY_CTRL_RIGHT, + [kVK_LeftArrow] =3D QEMU_KEY_CTRL_LEFT, + [kVK_Home] =3D QEMU_KEY_CTRL_HOME, + [kVK_End] =3D QEMU_KEY_CTRL_END, + [kVK_PageUp] =3D QEMU_KEY_CTRL_PAGEUP, + [kVK_PageDown] =3D QEMU_KEY_CTRL_PAGEDOWN, + }; + + if (control_key !=3D 0) { /* If the control key is being used */ + if ([event keyCode] < ARRAY_SIZE(with_control_translation)) { + keysym =3D with_control_translation[[event keyCode]]; + } + } else { + if ([event keyCode] < ARRAY_SIZE(without_control_translation)) { + keysym =3D without_control_translation[[event keyCode]]; + } + } + + // if not a key that needs translating + if (keysym =3D=3D 0) { + NSString *ks =3D [event characters]; + if ([ks length] > 0) { + keysym =3D [ks characterAtIndex:0]; + } + } + + if (keysym) { + kbd_put_keysym(keysym); + } +} + - (void) handleEvent:(NSEvent *)event { COCOA_DEBUG("QemuCocoaView: handleEvent\n"); @@ -641,38 +706,7 @@ QemuCocoaView *cocoaView; =20 // handlekeys for Monitor } else { - int keysym =3D 0; - switch([event keyCode]) { - case 115: - keysym =3D QEMU_KEY_HOME; - break; - case 117: - keysym =3D QEMU_KEY_DELETE; - break; - case 119: - keysym =3D QEMU_KEY_END; - break; - case 123: - keysym =3D QEMU_KEY_LEFT; - break; - case 124: - keysym =3D QEMU_KEY_RIGHT; - break; - case 125: - keysym =3D QEMU_KEY_DOWN; - break; - case 126: - keysym =3D QEMU_KEY_UP; - break; - default: - { - NSString *ks =3D [event characters]; - if ([ks length] > 0) - keysym =3D [ks characterAtIndex:0]; - } - } - if (keysym) - kbd_put_keysym(keysym); + [self handleMonitorInput: event]; } break; case NSEventTypeKeyUp: --=20 2.7.4 From nobody Sun Apr 28 18:09:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510049998454150.57979428612487; Tue, 7 Nov 2017 02:19:58 -0800 (PST) Received: from localhost ([::1]:52474 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC0z2-0003aZ-KE for importer@patchew.org; Tue, 07 Nov 2017 05:19:52 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC0ux-0000QX-PE for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:47 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eC0uq-0007qH-4G for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:39 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:38228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eC0up-0007lV-SX for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:32 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eC0un-0004Dz-T8; Tue, 07 Nov 2017 10:15:29 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 7 Nov 2017 10:16:01 +0000 Message-Id: <1510049762-4609-3-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510049762-4609-1-git-send-email-peter.maydell@linaro.org> References: <1510049762-4609-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 2/3] 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: programmingkidx@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: John Arbuckle Currently the cocoa user interface relis 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 Message-id: 20171102213907.11443-1-programmingkidx@gmail.com Reviewed-by: Peter Maydell Signed-off-by: Peter Maydell --- ui/cocoa.m | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index 2f76dac..f39c792 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -674,10 +674,6 @@ QemuCocoaView *cocoaView; } } =20 - // release Mouse grab when pressing ctrl+alt - if (([event modifierFlags] & NSEventModifierFlagControl) && ([= event modifierFlags] & NSEventModifierFlagOption)) { - [self ungrabMouse]; - } break; case NSEventTypeKeyDown: keycode =3D cocoa_keycode_to_qemu([event keyCode]); @@ -690,14 +686,23 @@ QemuCocoaView *cocoaView; =20 // default =20 - // handle control + alt Key Combos (ctrl+alt is reserved for Q= EMU) + // handle control + alt Key Combos (ctrl+alt+[1..9,g] is reser= ved 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 =3D [event charactersIgnoringModifiers]; + if ([keychar length] =3D=3D 1) { + char key =3D [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; + } } =20 // handle keys for graphic console @@ -840,9 +845,9 @@ QemuCocoaView *cocoaView; =20 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 M= ouse)"]; + [normalWindow setTitle:@"QEMU - (Press ctrl + alt + g to relea= se Mouse)"]; } [self hideCursor]; if (!isAbsoluteEnabled) { --=20 2.7.4 From nobody Sun Apr 28 18:09:11 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1510049840325444.7026574769602; Tue, 7 Nov 2017 02:17:20 -0800 (PST) Received: from localhost ([::1]:52464 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC0wW-0001MU-Ow for importer@patchew.org; Tue, 07 Nov 2017 05:17:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eC0uu-0000Om-RH for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:37 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eC0ur-0007qi-0W for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:36 -0500 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:38228) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eC0uq-0007lV-Pp for qemu-devel@nongnu.org; Tue, 07 Nov 2017 05:15:32 -0500 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1eC0uo-0004EH-I7; Tue, 07 Nov 2017 10:15:30 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Tue, 7 Nov 2017 10:16:02 +0000 Message-Id: <1510049762-4609-4-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1510049762-4609-1-git-send-email-peter.maydell@linaro.org> References: <1510049762-4609-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 3/3] ui/cocoa.m: Send ctrl-alt key combos to guest if QEMU isn't using them 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: programmingkidx@gmail.com Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Send those ctrl-alt key combos that QEMU doesn't treat specially to the guest rather than ignoring them. All the case where we do special handling of ctrl-alt-X exit the event handling using a "return" statement, so we can simply allow the rest to fall through into the normal key handling by deleting the now-spurious "else". We take the opportunity to clean up some oddly-formatted and now rather uninformative comments by removing them. Signed-off-by: Peter Maydell --- ui/cocoa.m | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/ui/cocoa.m b/ui/cocoa.m index f39c792..330cceb 100644 --- a/ui/cocoa.m +++ b/ui/cocoa.m @@ -704,12 +704,10 @@ QemuCocoaView *cocoaView; return; } } + } =20 - // handle keys for graphic console - } else if (qemu_console_is_graphic(NULL)) { + if (qemu_console_is_graphic(NULL)) { qemu_input_event_send_key_qcode(dcl->con, keycode, true); - - // handlekeys for Monitor } else { [self handleMonitorInput: event]; } --=20 2.7.4