]>
Dogcows Code - chaz/openbox/blob - src/bindings.hh
1 // -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 2; -*-
6 @brief I dunno.. some binding stuff?
14 typedef struct Binding
{
15 unsigned int modifiers
;
18 bool operator==(struct Binding
&b2
) { return key
== b2
.key
&&
19 modifiers
== b2
.modifiers
; }
20 bool operator!=(struct Binding
&b2
) { return key
!= b2
.key
||
21 modifiers
!= b2
.modifiers
; }
22 Binding(unsigned int mod
, unsigned int k
) { modifiers
= mod
; key
= k
; }
25 typedef struct BindingTree
{
28 int id
; // the id given for the binding in add()
29 bool chain
; // true if this is a chain to another key (not an action)
31 struct BindingTree
*next_sibling
; // the next binding in the tree at the same
33 struct BindingTree
*first_child
; // the first child of this binding (next
34 // binding in a chained sequence).
35 BindingTree(int id
) : binding(0, 0) {
36 this->id
= id
; chain
= true; next_sibling
= first_child
= 0;
38 BindingTree() : binding(0, 0) {
39 this->id
= -1; chain
= true; next_sibling
= first_child
= 0;
46 typedef std::vector
<std::string
> StringVect
;
49 BindingTree _tree
;// root node of the tree (this doesn't have siblings!)
51 int find(BindingTree
*search
);
52 bool translate(const std::string
&str
, Binding
&b
);
53 BindingTree
*buildtree(const StringVect
&keylist
, int id
);
56 //! Initializes an OBBinding object
58 //! Destroys the OBBinding object
59 virtual ~OBBindings();
61 //! Adds a new binding
63 A binding will fail to be added if the binding already exists (as part of
64 a chain or not), or if any of the strings in the keylist are invalid.
65 @return true if the binding could be added; false if it could not.
67 bool add(const StringVect
&keylist
, int id
);
69 //! Removes a key binding
71 @return The id of the binding that was removed, or '< 0' if none were
74 int remove(const StringVect
&keylist
);
76 //! Removes all key bindings
79 //! Finds a keybinding and returns its id or '< 0' if it isn't found.
81 @return -1 if the keybinding was not found but does not conflict with
82 any others; -2 if the keybinding conflicts with another.
84 int find(const StringVect
&keylist
);
86 // XXX: need an exec() function or something that will be used by openbox
87 // and hold state for which chain we're in etc. (it could have a timer
88 // for reseting too...)
95 #endif // __binding_hh
This page took 0.042407 seconds and 4 git commands to generate.