Question

Background: I am currently in the process of creating a simple VNC viewer embedded in a QWidget for use on Windows. For this, I compiled the Qt-only VNC version of KRDC (remote desktop viewer for KDE) as well as its dependency libvncclient on windows. The problem which arose now however lies in the way krdc sends key events over vnc: it simply sends the value of QKeyEvent::nativeVirtualKey(), which on X11 is conveniently already a valid RFB keysym. On Windows however, this is not the case.

Now, to solve this problem, I think the best (and ultimately also portable) way is to translate Qt's QKeyEvent::key() and ::modifier() data back to valid X11/RFB keysyms. This seems somewhat complex though given that I need to pick different keysyms depending on modifier state (XK_a vs XK_A, I've only considered shift so far) as well. Looking into how X11 -> Qt translation is done in Qt's source code didn't really help either.

Might there already be a library or code snippet out there which accomplishes this? Or should I just attempt to write my own (incomplete) translation routine? If so, what would be the best way to go about this and also, are there other caveats related to X11 I should be aware of?

Was it helpful?

Solution

Well, seems like I'm actually blind; there was a reference in krdc's code, right below the e->nativeVirtualKey() statement, referencing another project's class where they encountered the exact same problem as me:

// hmm, either Win32-platform or too old Qt so we have to handle and
// translate Qt-key-codes to X-keycodes

I didn't test their solution but it seems solid. As I only discovered this now, I have already written a small routine myself which should work ok for most latin keyboards (but will probably break if the Qt team changes any of the Qt::Key values), if anyone is interested in it: link

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top