[comp.windows.x] Keysyms and function keys

peter@polygen.uucp (Peter Ent) (12/21/88)

Does anyone know how to map multiple key combinations to a single key event
or from something that XLookupString returns via a keysym?

For example, we want to get back XK_Insert from something like ctrl-A. We
are not currently using any toolkits and have tried to find where in the
Athena widget set this type of translation is done.  The O'Reilly books
are of no help on this.  

We have also tried using XChangeKeyboardMapping but the page in the book
is VERY unclear. We tried to put 2 keysyms per keycode to map Ctrl-A to
XK_Insert as follows:

KeySym keysyms[] = { ControlMapIndex, XK_Insert };

	:

XChangeKeyboardMapping( display, 84, 2, keysyms, 1 );

but all that did was make the 'a' key turn into Ctrl-B. If the explanation
is lengthy, is there a better source than the O'Reilly books.

--peter ent
  Polygen Corp.
  (617) 890-288

dshr@SUN.COM (David Rosenthal) (12/21/88)

Once again.

Keysyms describe the symbols that are painted on the keys.  The only
reason you should ever use ChangeKeyboardMapping is if you paint different
symbols on keys.

The way these Keysyms are interpreted is up to each individual client.
The X server has no such concept as the control-A key,  and no such
concept as ASCII when it comes to keys.  Like the rest of X11,  the
keyboard support is designed to support simultaneously clients with
different ideas about character sets and their encodings.  That is
why the server rigourously avoids using ASCII anywhere.

If you want your client to interpret:

	A down-transition of the key with an A painted on it with the
	control modifier bit set

as an Insert command,  you must set up whatever translation tables
your client is using to have that effect.  There is nothing you can
do to the server to have this effect.

	David.

swick@ATHENA.MIT.EDU (Ralph R. Swick) (12/21/88)

> Does anyone know how to map multiple key combinations to a single key event
> or from something that XLookupString returns via a keysym?

I'm not sure I understand the last part of this question.  There is nothing
in Xlib that merges multiple events together.

> For example, we want to get back XK_Insert from something like ctrl-A.

No, you probably don't.  What you probably want is for your application
to execute the "insert" action upon receiving a key event (or a sequence
of key events) matching one of a list of events, where the list of events
includes "any key event with a keycode corresponding to XK_Insert" and
"any key event with the control modifier set and a keycode corresponding
to XK_A".  The Translation Management facility of the Xt Intrinsics are
designed to handle exactly this; see 'X Toolkit Intrinsics - C Language
Interface' chapter 10 and appendix B.

You don't want to use XChangeKeyboardMapping unless you actually remove
a keycap from your keyboard and replace it with a different one.