1 #ifndef SEEN_MODIFIER_FNS_H
2 #define SEEN_MODIFIER_FNS_H
4 /** \file
5 * Functions on GdkEventKey.state that test modifier keys.
6 *
7 * The MOD__SHIFT macro in macros.h is equivalent to mod_shift(event-\>key.state).
8 */
10 /*
11 * Hereby placed in public domain.
12 */
14 #include <gdk/gdktypes.h>
15 #include <glib/gtypes.h>
17 inline bool
18 mod_shift(guint const state)
19 {
20 return state & GDK_SHIFT_MASK;
21 }
23 inline bool
24 mod_ctrl(guint const state)
25 {
26 return state & GDK_CONTROL_MASK;
27 }
29 inline bool
30 mod_alt(guint const state)
31 {
32 return state & GDK_MOD1_MASK;
33 }
35 inline bool
36 mod_shift_only(guint const state)
37 {
38 return (state & GDK_SHIFT_MASK) && !(state & GDK_CONTROL_MASK) && !(state & GDK_MOD1_MASK);
39 }
41 inline bool
42 mod_ctrl_only(guint const state)
43 {
44 return !(state & GDK_SHIFT_MASK) && (state & GDK_CONTROL_MASK) && !(state & GDK_MOD1_MASK);
45 }
47 inline bool
48 mod_alt_only(guint const state)
49 {
50 return !(state & GDK_SHIFT_MASK) && !(state & GDK_CONTROL_MASK) && (state & GDK_MOD1_MASK);
51 }
53 #endif /* !SEEN_MODIFIER_FNS_H */
55 /*
56 Local Variables:
57 mode:c++
58 c-file-style:"stroustrup"
59 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
60 indent-tabs-mode:nil
61 fill-column:99
62 End:
63 */
64 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :