qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: berrange@redhat.com, Gerd Hoffmann <kraxel@redhat.com>
Subject: [Qemu-devel] [RFC PATCH v2 6/7] keymap: pass full keyboard state to keysym2scancode
Date: Wed, 19 Dec 2018 13:09:03 +0100	[thread overview]
Message-ID: <20181219120904.17643-7-kraxel@redhat.com> (raw)
In-Reply-To: <20181219120904.17643-1-kraxel@redhat.com>

Pass the keyboard state tracker handle down to keysym2scancode(),
so the code can fully inspect the keyboard state as needed.  No
functional change.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 ui/keymaps.h | 3 ++-
 ui/curses.c  | 2 +-
 ui/keymaps.c | 8 ++++----
 ui/vnc.c     | 5 +----
 4 files changed, 8 insertions(+), 10 deletions(-)

diff --git a/ui/keymaps.h b/ui/keymaps.h
index 98213a4191..6a2365196a 100644
--- a/ui/keymaps.h
+++ b/ui/keymaps.h
@@ -26,6 +26,7 @@
 #define QEMU_KEYMAPS_H
 
 #include "qemu-common.h"
+#include "ui/kbd-state.h"
 
 typedef struct {
 	const char* name;
@@ -55,7 +56,7 @@ typedef struct kbd_layout_t kbd_layout_t;
 kbd_layout_t *init_keyboard_layout(const name2keysym_t *table,
                                    const char *language, Error **errp);
 int keysym2scancode(kbd_layout_t *k, int keysym,
-                    bool shift, bool altgr, bool ctrl);
+                    KbdState *kbd);
 int keycode_is_keypad(kbd_layout_t *k, int keycode);
 int keysym_is_numlock(kbd_layout_t *k, int keysym);
 
diff --git a/ui/curses.c b/ui/curses.c
index f4e7a12f74..54687589d4 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -273,7 +273,7 @@ static void curses_refresh(DisplayChangeListener *dcl)
             }
 
             keycode = keysym2scancode(kbd_layout, keysym & KEYSYM_MASK,
-                                      false, false, false);
+                                      NULL);
             if (keycode == 0)
                 continue;
 
diff --git a/ui/keymaps.c b/ui/keymaps.c
index 085889b555..6be87cc201 100644
--- a/ui/keymaps.c
+++ b/ui/keymaps.c
@@ -189,7 +189,7 @@ kbd_layout_t *init_keyboard_layout(const name2keysym_t *table,
 
 
 int keysym2scancode(kbd_layout_t *k, int keysym,
-                    bool shift, bool altgr, bool ctrl)
+                    KbdState *kbd)
 {
     static const uint32_t mask =
         SCANCODE_SHIFT | SCANCODE_ALTGR | SCANCODE_CTRL;
@@ -221,13 +221,13 @@ int keysym2scancode(kbd_layout_t *k, int keysym,
      * If so, prefer that one.
      */
     mods = 0;
-    if (shift) {
+    if (kbd && kbd_state_modifier_get(kbd, KBD_MOD_SHIFT)) {
         mods |= SCANCODE_SHIFT;
     }
-    if (altgr) {
+    if (kbd && kbd_state_modifier_get(kbd, KBD_MOD_ALTGR)) {
         mods |= SCANCODE_ALTGR;
     }
-    if (ctrl) {
+    if (kbd && kbd_state_modifier_get(kbd, KBD_MOD_CTRL)) {
         mods |= SCANCODE_CTRL;
     }
 
diff --git a/ui/vnc.c b/ui/vnc.c
index b56431ce3b..704a138667 100644
--- a/ui/vnc.c
+++ b/ui/vnc.c
@@ -1954,9 +1954,6 @@ static const char *code2name(int keycode)
 
 static void key_event(VncState *vs, int down, uint32_t sym)
 {
-    bool shift = kbd_state_modifier_get(vs->vd->kbd, KBD_MOD_SHIFT);
-    bool altgr = kbd_state_modifier_get(vs->vd->kbd, KBD_MOD_ALTGR);
-    bool ctrl  = kbd_state_modifier_get(vs->vd->kbd, KBD_MOD_CTRL);
     int keycode;
     int lsym = sym;
 
@@ -1965,7 +1962,7 @@ static void key_event(VncState *vs, int down, uint32_t sym)
     }
 
     keycode = keysym2scancode(vs->vd->kbd_layout, lsym & 0xFFFF,
-                              shift, altgr, ctrl) & SCANCODE_KEYMASK;
+                              vs->vd->kbd) & SCANCODE_KEYMASK;
     trace_vnc_key_event_map(down, sym, keycode, code2name(keycode));
     do_key_event(vs, down, keycode, sym);
 }
-- 
2.9.3

  parent reply	other threads:[~2018-12-19 12:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-19 12:08 [Qemu-devel] [RFC PATCH v2 0/7] ui: add generic keyboard state tracker, fix keymap Gerd Hoffmann
2018-12-19 12:08 ` [Qemu-devel] [RFC PATCH v2 1/7] kbd-state: add keyboard state tracker Gerd Hoffmann
2018-12-21 10:56   ` Daniel P. Berrangé
2019-01-22 16:52   ` Eric Blake
2019-01-23  6:20     ` Gerd Hoffmann
2018-12-19 12:08 ` [Qemu-devel] [RFC PATCH v2 2/7] kbd-state: use state tracker for sdl2 Gerd Hoffmann
2018-12-21 11:04   ` Daniel P. Berrangé
2019-01-22 16:58   ` Eric Blake
2018-12-19 12:09 ` [Qemu-devel] [RFC PATCH v2 3/7] sdl2: use only QKeyCode in sdl2_process_key() Gerd Hoffmann
2018-12-21 11:06   ` Daniel P. Berrangé
2018-12-19 12:09 ` [Qemu-devel] [RFC PATCH v2 4/7] kbd-state: use state tracker for gtk Gerd Hoffmann
2018-12-21 11:10   ` Daniel P. Berrangé
2018-12-19 12:09 ` [Qemu-devel] [RFC PATCH v2 5/7] kbd-state: use state tracker for vnc Gerd Hoffmann
2018-12-21 11:18   ` Daniel P. Berrangé
2019-01-22  9:00     ` Gerd Hoffmann
2019-01-22  9:41       ` Daniel P. Berrangé
2018-12-19 12:09 ` Gerd Hoffmann [this message]
2018-12-21 11:18   ` [Qemu-devel] [RFC PATCH v2 6/7] keymap: pass full keyboard state to keysym2scancode Daniel P. Berrangé
2018-12-19 12:09 ` [Qemu-devel] [RFC PATCH v2 7/7] keymap: fix keyup mappings Gerd Hoffmann
2018-12-21 11:19   ` Daniel P. Berrangé
2018-12-25  6:46 ` [Qemu-devel] [RFC PATCH v2 0/7] ui: add generic keyboard state tracker, fix keymap no-reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181219120904.17643-7-kraxel@redhat.com \
    --to=kraxel@redhat.com \
    --cc=berrange@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).