medley icon indicating copy to clipboard operation
medley copied to clipboard

Medley Docker Image: Meta key does not work ; need to include xmodmap before calling run-medley

Open fghalasz opened this issue 4 years ago • 6 comments

In the Medley Docker images, the Meta key does not work. This is the case for a variety of VNC viewers that I tried across MacOS, Linux and Windows.

This is a complicated issue due to too many layers of mapping and remapping the keyboard codes before Interlisp finally gets to interpret the keypress (and the fact that Maiko basically ignores the modifier maps set up in your X environment).

Be that as it may, the fix is to run xmodmap to switch the Alt-L and Meta-L keymappings in Xvnc before running run-medley.

Probably best to do this by making the docker ENTRYPOINT be a bash script and then doing the XVnc, xmodmap, run-medley sequence in this bash script.

Here is a slice from the bash script that I use in Notecards.online for this purpose:

cd /app/medley
...
/usr/bin/Xvnc -geometry ${width}x${height} -rfbport 1${PORT} -nolisten tcp -localhost -nevershared -dontdisconnect :0 &
export DISPLAY=:0
# make sure X is up and running before proceeding
for i in {1..10}
    do
       xdpyinfo > /dev/null
        if [ $? -eq 0 ]; 
            then
                break
            else
                sleep 1
        fi
    done
xmodmap -e "keycode 12 = Alt_L" -e "keycode 13 = Alt_R" -e "keycode 14 = Meta_L" -e "keycode 15 = Meta_R"
PATH="/app/maiko:$PATH" ./run-medley -g ${width}x${height} -sc ${width}x${height} -vmem ${VMEM_PATH} ${sysout}

Note that I switch both the Left and Right Alt/Meta keys. But in fact Maiko/Medley appears to use just the Left key. The Meta_R key appears to do nothing - even though its mapped to lisp keycode 88 in Maiko. This is good because on my Mac keyboard the Right CMD key is actually mapped to Super-L in VNC Viewers. (On Windows and Linux, the Right CMD/Alt key is mapped to Alt-R in VNC.)

Final Note: From X It appears that from XKeymap.h in Maiko the intent is that either the Alt_L or the Meta_L key should map to "Meta" in Lisp. But the way that the X->lisp keycode mapping algorithm works in initkbd.c,, if there is a Meta_L mapping in the X server's keymap then it will dominate any Alt_L mapping. Hence, since the XVnc keymap has both Meta_L and Alt_L defined, we have to alter XVnc's keymap to make sure that Meta_L (and not Alt_L) is assigned to the key we want to be Meta in Medley. This is what the xmodmap in the bash script above do. There are alternative ways to do this - e.g., just unbind the Meta-L and Meta-R using 'xmodmap -e "keycode 12 =" -e "keycode 13="'. Then Maiko will bind the correct key (known in this configuration as Alt-L) to Lisp "Meta". Confusing, eh?

fghalasz avatar Oct 18 '21 19:10 fghalasz

There are definitely confusing layers of keyboard mappings,

  • keyboard hardware and driver
  • x server implementation (XQuartz, VcxSrv, XVnc)
  • Maiko modifications
  • Lisp handling of keyboard
  • process / windows association of actions in Lisp code

each of which perform some mappings into codes and events

I think an outline of Current State and Desired State and steps to get there would be helpful.

masinter avatar Oct 18 '21 21:10 masinter

@ecraven @nbriggs Does the SDL work also allow us to run a VNC server? That might reduce the complexity of the Medley-in-cloud online server.

masinter avatar Nov 17 '21 22:11 masinter

SDL itself isn't a VNC server -- it does output on a backend that depends on where/how it was compiled. In some cases it will be an X client, so it could output on a VNC server, but mostly it's not. For example, on my Mac:

% SDL_VIDEODRIVER=x11 ./ldesdl
Failed to find UNIXCOMM file handles; no processes
requested width: 1024, height: 768
SDL could not be initialized. SDL_Error: x11 not available
ERROR creating cursor: Cursors are not currently supported
ERROR creating cursor: Cursors are not currently supported
zsh: floating point exception  SDL_VIDEODRIVER=x11 ./ldesdl

nbriggs avatar Nov 17 '21 22:11 nbriggs

just wanted to get more eyes on this

masinter avatar Dec 08 '21 23:12 masinter

Is this issue still relevant?

pamoroso avatar Jul 29 '25 19:07 pamoroso

Do we still distribute a Docker images to users? Is this issue about the Docker image of Medley Online?

pamoroso avatar Sep 26 '25 18:09 pamoroso