1 /* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2000 Red Hat, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
20 * file for a list of people on the GTK+ Team. See the ChangeLog
21 * files for a list of changes. These files are distributed with
22 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
27 #include "gdkkeysyms.h"
28 #include "gdkkeysprivate.h"
29 #include "gdkdisplay.h"
30 #include "gdkdisplaymanagerprivate.h"
35 * @Short_description: Functions for manipulating keyboard codes
38 * Key values are the codes which are sent whenever a key is pressed or released.
39 * They appear in the #GdkEventKey.keyval field of the
40 * #GdkEventKey structure, which is passed to signal handlers for the
41 * #GtkWidget::key-press-event and #GtkWidget::key-release-event signals.
42 * The complete list of key values can be found in the
43 * <filename><gdk/gdkkeysyms.h></filename> header file.
45 * Key values are regularly updated from the upstream X.org X11 implementation,
46 * so new values are added regularly. They will be prefixed with GDK_KEY_ rather
47 * than XF86XK_ or XK_ (for older symbols).
49 * Key values can be converted into a string representation using
50 * gdk_keyval_name(). The reverse function, converting a string to a key value,
51 * is provided by gdk_keyval_from_name().
53 * The case of key values can be determined using gdk_keyval_is_upper() and
54 * gdk_keyval_is_lower(). Key values can be converted to upper or lower case
55 * using gdk_keyval_to_upper() and gdk_keyval_to_lower().
57 * When it makes sense, key values can be converted to and from
58 * Unicode characters with gdk_keyval_to_unicode() and gdk_unicode_to_keyval().
60 * <para id="key-group-explanation">
61 * One #GdkKeymap object exists for each user display. gdk_keymap_get_default()
62 * returns the #GdkKeymap for the default display; to obtain keymaps for other
63 * displays, use gdk_keymap_get_for_display(). A keymap
64 * is a mapping from #GdkKeymapKey to key values. You can think of a #GdkKeymapKey
65 * as a representation of a symbol printed on a physical keyboard key. That is, it
66 * contains three pieces of information. First, it contains the hardware keycode;
67 * this is an identifying number for a physical key. Second, it contains the
68 * <firstterm>level</firstterm> of the key. The level indicates which symbol on the
69 * key will be used, in a vertical direction. So on a standard US keyboard, the key
70 * with the number "1" on it also has the exclamation point ("!") character on
71 * it. The level indicates whether to use the "1" or the "!" symbol. The letter
72 * keys are considered to have a lowercase letter at level 0, and an uppercase
73 * letter at level 1, though only the uppercase letter is printed. Third, the
74 * #GdkKeymapKey contains a group; groups are not used on standard US keyboards,
75 * but are used in many other countries. On a keyboard with groups, there can be 3
76 * or 4 symbols printed on a single key. The group indicates movement in a
77 * horizontal direction. Usually groups are used for two different languages. In
78 * group 0, a key might have two English characters, and in group 1 it might have
79 * two Hebrew characters. The Hebrew characters will be printed on the key next to
80 * the English characters.
83 * In order to use a keymap to interpret a key event, it's necessary to first
84 * convert the keyboard state into an effective group and level. This is done via a
85 * set of rules that varies widely according to type of keyboard and user
86 * configuration. The function gdk_keymap_translate_keyboard_state() accepts a
87 * keyboard state -- consisting of hardware keycode pressed, active modifiers, and
88 * active group -- applies the appropriate rules, and returns the group/level to be
89 * used to index the keymap, along with the modifiers which did not affect the
90 * group and level. i.e. it returns "unconsumed modifiers." The keyboard group may
91 * differ from the effective group used for keymap lookups because some keys don't
92 * have multiple groups - e.g. the Enter key is always in group 0 regardless of
95 * Note that gdk_keymap_translate_keyboard_state() also returns the keyval, i.e. it
96 * goes ahead and performs the keymap lookup in addition to telling you which
97 * effective group/level values were used for the lookup. #GdkEventKey already
98 * contains this keyval, however, so you don't normally need to call
99 * gdk_keymap_translate_keyboard_state() just to get the keyval.
111 static GdkModifierType gdk_keymap_real_get_modifier_mask (GdkKeymap *keymap,
112 GdkModifierIntent intent);
115 static guint signals[LAST_SIGNAL] = { 0 };
117 G_DEFINE_TYPE (GdkKeymap, gdk_keymap, G_TYPE_OBJECT)
120 gdk_keymap_class_init (GdkKeymapClass *klass)
122 GObjectClass *object_class = G_OBJECT_CLASS (klass);
124 klass->get_modifier_mask = gdk_keymap_real_get_modifier_mask;
127 * GdkKeymap::direction-changed:
128 * @keymap: the object on which the signal is emitted
130 * The ::direction-changed signal gets emitted when the direction of
131 * the keymap changes.
135 signals[DIRECTION_CHANGED] =
136 g_signal_new ("direction-changed",
137 G_OBJECT_CLASS_TYPE (object_class),
139 G_STRUCT_OFFSET (GdkKeymapClass, direction_changed),
141 g_cclosure_marshal_VOID__VOID,
145 * GdkKeymap::keys-changed:
146 * @keymap: the object on which the signal is emitted
148 * The ::keys-changed signal is emitted when the mapping represented by
153 signals[KEYS_CHANGED] =
154 g_signal_new ("keys-changed",
155 G_OBJECT_CLASS_TYPE (object_class),
157 G_STRUCT_OFFSET (GdkKeymapClass, keys_changed),
159 g_cclosure_marshal_VOID__VOID,
164 * GdkKeymap::state-changed:
165 * @keymap: the object on which the signal is emitted
167 * The ::state-changed signal is emitted when the state of the
168 * keyboard changes, e.g when Caps Lock is turned on or off.
169 * See gdk_keymap_get_caps_lock_state().
173 signals[STATE_CHANGED] =
174 g_signal_new ("state_changed",
175 G_OBJECT_CLASS_TYPE (object_class),
177 G_STRUCT_OFFSET (GdkKeymapClass, state_changed),
179 g_cclosure_marshal_VOID__VOID,
185 gdk_keymap_init (GdkKeymap *keymap)
189 /* Other key-handling stuff
193 * gdk_keyval_convert_case:
195 * @lower: (out): return location for lowercase version of @symbol
196 * @upper: (out): return location for uppercase version of @symbol
198 * Obtains the upper- and lower-case versions of the keyval @symbol.
199 * Examples of keyvals are #GDK_KEY_a, #GDK_KEY_Enter, #GDK_KEY_F1, etc.
202 gdk_keyval_convert_case (guint symbol,
206 GdkDisplayManager *manager = gdk_display_manager_get ();
208 GDK_DISPLAY_MANAGER_GET_CLASS (manager)->keyval_convert_case (manager, symbol, lower, upper);
212 * gdk_keyval_to_upper:
213 * @keyval: a key value.
215 * Converts a key value to upper case, if applicable.
217 * Returns: the upper case form of @keyval, or @keyval itself if it is already
218 * in upper case or it is not subject to case conversion.
221 gdk_keyval_to_upper (guint keyval)
225 gdk_keyval_convert_case (keyval, NULL, &result);
231 * gdk_keyval_to_lower:
232 * @keyval: a key value.
234 * Converts a key value to lower case, if applicable.
236 * Returns: the lower case form of @keyval, or @keyval itself if it is already
237 * in lower case or it is not subject to case conversion.
240 gdk_keyval_to_lower (guint keyval)
244 gdk_keyval_convert_case (keyval, &result, NULL);
250 * gdk_keyval_is_upper:
251 * @keyval: a key value.
253 * Returns %TRUE if the given key value is in upper case.
255 * Returns: %TRUE if @keyval is in upper case, or if @keyval is not subject to
259 gdk_keyval_is_upper (guint keyval)
265 gdk_keyval_convert_case (keyval, NULL, &upper_val);
266 return upper_val == keyval;
272 * gdk_keyval_is_lower:
273 * @keyval: a key value.
275 * Returns %TRUE if the given key value is in lower case.
277 * Returns: %TRUE if @keyval is in lower case, or if @keyval is not
278 * subject to case conversion.
281 gdk_keyval_is_lower (guint keyval)
287 gdk_keyval_convert_case (keyval, &lower_val, NULL);
288 return lower_val == keyval;
294 * gdk_keymap_get_default:
296 * Returns the #GdkKeymap attached to the default display.
298 * Returns: (transfer none): the #GdkKeymap attached to the default display.
301 gdk_keymap_get_default (void)
303 return gdk_keymap_get_for_display (gdk_display_get_default ());
307 * gdk_keymap_get_direction:
308 * @keymap: a #GdkKeymap
310 * Returns the direction of effective layout of the keymap.
312 * Returns: %PANGO_DIRECTION_LTR or %PANGO_DIRECTION_RTL
313 * if it can determine the direction. %PANGO_DIRECTION_NEUTRAL
317 gdk_keymap_get_direction (GdkKeymap *keymap)
319 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), PANGO_DIRECTION_LTR);
321 return GDK_KEYMAP_GET_CLASS (keymap)->get_direction (keymap);
325 * gdk_keymap_have_bidi_layouts:
326 * @keymap: a #GdkKeymap
328 * Determines if keyboard layouts for both right-to-left and left-to-right
329 * languages are in use.
331 * Returns: %TRUE if there are layouts in both directions, %FALSE otherwise
336 gdk_keymap_have_bidi_layouts (GdkKeymap *keymap)
338 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
340 return GDK_KEYMAP_GET_CLASS (keymap)->have_bidi_layouts (keymap);
344 * gdk_keymap_get_caps_lock_state:
345 * @keymap: a #GdkKeymap
347 * Returns whether the Caps Lock modifer is locked.
349 * Returns: %TRUE if Caps Lock is on
354 gdk_keymap_get_caps_lock_state (GdkKeymap *keymap)
356 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
358 return GDK_KEYMAP_GET_CLASS (keymap)->get_caps_lock_state (keymap);
362 * gdk_keymap_get_num_lock_state:
363 * @keymap: a #GdkKeymap
365 * Returns whether the Num Lock modifer is locked.
367 * Returns: %TRUE if Num Lock is on
372 gdk_keymap_get_num_lock_state (GdkKeymap *keymap)
374 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
376 return GDK_KEYMAP_GET_CLASS (keymap)->get_num_lock_state (keymap);
380 * gdk_keymap_get_modifier_state:
381 * @keymap: a #GdkKeymap
383 * Returns the current modifier state.
385 * Returns: the current modifier state.
390 gdk_keymap_get_modifier_state (GdkKeymap *keymap)
392 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
394 if (GDK_KEYMAP_GET_CLASS (keymap)->get_modifier_state)
395 return GDK_KEYMAP_GET_CLASS (keymap)->get_modifier_state (keymap);
401 * gdk_keymap_get_entries_for_keyval:
402 * @keymap: a #GdkKeymap
403 * @keyval: a keyval, such as %GDK_a, %GDK_Up, %GDK_Return, etc.
404 * @keys: (out) (array length=n_keys) (transfer full): return location
405 * for an array of #GdkKeymapKey
406 * @n_keys: return location for number of elements in returned array
408 * Obtains a list of keycode/group/level combinations that will
409 * generate @keyval. Groups and levels are two kinds of keyboard mode;
410 * in general, the level determines whether the top or bottom symbol
411 * on a key is used, and the group determines whether the left or
412 * right symbol is used. On US keyboards, the shift key changes the
413 * keyboard level, and there are no groups. A group switch key might
414 * convert a keyboard between Hebrew to English modes, for example.
415 * #GdkEventKey contains a %group field that indicates the active
416 * keyboard group. The level is computed from the modifier mask.
417 * The returned array should be freed
420 * Return value: %TRUE if keys were found and returned
423 gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
428 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
429 g_return_val_if_fail (keys != NULL, FALSE);
430 g_return_val_if_fail (n_keys != NULL, FALSE);
431 g_return_val_if_fail (keyval != 0, FALSE);
433 return GDK_KEYMAP_GET_CLASS (keymap)->get_entries_for_keyval (keymap, keyval,
438 * gdk_keymap_get_entries_for_keycode:
439 * @keymap: a #GdkKeymap
440 * @hardware_keycode: a keycode
441 * @keys: (out) (array length=n_entries) (transfer full): return
442 * location for array of #GdkKeymapKey, or %NULL
443 * @keyvals: (out) (array length=n_entries) (transfer full): return
444 * location for array of keyvals, or %NULL
445 * @n_entries: length of @keys and @keyvals
447 * Returns the keyvals bound to @hardware_keycode.
448 * The Nth #GdkKeymapKey in @keys is bound to the Nth
449 * keyval in @keyvals. Free the returned arrays with g_free().
450 * When a keycode is pressed by the user, the keyval from
451 * this list of entries is selected by considering the effective
452 * keyboard group and level. See gdk_keymap_translate_keyboard_state().
454 * Returns: %TRUE if there were any entries
457 gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
458 guint hardware_keycode,
463 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
464 g_return_val_if_fail (n_entries != NULL, FALSE);
466 return GDK_KEYMAP_GET_CLASS (keymap)->get_entries_for_keycode (keymap, hardware_keycode,
467 keys, keyvals, n_entries);
471 * gdk_keymap_lookup_key:
472 * @keymap: a #GdkKeymap
473 * @key: a #GdkKeymapKey with keycode, group, and level initialized
475 * Looks up the keyval mapped to a keycode/group/level triplet.
476 * If no keyval is bound to @key, returns 0. For normal user input,
477 * you want to use gdk_keymap_translate_keyboard_state() instead of
478 * this function, since the effective group/level may not be
479 * the same as the current keyboard state.
481 * Return value: a keyval, or 0 if none was mapped to the given @key
484 gdk_keymap_lookup_key (GdkKeymap *keymap,
485 const GdkKeymapKey *key)
487 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), 0);
488 g_return_val_if_fail (key != NULL, 0);
490 return GDK_KEYMAP_GET_CLASS (keymap)->lookup_key (keymap, key);
494 * gdk_keymap_translate_keyboard_state:
495 * @keymap: a #GdkKeymap
496 * @hardware_keycode: a keycode
497 * @state: a modifier state
498 * @group: active keyboard group
499 * @keyval: (out) (allow-none): return location for keyval, or %NULL
500 * @effective_group: (out) (allow-none): return location for effective
502 * @level: (out) (allow-none): return location for level, or %NULL
503 * @consumed_modifiers: (out) (allow-none): return location for modifiers
504 * that were used to determine the group or level, or %NULL
506 * Translates the contents of a #GdkEventKey into a keyval, effective
507 * group, and level. Modifiers that affected the translation and
508 * are thus unavailable for application use are returned in
509 * @consumed_modifiers.
510 * See <xref linkend="key-group-explanation"/> for an explanation of
511 * groups and levels. The @effective_group is the group that was
512 * actually used for the translation; some keys such as Enter are not
513 * affected by the active keyboard group. The @level is derived from
514 * @state. For convenience, #GdkEventKey already contains the translated
515 * keyval, so this function isn't as useful as you might think.
518 * @consumed_modifiers gives modifiers that should be masked out
519 * from @state when comparing this key press to a hot key. For
520 * instance, on a US keyboard, the <literal>plus</literal>
521 * symbol is shifted, so when comparing a key press to a
522 * <literal><Control>plus</literal> accelerator <Shift> should
525 * <informalexample><programlisting>
526 * /* We want to ignore irrelevant modifiers like ScrollLock */
527 * #define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)
528 * gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode,
529 * event->state, event->group,
530 * &keyval, NULL, NULL, &consumed);
531 * if (keyval == GDK_PLUS &&
532 * (event->state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK)
533 * /* Control was pressed */
534 * </programlisting></informalexample>
536 * An older interpretation @consumed_modifiers was that it contained
537 * all modifiers that might affect the translation of the key;
538 * this allowed accelerators to be stored with irrelevant consumed
539 * modifiers, by doing:</para>
540 * <informalexample><programlisting>
541 * /* XXX Don't do this XXX */
542 * if (keyval == accel_keyval &&
543 * (event->state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed))
544 * /* Accelerator was pressed */
545 * </programlisting></informalexample>
547 * However, this did not work if multi-modifier combinations were
548 * used in the keymap, since, for instance, <literal><Control></literal>
549 * would be masked out even if only <literal><Control><Alt></literal>
550 * was used in the keymap. To support this usage as well as well as
551 * possible, all <emphasis>single modifier</emphasis> combinations
552 * that could affect the key for any combination of modifiers will
553 * be returned in @consumed_modifiers; multi-modifier combinations
554 * are returned only when actually found in @state. When you store
555 * accelerators, you should always store them with consumed modifiers
556 * removed. Store <literal><Control>plus</literal>,
557 * not <literal><Control><Shift>plus</literal>,
560 * Return value: %TRUE if there was a keyval bound to the keycode/state/group
563 gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
564 guint hardware_keycode,
565 GdkModifierType state,
568 gint *effective_group,
570 GdkModifierType *consumed_modifiers)
572 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
574 return GDK_KEYMAP_GET_CLASS (keymap)->translate_keyboard_state (keymap,
585 * gdk_keymap_add_virtual_modifiers:
586 * @keymap: a #GdkKeymap
587 * @state: (inout): pointer to the modifier mask to change
589 * Maps the non-virtual modifiers (i.e Mod2, Mod3, ...) which are set
590 * in @state to the virtual modifiers (i.e. Super, Hyper and Meta) and
591 * set the corresponding bits in @state.
593 * GDK already does this before delivering key events, but for
594 * compatibility reasons, it only sets the first virtual modifier
595 * it finds, whereas this function sets all matching virtual modifiers.
597 * This function is useful when matching key events against
603 gdk_keymap_add_virtual_modifiers (GdkKeymap *keymap,
604 GdkModifierType *state)
606 g_return_if_fail (GDK_IS_KEYMAP (keymap));
608 GDK_KEYMAP_GET_CLASS (keymap)->add_virtual_modifiers (keymap, state);
612 * gdk_keymap_map_virtual_modifiers:
613 * @keymap: a #GdkKeymap
614 * @state: (inout): pointer to the modifier state to map
616 * Maps the virtual modifiers (i.e. Super, Hyper and Meta) which
617 * are set in @state to their non-virtual counterparts (i.e. Mod2,
618 * Mod3,...) and set the corresponding bits in @state.
620 * This function is useful when matching key events against
623 * Returns: %TRUE if no virtual modifiers were mapped to the
624 * same non-virtual modifier. Note that %FALSE is also returned
625 * if a virtual modifier is mapped to a non-virtual modifier that
626 * was already set in @state.
631 gdk_keymap_map_virtual_modifiers (GdkKeymap *keymap,
632 GdkModifierType *state)
634 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), FALSE);
636 return GDK_KEYMAP_GET_CLASS(keymap)->map_virtual_modifiers (keymap, state);
639 static GdkModifierType
640 gdk_keymap_real_get_modifier_mask (GdkKeymap *keymap,
641 GdkModifierIntent intent)
645 case GDK_MODIFIER_INTENT_PRIMARY_ACCELERATOR:
646 return GDK_CONTROL_MASK;
648 case GDK_MODIFIER_INTENT_CONTEXT_MENU:
651 case GDK_MODIFIER_INTENT_EXTEND_SELECTION:
652 return GDK_SHIFT_MASK;
654 case GDK_MODIFIER_INTENT_MODIFY_SELECTION:
655 return GDK_CONTROL_MASK;
657 case GDK_MODIFIER_INTENT_NO_TEXT_INPUT:
658 return GDK_MOD1_MASK | GDK_CONTROL_MASK;
660 case GDK_MODIFIER_INTENT_SHIFT_GROUP:
664 g_return_val_if_reached (0);
669 * gdk_keymap_get_modifier_mask:
670 * @keymap: a #GdkKeymap
671 * @intent: the use case for the modifier mask
673 * Returns the modifier mask the @keymap's windowing system backend
674 * uses for a particular purpose.
676 * Note that this function always returns real hardware modifiers, not
677 * virtual ones (e.g. it will return #GDK_MOD1_MASK rather than
678 * #GDK_META_MASK if the backend maps MOD1 to META), so there are use
679 * cases where the return value of this function has to be transformed
680 * by gdk_keymap_add_virtual_modifiers() in order to contain the
683 * Returns: the modifier mask used for @intent.
688 gdk_keymap_get_modifier_mask (GdkKeymap *keymap,
689 GdkModifierIntent intent)
691 g_return_val_if_fail (GDK_IS_KEYMAP (keymap), 0);
693 return GDK_KEYMAP_GET_CLASS (keymap)->get_modifier_mask (keymap, intent);
699 * @keyval: a key value
701 * Converts a key value into a symbolic name.
703 * The names are the same as those in the
704 * <filename><gdk/gdkkeysyms.h></filename> header file
705 * but without the leading "GDK_KEY_".
707 * Return value: (transfer none): a string containing the name of the key,
708 * or %NULL if @keyval is not a valid key. The string should not be
712 gdk_keyval_name (guint keyval)
714 GdkDisplayManager *manager = gdk_display_manager_get ();
716 return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->get_keyval_name (manager,
721 * gdk_keyval_from_name:
722 * @keyval_name: a key name
724 * Converts a key name to a key value.
726 * The names are the same as those in the
727 * <filename><gdk/gdkkeysyms.h></filename> header file
728 * but without the leading "GDK_KEY_".
730 * Returns: the corresponding key value, or %GDK_KEY_VoidSymbol
731 * if the key name is not a valid key
734 gdk_keyval_from_name (const gchar *keyval_name)
736 GdkDisplayManager *manager = gdk_display_manager_get ();
738 return GDK_DISPLAY_MANAGER_GET_CLASS (manager)->lookup_keyval (manager,
743 _gdk_display_manager_real_keyval_convert_case (GdkDisplayManager *manager,
748 guint xlower = symbol;
749 guint xupper = symbol;
751 /* Check for directly encoded 24-bit UCS characters: */
752 if ((symbol & 0xff000000) == 0x01000000)
755 *lower = gdk_unicode_to_keyval (g_unichar_tolower (symbol & 0x00ffffff));
757 *upper = gdk_unicode_to_keyval (g_unichar_toupper (symbol & 0x00ffffff));
763 case 0: /* Latin 1 */
764 if ((symbol >= GDK_KEY_A) && (symbol <= GDK_KEY_Z))
765 xlower += (GDK_KEY_a - GDK_KEY_A);
766 else if ((symbol >= GDK_KEY_a) && (symbol <= GDK_KEY_z))
767 xupper -= (GDK_KEY_a - GDK_KEY_A);
768 else if ((symbol >= GDK_KEY_Agrave) && (symbol <= GDK_KEY_Odiaeresis))
769 xlower += (GDK_KEY_agrave - GDK_KEY_Agrave);
770 else if ((symbol >= GDK_KEY_agrave) && (symbol <= GDK_KEY_odiaeresis))
771 xupper -= (GDK_KEY_agrave - GDK_KEY_Agrave);
772 else if ((symbol >= GDK_KEY_Ooblique) && (symbol <= GDK_KEY_Thorn))
773 xlower += (GDK_KEY_oslash - GDK_KEY_Ooblique);
774 else if ((symbol >= GDK_KEY_oslash) && (symbol <= GDK_KEY_thorn))
775 xupper -= (GDK_KEY_oslash - GDK_KEY_Ooblique);
778 case 1: /* Latin 2 */
779 /* Assume the KeySym is a legal value (ignore discontinuities) */
780 if (symbol == GDK_KEY_Aogonek)
781 xlower = GDK_KEY_aogonek;
782 else if (symbol >= GDK_KEY_Lstroke && symbol <= GDK_KEY_Sacute)
783 xlower += (GDK_KEY_lstroke - GDK_KEY_Lstroke);
784 else if (symbol >= GDK_KEY_Scaron && symbol <= GDK_KEY_Zacute)
785 xlower += (GDK_KEY_scaron - GDK_KEY_Scaron);
786 else if (symbol >= GDK_KEY_Zcaron && symbol <= GDK_KEY_Zabovedot)
787 xlower += (GDK_KEY_zcaron - GDK_KEY_Zcaron);
788 else if (symbol == GDK_KEY_aogonek)
789 xupper = GDK_KEY_Aogonek;
790 else if (symbol >= GDK_KEY_lstroke && symbol <= GDK_KEY_sacute)
791 xupper -= (GDK_KEY_lstroke - GDK_KEY_Lstroke);
792 else if (symbol >= GDK_KEY_scaron && symbol <= GDK_KEY_zacute)
793 xupper -= (GDK_KEY_scaron - GDK_KEY_Scaron);
794 else if (symbol >= GDK_KEY_zcaron && symbol <= GDK_KEY_zabovedot)
795 xupper -= (GDK_KEY_zcaron - GDK_KEY_Zcaron);
796 else if (symbol >= GDK_KEY_Racute && symbol <= GDK_KEY_Tcedilla)
797 xlower += (GDK_KEY_racute - GDK_KEY_Racute);
798 else if (symbol >= GDK_KEY_racute && symbol <= GDK_KEY_tcedilla)
799 xupper -= (GDK_KEY_racute - GDK_KEY_Racute);
802 case 2: /* Latin 3 */
803 /* Assume the KeySym is a legal value (ignore discontinuities) */
804 if (symbol >= GDK_KEY_Hstroke && symbol <= GDK_KEY_Hcircumflex)
805 xlower += (GDK_KEY_hstroke - GDK_KEY_Hstroke);
806 else if (symbol >= GDK_KEY_Gbreve && symbol <= GDK_KEY_Jcircumflex)
807 xlower += (GDK_KEY_gbreve - GDK_KEY_Gbreve);
808 else if (symbol >= GDK_KEY_hstroke && symbol <= GDK_KEY_hcircumflex)
809 xupper -= (GDK_KEY_hstroke - GDK_KEY_Hstroke);
810 else if (symbol >= GDK_KEY_gbreve && symbol <= GDK_KEY_jcircumflex)
811 xupper -= (GDK_KEY_gbreve - GDK_KEY_Gbreve);
812 else if (symbol >= GDK_KEY_Cabovedot && symbol <= GDK_KEY_Scircumflex)
813 xlower += (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
814 else if (symbol >= GDK_KEY_cabovedot && symbol <= GDK_KEY_scircumflex)
815 xupper -= (GDK_KEY_cabovedot - GDK_KEY_Cabovedot);
818 case 3: /* Latin 4 */
819 /* Assume the KeySym is a legal value (ignore discontinuities) */
820 if (symbol >= GDK_KEY_Rcedilla && symbol <= GDK_KEY_Tslash)
821 xlower += (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
822 else if (symbol >= GDK_KEY_rcedilla && symbol <= GDK_KEY_tslash)
823 xupper -= (GDK_KEY_rcedilla - GDK_KEY_Rcedilla);
824 else if (symbol == GDK_KEY_ENG)
825 xlower = GDK_KEY_eng;
826 else if (symbol == GDK_KEY_eng)
827 xupper = GDK_KEY_ENG;
828 else if (symbol >= GDK_KEY_Amacron && symbol <= GDK_KEY_Umacron)
829 xlower += (GDK_KEY_amacron - GDK_KEY_Amacron);
830 else if (symbol >= GDK_KEY_amacron && symbol <= GDK_KEY_umacron)
831 xupper -= (GDK_KEY_amacron - GDK_KEY_Amacron);
834 case 6: /* Cyrillic */
835 /* Assume the KeySym is a legal value (ignore discontinuities) */
836 if (symbol >= GDK_KEY_Serbian_DJE && symbol <= GDK_KEY_Serbian_DZE)
837 xlower -= (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
838 else if (symbol >= GDK_KEY_Serbian_dje && symbol <= GDK_KEY_Serbian_dze)
839 xupper += (GDK_KEY_Serbian_DJE - GDK_KEY_Serbian_dje);
840 else if (symbol >= GDK_KEY_Cyrillic_YU && symbol <= GDK_KEY_Cyrillic_HARDSIGN)
841 xlower -= (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
842 else if (symbol >= GDK_KEY_Cyrillic_yu && symbol <= GDK_KEY_Cyrillic_hardsign)
843 xupper += (GDK_KEY_Cyrillic_YU - GDK_KEY_Cyrillic_yu);
847 /* Assume the KeySym is a legal value (ignore discontinuities) */
848 if (symbol >= GDK_KEY_Greek_ALPHAaccent && symbol <= GDK_KEY_Greek_OMEGAaccent)
849 xlower += (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
850 else if (symbol >= GDK_KEY_Greek_alphaaccent && symbol <= GDK_KEY_Greek_omegaaccent &&
851 symbol != GDK_KEY_Greek_iotaaccentdieresis &&
852 symbol != GDK_KEY_Greek_upsilonaccentdieresis)
853 xupper -= (GDK_KEY_Greek_alphaaccent - GDK_KEY_Greek_ALPHAaccent);
854 else if (symbol >= GDK_KEY_Greek_ALPHA && symbol <= GDK_KEY_Greek_OMEGA)
855 xlower += (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);
856 else if (symbol >= GDK_KEY_Greek_alpha && symbol <= GDK_KEY_Greek_omega &&
857 symbol != GDK_KEY_Greek_finalsmallsigma)
858 xupper -= (GDK_KEY_Greek_alpha - GDK_KEY_Greek_ALPHA);