xmodmap patch to vnc 3.3.3 (interesting discoveries!)

Marius Kotsbak marikots "at" stud.aitel.hist.no
Fri, 22 Mar 2002 17:21:17 +0000


(this might have been sent before, but I send it again as I didn't
receive my post)

I have attatched my findings, like you requested and more.


On Thu, 2002-03-21 at 17:30, Grant McDorman wrote:
> According to Marius Kotsbak:
> > I tried your trick, but it didn't have any effect. Has 127 in "xmodmap
> > -e 'keycode 127 = s S aring" anything with the key to do, or is it just
> > an empty keycode. But wait.... now the questionmark key gives me 'S'.
> > This could indicate that the answer is yes.
> 
> No, the '127' is of no significance, other than it has to be higher than the
> highest used keymap entry in Xvnc. Currently, the last used entry is
> actually 88, for F12. I don't know why the question-mark key is giving you
> 'S' (is that really upper case?), unless it's sending the aring - or S -
> keysym.
> 
> I just looked at the other end of the equation, the Windows VNC viewer. It
> has a translation table which converts Windows virtual keys to X keysyms
> (i.e. translating from the Windows names to the Unix names). If a Windows
> key isn't in the table, it tries to send the Latin-1 character (i.e. 8-bit
> ASCII) that corresponds to the key pressed.
> 
> However, for 'aring' this should be OK - the X keysym for 'aring' is the
> Latin-1 character. I don't know why the xmodmap I suggested isn't working -
> unless you have a lower-numbered entry in your keymap for 'aring'; that
> would happen if you pressed 'aring' before doing the xmodmap.
> 
> I think what we need to do here is two things:
>  1) Use xev to determine what keysym is being sent for the international
>     key(s), including aring - and the question-mark key. It should be
>     the corresponding keysyms (e.g. XK_aring).
>     (Do this without doing the xmodmap at all).
>  2) Print the keymap (xmodmap -pk) after pressing the international key(s)
>     on your keyboard, paying attention to keycodes greater than 88.
> 
> Send me the result of this and we'll take it from there.
> 
> > Marius
> >
> > On Wed, 2002-03-20 at 17:18, Grant McDorman wrote:
> > > [Copied to the VNC list since this should be archived, and distributed to
> > > the world.]
> > >
> > > Background: Marius is using a VNC server on a *nix system, and has a
> non-US
> > > (Norwegian?) keyboard. He wishes to change the keyboard layout so that
> the
> > > 'Aring' key, when pressed, acts as the 's' key. The standard X method of
> > > changing this does not work.
> > >
> > > Analysis: This is a deficiency, at best; at worst, it's a bug.
> > >
> > > VNC in general sends keystrokes as key names (due to its Unix heritage,
> > > these are the names used in Unix, referred to as keysyms).
> > >
> > > The Unix VNC server has a compiled-in list of a basic set of key names;
> this
> > > is, essentially, the U.S. 'qwerty' keyboard.
> > >
> > > If you press a key on the viewer that's not in the static list, the VNC
> > > server looks for a key definition, locally, that when pressed will
> > > correspond to the key name. It then uses that definition, suitably
> modifed
> > > by the Shift/Shift Lock keys, to report the key to the Unix applications.
> > >
> > > As a result, it is impossible to redefine the key completely - the
> physical
> > > key name (in this case Aring) must be present on the logical key.
> > >
> > > In detail, the first time you press the 'aring' key Xvnc will add a key
> > > mapping that assigns keycode 91, say, to 'aring'. Subsequently, it will
> > > search its mappings when you press the 'aring' key, and find that entry
> #91
> > > contains 'aring'. It will then send code 91 to the application - which
> will
> > > use the *same* entry to translate it back to a key name: that is,
> 'aring'.
> > >
> > > If you remap 'aring' to 's':
> > >   xmodmap -e 'keysym aring = s'
> > > this changes entry #91 to contain only 's'. As a result, when Xvnc
> searches
> > > its mappings for 'aring', it won't find it - and will create a *new*
> > > mapping!
> > >
> > > However, since the VNC server (and all X servers, in fact) allow multiple
> > > key definitions for each physical key, there is a trick you can use to
> get
> > > the effect you want.
> > >
> > > The first two definitions on the key are the normal state, and the
> shifted
> > > state. The second two are for the 'AltGraph' or "Mode Switch" key, in
> > > combination with the shift key. Subsequent definitions are possible but
> > > usually serve no pratical purpose.
> > >
> > > However, since Xvnc uses the key definition when *any* of the set of
> > > mappings correspond to the physical key, you should be able to do this
> trick:
> > >   xmodmap -e 'keycode 127 = s S aring'
> > > Then, Xvnc will find this mapping for when the viewer sends the aring
> key;
> > > since the 'aring' key name appears as the _third_ symbol the application
> > > (and you) will see 's' (or 'S') when you press the key.
> > >
> > > Of course, if you're using a 'mode switch' type key you'll have to extend
> > > the mapping to five entries; but it should still work.
> > >
> > > (original message follows)
> > >
> > > According to Marius Kotsbak:
> > > > On Wed, 2002-03-20 at 16:44, Grant McDorman wrote:
> > > > > According to Marius Kotsbak:
> > > > > > On Wed, 2002-03-20 at 16:02, Grant McDorman wrote:
> > > > > > > According to Marius:
> > > > > > > > Grant McDorman wrote:
> > > > > > I am NOT using xmodmap with keycodes myself, just keysyms. The
> keycodes
> > > > > > are preconfigured for vnc (havent't changed anything in vnc), just
> as
> > > in
> > > > > > normal X session.
> > > > > >
> > > > > > The opposite work though, i can use keysym "s = aring" and i get
> the
> > > > > > norwegian character "aring" when i press s. But mapping from the
> > > > > > aring-button to s is impossible. xmodmap does not complain, but it
> has
> > > > > > no effect.
> > > > > >
> > > > > > Could it be that vnc is not handling keycodes outside the US
> keyboard
> > > > > > right?
> > > > >
> > > > > VNC doesn't include non-U.S. keysyms in its static keymap. Any keysym
> > > that
> > > > > it receives outside of this static keymap is dynamically added.
> > > > >
> > > > > What happens is the VNC client sends the keysym. If the server finds
> it
> > > in
> > > > > its keymap, it uses that; otherwise, it creates a new entry which, of
> > > > > course, maps the incoming keysym to itself.
> > > > >
> > > > > I'm not sure how one could manage to remap a keysym outside the
> static
> > > > > keymap at startup. However, to see if it works, try this: Press your
> > > aring
> > > > > key; then do 'xmodmap -e "keysym aring = s"'.
> > > > As I said; I have tried exactly that one. It is accepted, but has no
> > > > effect.
> > > >
> > > > >
> > > > > I'll look at the source for 3.3.3 and see if there is something that
> can
> > > be
> > > > > cooked up.
> > > > >
> > > > > --
> > > > >
> > > > > Grant McDorman <grant.mcdorman "at" cedara.com>, Sr. Software Design
> > > Consultant
> > > > > Cedara Software Corp.  <URL:http://www.cedara.com>
> > > > >   (formerly I.S.G. Technologies Inc.)
> > > > > Mississauga, Ontario, Canada
> > > > >
> > > >
> > >
> > > --
> > >
> > > Grant McDorman <grant.mcdorman "at" cedara.com>, Sr. Software Design
> Consultant
> > > Cedara Software Corp.  <URL:http://www.cedara.com>
> > >   (formerly I.S.G. Technologies Inc.)
> > > Mississauga, Ontario, Canada
> > >
> > > [demime 0.97b removed an attachment of type application/pgp-signature]
> > > ---------------------------------------------------------------------
> > > To unsubscribe, mail majordomo "at" uk.research.att.com with the line:
> > > 'unsubscribe vnc-list' in the message BODY
> > > See also: http://www.uk.research.att.com/vnc/intouch.html
> > > ---------------------------------------------------------------------
> >
> 
> --
> 
> Grant McDorman <grant.mcdorman "at" cedara.com>, Sr. Software Design Consultant
> Cedara Software Corp.  <URL:http://www.cedara.com>
>   (formerly I.S.G. Technologies Inc.)
> Mississauga, Ontario, Canada
> 
> [demime 0.97b removed an attachment of type application/pgp-signature]
> ---------------------------------------------------------------------
> To unsubscribe, mail majordomo "at" uk.research.att.com with the line:
> 'unsubscribe vnc-list' in the message BODY
> See also: http://www.uk.research.att.com/vnc/intouch.html
> ---------------------------------------------------------------------
==========================
xev on new clean vncserver
Note the MappingNotify events for every norwegian key.
==========================

PropertyNotify event, serial 22, synthetic NO, window 0x2c00001,
    atom 0xc2 (_NET_WM_ICON_GEOMETRY), time 3184621143, state
PropertyNewValue

MappingNotify event, serial 23, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 89, count 1

KeyPress event, serial 23, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x0, time 3184626161, (518,155), root:(522,175),
    state 0x0, keycode 89 (keysym 0xf8, oslash), same_screen YES,
    XLookupString gives 1 characters:  "x"

KeyRelease event, serial 24, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x0, time 3184626248, (518,155), root:(522,175),
    state 0x0, keycode 89 (keysym 0xf8, oslash), same_screen YES,
    XLookupString gives 1 characters:  "x"

MappingNotify event, serial 24, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 90, count 1

KeyPress event, serial 24, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x0, time 3184627003, (518,155), root:(522,175),
    state 0x0, keycode 90 (keysym 0xe6, ae), same_screen YES,
    XLookupString gives 1 characters:  "f"

KeyRelease event, serial 25, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x0, time 3184627116, (518,155), root:(522,175),
    state 0x0, keycode 90 (keysym 0xe6, ae), same_screen YES,
    XLookupString gives 1 characters:  "f"

MappingNotify event, serial 25, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 91, count 1

KeyPress event, serial 25, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x0, time 3184627974, (518,155), root:(522,175),
    state 0x0, keycode 91 (keysym 0xe5, aring), same_screen YES,
    XLookupString gives 1 characters:  "e"

KeyRelease event, serial 26, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x0, time 3184628047, (518,155), root:(522,175),
    state 0x0, keycode 91 (keysym 0xe5, aring), same_screen YES,
    XLookupString gives 1 characters:  "e"


=======================================
xev the second time the key is typed (no maping notify)
=======================================
KeyPress event, serial 26, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x2c00002, time 3184986739, (59,53), root:(63,73),
    state 0x0, keycode 89 (keysym 0xf8, oslash), same_screen YES,
    XLookupString gives 1 characters:  "x"



===============================
xmodmap -pk (before pressing the norw. keys, the three lines on the bottom are
empty)
===============================
    KeyCode     Keysym (Keysym) ...
    Value       Value   (Name)  ...

      8         0xffe3 (Control_L)
      9         0xffe4 (Control_R)
     10         0xffe1 (Shift_L)
     11         0xffe2 (Shift_R)
     12         0xffe7 (Meta_L)
     13         0xffe8 (Meta_R)
     14         0xffe9 (Alt_L)
     15         0xffea (Alt_R)
     16         0x0020 (space)
     17         0x0030 (0)      0x0029 (parenright)
     18         0x0031 (1)      0x0021 (exclam)
     19         0x0032 (2)      0x0040 (at)
     20         0x0033 (3)      0x0023 (numbersign)
     21         0x0034 (4)      0x0024 (dollar)
     22         0x0035 (5)      0x0025 (percent)
     23         0x0036 (6)      0x005e (asciicircum)
     24         0x0037 (7)      0x0026 (ampersand)
     25         0x0038 (8)      0x002a (asterisk)
     26         0x0039 (9)      0x0028 (parenleft)
     27         0x002d (minus)  0x005f (underscore)
     28         0x003d (equal)  0x002b (plus)
     29         0x005b (bracketleft)    0x007b (braceleft)
     30         0x005d (bracketright)   0x007d (braceright)
     31         0x003b (semicolon)      0x003a (colon)
     32         0x0027 (apostrophe)     0x0022 (quotedbl)
     33         0x0060 (grave)  0x007e (asciitilde)
     34         0x002c (comma)  0x003c (less)
     35         0x002e (period) 0x003e (greater)
     36         0x002f (slash)  0x003f (question)
     37         0x005c (backslash)      0x007c (bar)
     38         0x0061 (a)      0x0041 (A)
     39         0x0062 (b)      0x0042 (B)
     40         0x0063 (c)      0x0043 (C)
     41         0x0064 (d)      0x0044 (D)
     42         0x0065 (e)      0x0045 (E)
     43         0x0066 (f)      0x0046 (F)
     44         0x0067 (g)      0x0047 (G)
     45         0x0068 (h)      0x0048 (H)
     46         0x0069 (i)      0x0049 (I)
     47         0x006a (j)      0x004a (J)
     48         0x006b (k)      0x004b (K)
     49         0x006c (l)      0x004c (L)
     50         0x006d (m)      0x004d (M)
     51         0x006e (n)      0x004e (N)
     52         0x006f (o)      0x004f (O)
     53         0x0070 (p)      0x0050 (P)
     54         0x0071 (q)      0x0051 (Q)
     55         0x0072 (r)      0x0052 (R)
     56         0x0073 (s)      0x0053 (S)
     57         0x0074 (t)      0x0054 (T)
     58         0x0075 (u)      0x0055 (U)
     59         0x0076 (v)      0x0056 (V)
     60         0x0077 (w)      0x0057 (W)
     61         0x0078 (x)      0x0058 (X)
     62         0x0079 (y)      0x0059 (Y)
     63         0x007a (z)      0x005a (Z)
     64         0xff08 (BackSpace)
     65         0xff0d (Return)
     66         0xff09 (Tab)
     67         0xff1b (Escape)
     68         0xffff (Delete)
     69         0xff50 (Home)
     70         0xff57 (End)
     71         0xff55 (Prior)
     72         0xff56 (Next)
     73         0xff52 (Up)
     74         0xff54 (Down)
     75         0xff51 (Left)
     76         0xff53 (Right)
     77         0xffbe (F1)
     78         0xffbf (F2)
     79         0xffc0 (F3)
     80         0xffc1 (F4)
     81         0xffc2 (F5)
     82         0xffc3 (F6)
     83         0xffc4 (F7)
     84         0xffc5 (F8)
     85         0xffc6 (F9)
     86         0xffc7 (F10)
     87         0xffc8 (F11)
     88         0xffc9 (F12)
!!     89         0x00f8 (oslash) 0x00d8 (Ooblique)
!!     90         0x00e6 (ae)     0x00c6 (AE)
!!     91         0x00e5 (aring)  0x00c5 (Aring)




=============================
After I run: "xmodmap  -e "keysym aring = s"

the aring line is changed into:

     91         0x0073 (s)






And then when I run xev (after doing the same for "ae", It mappes it to a new
keycode (90->93)!:

========================================================
MappingNotify event, serial 23, synthetic NO, window 0x0,
    request MappingKeyboard, first_keycode 93, count 1

KeyPress event, serial 23, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x2c00002, time 3185604561, (60,31), root:(64,51),
    state 0x0, keycode 93 (keysym 0xe6, ae), same_screen YES,
    XLookupString gives 1 characters:  "
KeyPress"

KeyRelease event, serial 24, synthetic NO, window 0x2c00001,
    root 0x25, subw 0x2c00002, time 3185604633, (60,31), root:(64,51),
    state 0x0, keycode 93 (keysym 0xe6, ae), same_screen YES,
    XLookupString gives 1 characters:  " event"
=============================



The keymap is now:
....
     89         0x00f8 (oslash) 0x00d8 (Ooblique)
     90         0x0071 (q)
     91         0x0073 (s)
     92         0x00e5 (aring)  0x00c5 (Aring)
     93         0x00e6 (ae)     0x00c6 (AE)
.....


It seems like it is no longer recognizing the keycodes after the mapping.




================================================
Result of your trick (127, and mapping oslash to i after pressing the key (the
127-code changes, but
the x-server still use the lower one)

     89         0x00f8 (oslash) 0x00d8 (Ooblique)
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127         0x0069 (i)
---------------------------------------------------------------------
To unsubscribe, mail majordomo "at" uk.research.att.com with the line:
'unsubscribe vnc-list' in the message BODY
See also: http://www.uk.research.att.com/vnc/intouch.html
---------------------------------------------------------------------