aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.hh
diff options
context:
space:
mode:
authorMark Tiefenbruck <mark@fluxbox.org>2008-01-02 21:38:09 (GMT)
committerMark Tiefenbruck <mark@fluxbox.org>2008-01-02 21:38:09 (GMT)
commit903349f47a03138eb4217c5dbfd27d2bcb6b26cd (patch)
tree0d1f139c9a977273a5c9ce66dd8dee9481698a6d /src/Keys.hh
parent6ea1ed8cfa2915a75479daec2b21513a11cd0cee (diff)
parent222128c236db06267d0cc225a9e7bbdd017bce77 (diff)
downloadfluxbox_paul-903349f47a03138eb4217c5dbfd27d2bcb6b26cd.zip
fluxbox_paul-903349f47a03138eb4217c5dbfd27d2bcb6b26cd.tar.bz2
Merge branch 'master' of fluxbox@gitfbox:fluxbox
Diffstat (limited to 'src/Keys.hh')
-rw-r--r--src/Keys.hh60
1 files changed, 11 insertions, 49 deletions
diff --git a/src/Keys.hh b/src/Keys.hh
index 226d52b..03f11e0 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -25,12 +25,9 @@
25#define KEYS_HH 25#define KEYS_HH
26 26
27#include "FbTk/NotCopyable.hh" 27#include "FbTk/NotCopyable.hh"
28#include "FbTk/RefCount.hh"
29#include "FbTk/Command.hh"
30#include "FbTk/KeyUtil.hh"
31 28
29#include <X11/Xlib.h>
32#include <string> 30#include <string>
33#include <list>
34#include <map> 31#include <map>
35 32
36 33
@@ -92,9 +89,14 @@ public:
92 @return true on success, else false 89 @return true on success, else false
93 */ 90 */
94 bool reconfigure(const char *filename); 91 bool reconfigure(const char *filename);
95 const std::string filename() const { return m_filename; } 92 const std::string& filename() const { return m_filename; }
96 void keyMode(std::string keyMode); 93 void keyMode(const std::string& keyMode);
97private: 94private:
95 class t_key; // helper class to build a 'keytree'
96 typedef std::map<std::string, t_key *> keyspace_t;
97 typedef std::map<Window, int> WindowMap;
98 typedef std::map<Window, FbTk::EventHandler*> HandlerMap;
99
98 void deleteTree(); 100 void deleteTree();
99 101
100 void grabKey(unsigned int key, unsigned int mod); 102 void grabKey(unsigned int key, unsigned int mod);
@@ -105,54 +107,14 @@ private:
105 107
106 // Load default keybindings for when there are errors loading the initial one 108 // Load default keybindings for when there are errors loading the initial one
107 void loadDefaults(); 109 void loadDefaults();
108
109 std::string m_filename;
110
111 class t_key;
112 typedef std::list<t_key*> keylist_t;
113
114 class t_key {
115 public:
116 t_key(int type, unsigned int mod, unsigned int key, int context,
117 bool isdouble);
118 t_key(t_key *k);
119 ~t_key();
120
121 t_key *find(int type_, unsigned int mod_, unsigned int key_,
122 int context_, bool isdouble_) {
123 // t_key ctor sets context_ of 0 to GLOBAL, so we must here too
124 context_ = context_ ? context_ : GLOBAL;
125 keylist_t::iterator it = keylist.begin(), it_end = keylist.end();
126 for (; it != it_end; it++) {
127 if ((*it)->type == type_ && (*it)->key == key_ &&
128 ((*it)->context & context_) > 0 &&
129 isdouble_ == (*it)->isdouble && (*it)->mod ==
130 FbTk::KeyUtil::instance().isolateModifierMask(mod_))
131 return *it;
132 }
133 return 0;
134 }
135
136
137 FbTk::RefCount<FbTk::Command> m_command;
138 int context; // ON_TITLEBAR, etc.: bitwise-or of all desired contexts
139 int type; // KeyPress or ButtonPress
140 unsigned int key; // key code or button number
141 unsigned int mod;
142 bool isdouble;
143 keylist_t keylist;
144 };
145
146 void setKeyMode(t_key *keyMode); 110 void setKeyMode(t_key *keyMode);
147 111
148 typedef std::map<std::string, t_key *> keyspace_t; 112
113 // member variables
114 std::string m_filename;
149 t_key *m_keylist; 115 t_key *m_keylist;
150 keyspace_t m_map; 116 keyspace_t m_map;
151 117
152 Display *m_display; ///< display connection
153
154 typedef std::map<Window, int> WindowMap;
155 typedef std::map<Window, FbTk::EventHandler*> HandlerMap;
156 WindowMap m_window_map; 118 WindowMap m_window_map;
157 HandlerMap m_handler_map; 119 HandlerMap m_handler_map;
158}; 120};