Emacs over rdesktop

April 16, 2009

Finally solved an issue has been driving me crazy for weeks! If I can help one other poor soul out there with this writeup, it’ll be worth it. Even if not, I need this entry to make sure I never forget how to fix this problem.

At work, I’m running Ubuntu 8.10 on my workstation. I also have an XP VM running most of the time, so when I need to do Windows work, I can just RDP into it.

I’m using rdesktop as my RDP client, and it is working great, mostly. Very lightweight and fast. So when running it in fullscreen mode, the user experience is pretty much as if I had XP running locally.

Except…there was one small but extraordinarily annoying issue.

Sometimes, after pressing the left Alt and Shift keys simultaneously, the keyboard would get into some state where it acted as if the left Windows key was depressed. The effect was that subsequent keypresses would pop up windows with dogs in them (“f”), Explorer windows (“e”) or similar. It would stay this way until I actually pressed the Windows key to somehow reset it.

It turns out that when the Alt key is depressed before the Shift key, an ALT_L window event (or whatever it’s called, I don’t even want to know) is generated for the Alt key.

But when the Shift key is depressed before the Alt key, a META_L event was generated instead!! How lame is that?!?

So this was what tripped rdesktop, and it was really a bitch to find. It seemed to pop up randomly, the randomness being caused by whichever key I happened to strike first…

Almost forgot to mention the trick I found to fix the issue. Simply put this in your .profile:

xmodmap -e "remove mod1 = Meta_L"

This causes the left Alt key to always generate an ALT_L event. Problem solved.

UPDATE:
Seems the above method didn’t quite cut it… I also needed to add this to “.profile”:

xmodmap -e "keycode 64 = Alt_L"

For some reason, I think this has become necessary since upgrading to 9.04…?

5 Responses to “Emacs over rdesktop”

  1. Alan Bram Says:

    Wow, this is fantastic!

    I have been enduring this exact same problem for years, but never had
    a clue as to how to solve it. Although the problem seems trifling, it
    was extremely annoying. But, I’m sure I don’t have to tell you that.
    Just as you said, it was really driving me crazy.

    (Now all I have to do is re-train myself to type normally when I’m in
    the rdesktop window, instead of trying to remember to use Esc instead
    of Meta.)

    Thank you so much for sharing this.

  2. Alan Bram Says:

    Gee, I spoke too soon. Sometimes it works, and sometimes it doesn’t. I haven’t yet noticed what the determining factor is.
    :-(

  3. chopmo Says:

    Alan,

    Oh, too bad…just thought I had helped you out there.

    Do you know of the “xev” program? You can use it to get information about the keycodes generated by each keypress. This was what helped me discover that the left Alt key did not always produce the same keycode.

    /Chopmo

  4. Alan Bram Says:

    Hi Chopmo,

    Thanks for your reply. I forgot about the “xev” program. Maybe I’ll give that a try and see what I can discover.

    – arb

  5. Alan Bram Says:

    Hi again, Chopmo,

    Just wanted to let you know that since I added the extra stuff you mentioned in your “UPDATE” everything has been working beautifully. This is such a pleasure; thank you again.

    Cheers,
    – arb


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: