1/* GDK - The GIMP Drawing Kit
2 * Copyright (C) 2010 Red Hat, Inc
3 *
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.
8 *
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.
13 *
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/>.
16 */
17
18#ifndef __GDK_KEYS_PRIVATE_H__
19#define __GDK_KEYS_PRIVATE_H__
20
21#include "gdkkeys.h"
22
23#include "gdkenums.h"
24
25G_BEGIN_DECLS
26
27#define GDK_TYPE_KEYMAP (gdk_keymap_get_type ())
28#define GDK_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_CAST ((object), GDK_TYPE_KEYMAP, GdkKeymap))
29#define GDK_IS_KEYMAP(object) (G_TYPE_CHECK_INSTANCE_TYPE ((object), GDK_TYPE_KEYMAP))
30#define GDK_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GDK_TYPE_KEYMAP, GdkKeymapClass))
31#define GDK_IS_KEYMAP_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GDK_TYPE_KEYMAP))
32#define GDK_KEYMAP_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GDK_TYPE_KEYMAP, GdkKeymapClass))
33
34typedef struct _GdkKeymap GdkKeymap;
35typedef struct _GdkKeymapClass GdkKeymapClass;
36
37struct _GdkKeymapClass
38{
39 GObjectClass parent_class;
40
41 PangoDirection (* get_direction) (GdkKeymap *keymap);
42 gboolean (* have_bidi_layouts) (GdkKeymap *keymap);
43 gboolean (* get_caps_lock_state) (GdkKeymap *keymap);
44 gboolean (* get_num_lock_state) (GdkKeymap *keymap);
45 gboolean (* get_scroll_lock_state) (GdkKeymap *keymap);
46 gboolean (* get_entries_for_keyval) (GdkKeymap *keymap,
47 guint keyval,
48 GArray *array);
49 gboolean (* get_entries_for_keycode) (GdkKeymap *keymap,
50 guint hardware_keycode,
51 GdkKeymapKey **keys,
52 guint **keyvals,
53 int *n_entries);
54 guint (* lookup_key) (GdkKeymap *keymap,
55 const GdkKeymapKey *key);
56 gboolean (* translate_keyboard_state) (GdkKeymap *keymap,
57 guint hardware_keycode,
58 GdkModifierType state,
59 int group,
60 guint *keyval,
61 int *effective_group,
62 int *level,
63 GdkModifierType *consumed_modifiers);
64 guint (* get_modifier_state) (GdkKeymap *keymap);
65
66
67 /* Signals */
68 void (*direction_changed) (GdkKeymap *keymap);
69 void (*keys_changed) (GdkKeymap *keymap);
70 void (*state_changed) (GdkKeymap *keymap);
71};
72
73struct _GdkKeymap
74{
75 GObject parent_instance;
76 GdkDisplay *display;
77
78 /* We cache an array of GdkKeymapKey entries for keyval -> keycode
79 * lookup. Position 0 is unused.
80 *
81 * The hash table maps keyvals to values that have the number of keys
82 * in the low 8 bits, and the position in the array in the rest.
83 *
84 * The cache is cleared before ::keys-changed is emitted.
85 */
86 GArray *cached_keys;
87 GHashTable *cache;
88};
89
90GType gdk_keymap_get_type (void) G_GNUC_CONST;
91
92GdkDisplay * gdk_keymap_get_display (GdkKeymap *keymap);
93
94guint gdk_keymap_lookup_key (GdkKeymap *keymap,
95 const GdkKeymapKey *key);
96gboolean gdk_keymap_translate_keyboard_state (GdkKeymap *keymap,
97 guint hardware_keycode,
98 GdkModifierType state,
99 int group,
100 guint *keyval,
101 int *effective_group,
102 int *level,
103 GdkModifierType *consumed_modifiers);
104gboolean gdk_keymap_get_entries_for_keyval (GdkKeymap *keymap,
105 guint keyval,
106 GdkKeymapKey **keys,
107 int *n_keys);
108gboolean gdk_keymap_get_entries_for_keycode (GdkKeymap *keymap,
109 guint hardware_keycode,
110 GdkKeymapKey **keys,
111 guint **keyvals,
112 int *n_entries);
113
114PangoDirection gdk_keymap_get_direction (GdkKeymap *keymap);
115gboolean gdk_keymap_have_bidi_layouts (GdkKeymap *keymap);
116gboolean gdk_keymap_get_caps_lock_state (GdkKeymap *keymap);
117gboolean gdk_keymap_get_num_lock_state (GdkKeymap *keymap);
118gboolean gdk_keymap_get_scroll_lock_state (GdkKeymap *keymap);
119guint gdk_keymap_get_modifier_state (GdkKeymap *keymap);
120
121void gdk_keymap_get_cached_entries_for_keyval (GdkKeymap *keymap,
122 guint keyval,
123 GdkKeymapKey **keys,
124 guint *n_keys);
125
126G_END_DECLS
127
128#endif
129

source code of gtk/gdk/gdkkeysprivate.h