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, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
21 * Modified by the GTK+ Team and others 1997-2000. See the AUTHORS
22 * file for a list of people on the GTK+ Team. See the ChangeLog
23 * files for a list of changes. These files are distributed with
24 * GTK+ at ftp://ftp.gtk.org/pub/gtk/.
29 #include "gdkdisplay.h"
39 static guint signals[LAST_SIGNAL] = { 0 };
41 G_DEFINE_TYPE (GdkKeymap, gdk_keymap, G_TYPE_OBJECT)
44 gdk_keymap_class_init (GdkKeymapClass *klass)
46 GObjectClass *object_class = G_OBJECT_CLASS (klass);
49 * GdkKeymap::direction-changed:
50 * @keymap: the object on which the signal is emitted
52 * The ::direction_changed signal gets emitted when the direction of
57 signals[DIRECTION_CHANGED] =
58 g_signal_new ("direction_changed",
59 G_OBJECT_CLASS_TYPE (object_class),
61 G_STRUCT_OFFSET (GdkKeymapClass, direction_changed),
63 g_cclosure_marshal_VOID__VOID,
67 * GdkKeymap::keys-changed:
68 * @keymap: the object on which the signal is emitted
70 * The ::keys_changed signal is emitted when the mapping represented by
75 signals[KEYS_CHANGED] =
76 g_signal_new ("keys_changed",
77 G_OBJECT_CLASS_TYPE (object_class),
79 G_STRUCT_OFFSET (GdkKeymapClass, keys_changed),
81 g_cclosure_marshal_VOID__VOID,
87 gdk_keymap_init (GdkKeymap *keymap)
91 /* Other key-handling stuff
94 #ifndef HAVE_XCONVERTCASE
95 #include "gdkkeysyms.h"
97 /* compatibility function from X11R6.3, since XConvertCase is not
101 * gdk_keyval_convert_case:
103 * @lower: return location for lowercase version of @symbol
104 * @upper: return location for uppercase version of @symbol
106 * Obtains the upper- and lower-case versions of the keyval @symbol.
107 * Examples of keyvals are #GDK_a, #GDK_Enter, #GDK_F1, etc.
111 gdk_keyval_convert_case (guint symbol,
115 guint xlower = symbol;
116 guint xupper = symbol;
118 /* Check for directly encoded 24-bit UCS characters: */
119 if ((symbol & 0xff000000) == 0x01000000)
122 *lower = gdk_unicode_to_keyval (g_unichar_tolower (symbol & 0x00ffffff));
124 *upper = gdk_unicode_to_keyval (g_unichar_toupper (symbol & 0x00ffffff));
130 case 0: /* Latin 1 */
131 if ((symbol >= GDK_A) && (symbol <= GDK_Z))
132 xlower += (GDK_a - GDK_A);
133 else if ((symbol >= GDK_a) && (symbol <= GDK_z))
134 xupper -= (GDK_a - GDK_A);
135 else if ((symbol >= GDK_Agrave) && (symbol <= GDK_Odiaeresis))
136 xlower += (GDK_agrave - GDK_Agrave);
137 else if ((symbol >= GDK_agrave) && (symbol <= GDK_odiaeresis))
138 xupper -= (GDK_agrave - GDK_Agrave);
139 else if ((symbol >= GDK_Ooblique) && (symbol <= GDK_Thorn))
140 xlower += (GDK_oslash - GDK_Ooblique);
141 else if ((symbol >= GDK_oslash) && (symbol <= GDK_thorn))
142 xupper -= (GDK_oslash - GDK_Ooblique);
145 case 1: /* Latin 2 */
146 /* Assume the KeySym is a legal value (ignore discontinuities) */
147 if (symbol == GDK_Aogonek)
148 xlower = GDK_aogonek;
149 else if (symbol >= GDK_Lstroke && symbol <= GDK_Sacute)
150 xlower += (GDK_lstroke - GDK_Lstroke);
151 else if (symbol >= GDK_Scaron && symbol <= GDK_Zacute)
152 xlower += (GDK_scaron - GDK_Scaron);
153 else if (symbol >= GDK_Zcaron && symbol <= GDK_Zabovedot)
154 xlower += (GDK_zcaron - GDK_Zcaron);
155 else if (symbol == GDK_aogonek)
156 xupper = GDK_Aogonek;
157 else if (symbol >= GDK_lstroke && symbol <= GDK_sacute)
158 xupper -= (GDK_lstroke - GDK_Lstroke);
159 else if (symbol >= GDK_scaron && symbol <= GDK_zacute)
160 xupper -= (GDK_scaron - GDK_Scaron);
161 else if (symbol >= GDK_zcaron && symbol <= GDK_zabovedot)
162 xupper -= (GDK_zcaron - GDK_Zcaron);
163 else if (symbol >= GDK_Racute && symbol <= GDK_Tcedilla)
164 xlower += (GDK_racute - GDK_Racute);
165 else if (symbol >= GDK_racute && symbol <= GDK_tcedilla)
166 xupper -= (GDK_racute - GDK_Racute);
169 case 2: /* Latin 3 */
170 /* Assume the KeySym is a legal value (ignore discontinuities) */
171 if (symbol >= GDK_Hstroke && symbol <= GDK_Hcircumflex)
172 xlower += (GDK_hstroke - GDK_Hstroke);
173 else if (symbol >= GDK_Gbreve && symbol <= GDK_Jcircumflex)
174 xlower += (GDK_gbreve - GDK_Gbreve);
175 else if (symbol >= GDK_hstroke && symbol <= GDK_hcircumflex)
176 xupper -= (GDK_hstroke - GDK_Hstroke);
177 else if (symbol >= GDK_gbreve && symbol <= GDK_jcircumflex)
178 xupper -= (GDK_gbreve - GDK_Gbreve);
179 else if (symbol >= GDK_Cabovedot && symbol <= GDK_Scircumflex)
180 xlower += (GDK_cabovedot - GDK_Cabovedot);
181 else if (symbol >= GDK_cabovedot && symbol <= GDK_scircumflex)
182 xupper -= (GDK_cabovedot - GDK_Cabovedot);
185 case 3: /* Latin 4 */
186 /* Assume the KeySym is a legal value (ignore discontinuities) */
187 if (symbol >= GDK_Rcedilla && symbol <= GDK_Tslash)
188 xlower += (GDK_rcedilla - GDK_Rcedilla);
189 else if (symbol >= GDK_rcedilla && symbol <= GDK_tslash)
190 xupper -= (GDK_rcedilla - GDK_Rcedilla);
191 else if (symbol == GDK_ENG)
193 else if (symbol == GDK_eng)
195 else if (symbol >= GDK_Amacron && symbol <= GDK_Umacron)
196 xlower += (GDK_amacron - GDK_Amacron);
197 else if (symbol >= GDK_amacron && symbol <= GDK_umacron)
198 xupper -= (GDK_amacron - GDK_Amacron);
201 case 6: /* Cyrillic */
202 /* Assume the KeySym is a legal value (ignore discontinuities) */
203 if (symbol >= GDK_Serbian_DJE && symbol <= GDK_Serbian_DZE)
204 xlower -= (GDK_Serbian_DJE - GDK_Serbian_dje);
205 else if (symbol >= GDK_Serbian_dje && symbol <= GDK_Serbian_dze)
206 xupper += (GDK_Serbian_DJE - GDK_Serbian_dje);
207 else if (symbol >= GDK_Cyrillic_YU && symbol <= GDK_Cyrillic_HARDSIGN)
208 xlower -= (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
209 else if (symbol >= GDK_Cyrillic_yu && symbol <= GDK_Cyrillic_hardsign)
210 xupper += (GDK_Cyrillic_YU - GDK_Cyrillic_yu);
214 /* Assume the KeySym is a legal value (ignore discontinuities) */
215 if (symbol >= GDK_Greek_ALPHAaccent && symbol <= GDK_Greek_OMEGAaccent)
216 xlower += (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
217 else if (symbol >= GDK_Greek_alphaaccent && symbol <= GDK_Greek_omegaaccent &&
218 symbol != GDK_Greek_iotaaccentdieresis &&
219 symbol != GDK_Greek_upsilonaccentdieresis)
220 xupper -= (GDK_Greek_alphaaccent - GDK_Greek_ALPHAaccent);
221 else if (symbol >= GDK_Greek_ALPHA && symbol <= GDK_Greek_OMEGA)
222 xlower += (GDK_Greek_alpha - GDK_Greek_ALPHA);
223 else if (symbol >= GDK_Greek_alpha && symbol <= GDK_Greek_omega &&
224 symbol != GDK_Greek_finalsmallsigma)
225 xupper -= (GDK_Greek_alpha - GDK_Greek_ALPHA);
237 gdk_keyval_to_upper (guint keyval)
241 gdk_keyval_convert_case (keyval, NULL, &result);
247 gdk_keyval_to_lower (guint keyval)
251 gdk_keyval_convert_case (keyval, &result, NULL);
257 gdk_keyval_is_upper (guint keyval)
263 gdk_keyval_convert_case (keyval, NULL, &upper_val);
264 return upper_val == keyval;
270 gdk_keyval_is_lower (guint keyval)
276 gdk_keyval_convert_case (keyval, &lower_val, NULL);
277 return lower_val == keyval;
283 * gdk_keymap_get_default:
284 * @returns: the #GdkKeymap attached to the default display.
286 * Returns the #GdkKeymap attached to the default display.
289 gdk_keymap_get_default (void)
291 return gdk_keymap_get_for_display (gdk_display_get_default ());
294 #define __GDK_KEYS_C__
295 #include "gdkaliasdef.c"