diff mbox series

[v2,2/2] ui/cocoa.m: send ctrl-alt key combinations to guest if not used by QEMU

Message ID 20171005145557.5746-3-programmingkidx@gmail.com
State New
Headers show
Series ui/cocoa.m: enable guest to see control-alt key combinations | expand

Commit Message

Programmingkid Oct. 5, 2017, 2:55 p.m. UTC
Send control-alt key combinations to the guest if not used by the user interface.

---
v2 changes:
- changed logic to use existing if case

 ui/cocoa.m | 31 ++++++++++++++-----------------
 1 file changed, 14 insertions(+), 17 deletions(-)

Comments

Peter Maydell Oct. 31, 2017, 2:38 p.m. UTC | #1
On 5 October 2017 at 15:55, John Arbuckle <programmingkidx@gmail.com> wrote:
> Send control-alt key combinations to the guest if not used by the user interface.
>
> ---
> v2 changes:
> - changed logic to use existing if case
>

This patch is missing your signed-off-by line, can you provide
it, please?

thanks
-- PMM
Peter Maydell Oct. 31, 2017, 2:52 p.m. UTC | #2
On 31 October 2017 at 14:38, Peter Maydell <peter.maydell@linaro.org> wrote:
> On 5 October 2017 at 15:55, John Arbuckle <programmingkidx@gmail.com> wrote:
>> Send control-alt key combinations to the guest if not used by the user interface.
>>
>> ---
>> v2 changes:
>> - changed logic to use existing if case
>>
>
> This patch is missing your signed-off-by line, can you provide
> it, please?

...actually, don't worry -- I wrote an equivalent of this patch
that does the same thing but doesn't need to get rid of the
switch() statement.

thanks
-- PMM
Programmingkid Nov. 1, 2017, 3:11 p.m. UTC | #3
> On Oct 31, 2017, at 10:52 AM, Peter Maydell <peter.maydell@linaro.org> wrote:
> 
> On 31 October 2017 at 14:38, Peter Maydell <peter.maydell@linaro.org> wrote:
>> On 5 October 2017 at 15:55, John Arbuckle <programmingkidx@gmail.com> wrote:
>>> Send control-alt key combinations to the guest if not used by the user interface.
>>> 
>>> ---
>>> v2 changes:
>>> - changed logic to use existing if case
>>> 
>> 
>> This patch is missing your signed-off-by line, can you provide
>> it, please?
> 
> ...actually, don't worry -- I wrote an equivalent of this patch
> that does the same thing but doesn't need to get rid of the
> switch() statement.
> 
> thanks
> -- PMM

Please cc me when you send it to the mailing list. Thanks.
diff mbox series

Patch

diff --git a/ui/cocoa.m b/ui/cocoa.m
index d3e7907103..828d507d57 100644
--- a/ui/cocoa.m
+++ b/ui/cocoa.m
@@ -619,25 +619,22 @@  - (void) handleEvent:(NSEvent *)event
                 return;
             }
 
-            // default
-
-            // 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 - 11);
-                        break;
+            // console selection
+            if (([event modifierFlags] & NSEventModifierFlagControl) &&
+                ([event modifierFlags] & NSEventModifierFlagOption) &&
+                (keycode >= Q_KEY_CODE_1 && keycode <= Q_KEY_CODE_9)) {
+                console_select(keycode - 11);
+            }
 
-                    // release the mouse grab
-                    case Q_KEY_CODE_G:
-                        [self ungrabMouse];
-                        break;
-                }
+            // mouse ungrab
+            else if (([event modifierFlags] & NSEventModifierFlagControl) &&
+                     ([event modifierFlags] & NSEventModifierFlagOption) &&
+                     (keycode == Q_KEY_CODE_G)) {
+                [self ungrabMouse];
+            }
 
-            // handle keys for graphic console
-            } else if (qemu_console_is_graphic(NULL)) {
+            // send to guest
+            else if (qemu_console_is_graphic(NULL)) {
                 qemu_input_event_send_key_qcode(dcl->con, keycode, true);
 
             // handlekeys for Monitor