aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/Keys.cc')
-rw-r--r--src/Keys.cc49
1 files changed, 23 insertions, 26 deletions
diff --git a/src/Keys.cc b/src/Keys.cc
index a0aabd5..196c5e0 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -19,7 +19,7 @@
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE. 20// DEALINGS IN THE SOFTWARE.
21 21
22//$Id: Keys.cc,v 1.35 2003/07/02 05:42:21 fluxgen Exp $ 22//$Id: Keys.cc,v 1.36 2003/08/19 16:19:28 fluxgen Exp $
23 23
24 24
25#include "Keys.hh" 25#include "Keys.hh"
@@ -71,15 +71,16 @@
71 71
72using namespace std; 72using namespace std;
73 73
74int Keys::s_capslock_mod = 0;
75int Keys::s_numlock_mod = 0;
76int Keys::s_scrolllock_mod = 0;
77
74Keys::Keys(const char *filename): 78Keys::Keys(const char *filename):
75 m_capslock_mod(0),
76 m_numlock_mod(0),
77 m_scrolllock_mod(0),
78 m_abortkey(0),
79 m_display(FbTk::App::instance()->display()), 79 m_display(FbTk::App::instance()->display()),
80 m_modmap(0) 80 m_modmap(0) {
81{ 81
82 loadModmap(); 82 loadModmap();
83
83 if (filename != 0) 84 if (filename != 0)
84 load(filename); 85 load(filename);
85} 86}
@@ -92,17 +93,13 @@ Keys::~Keys() {
92 deleteTree(); 93 deleteTree();
93} 94}
94 95
95/// Destroys the keytree and m_abortkey 96/// Destroys the keytree
96void Keys::deleteTree() { 97void Keys::deleteTree() {
97 while (!m_keylist.empty()) { 98 while (!m_keylist.empty()) {
98 if (m_keylist.back() && m_keylist.back() != 0) 99 if (m_keylist.back())
99 delete m_keylist.back(); 100 delete m_keylist.back();
100 m_keylist.pop_back(); 101 m_keylist.pop_back();
101 } 102 }
102 if (m_abortkey) {
103 delete m_abortkey;
104 m_abortkey=0;
105 }
106} 103}
107 104
108/// Ungrabs the keys 105/// Ungrabs the keys
@@ -243,35 +240,35 @@ void Keys::grabKey(unsigned int key, unsigned int mod) {
243 // Grab with numlock, capslock and scrlock 240 // Grab with numlock, capslock and scrlock
244 241
245 //numlock 242 //numlock
246 XGrabKey(m_display, key, mod|m_numlock_mod, 243 XGrabKey(m_display, key, mod|s_numlock_mod,
247 root, True, 244 root, True,
248 GrabModeAsync, GrabModeAsync); 245 GrabModeAsync, GrabModeAsync);
249 //scrolllock 246 //scrolllock
250 XGrabKey(m_display, key, mod|m_scrolllock_mod, 247 XGrabKey(m_display, key, mod|s_scrolllock_mod,
251 root, True, 248 root, True,
252 GrabModeAsync, GrabModeAsync); 249 GrabModeAsync, GrabModeAsync);
253 //capslock 250 //capslock
254 XGrabKey(m_display, key, mod|m_capslock_mod, 251 XGrabKey(m_display, key, mod|s_capslock_mod,
255 root, True, 252 root, True,
256 GrabModeAsync, GrabModeAsync); 253 GrabModeAsync, GrabModeAsync);
257 254
258 //capslock+numlock 255 //capslock+numlock
259 XGrabKey(m_display, key, mod|m_capslock_mod|m_numlock_mod, 256 XGrabKey(m_display, key, mod|s_capslock_mod|s_numlock_mod,
260 root, True, 257 root, True,
261 GrabModeAsync, GrabModeAsync); 258 GrabModeAsync, GrabModeAsync);
262 259
263 //capslock+scrolllock 260 //capslock+scrolllock
264 XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod, 261 XGrabKey(m_display, key, mod|s_capslock_mod|s_scrolllock_mod,
265 root, True, 262 root, True,
266 GrabModeAsync, GrabModeAsync); 263 GrabModeAsync, GrabModeAsync);
267 264
268 //capslock+numlock+scrolllock 265 //capslock+numlock+scrolllock
269 XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod|m_numlock_mod, 266 XGrabKey(m_display, key, mod|s_capslock_mod|s_scrolllock_mod|s_numlock_mod,
270 root, True, 267 root, True,
271 GrabModeAsync, GrabModeAsync); 268 GrabModeAsync, GrabModeAsync);
272 269
273 //numlock+scrollLock 270 //numlock+scrollLock
274 XGrabKey(m_display, key, mod|m_numlock_mod|m_scrolllock_mod, 271 XGrabKey(m_display, key, mod|s_numlock_mod|s_scrolllock_mod,
275 root, True, 272 root, True,
276 GrabModeAsync, GrabModeAsync); 273 GrabModeAsync, GrabModeAsync);
277 274
@@ -287,10 +284,10 @@ unsigned int Keys::getModifier(const char *modstr) {
287 if (!modstr) 284 if (!modstr)
288 return 0; 285 return 0;
289 struct t_modlist{ 286 struct t_modlist{
290 char *string; 287 char *str;
291 unsigned int mask; 288 unsigned int mask;
292 bool operator == (const char *modstr) { 289 bool operator == (const char *modstr) {
293 return (strcasecmp(string, modstr) == 0 && mask !=0); 290 return (strcasecmp(str, modstr) == 0 && mask !=0);
294 } 291 }
295 } modlist[] = { 292 } modlist[] = {
296 {"SHIFT", ShiftMask}, 293 {"SHIFT", ShiftMask},
@@ -304,7 +301,7 @@ unsigned int Keys::getModifier(const char *modstr) {
304 }; 301 };
305 302
306 // find mod mask string 303 // find mod mask string
307 for (unsigned int i=0; modlist[i].string!=0; i++) { 304 for (unsigned int i=0; modlist[i].str !=0; i++) {
308 if (modlist[i] == modstr) 305 if (modlist[i] == modstr)
309 return modlist[i].mask; 306 return modlist[i].mask;
310 } 307 }
@@ -480,13 +477,13 @@ void Keys::loadModmap() {
480 477
481 switch (ks) { 478 switch (ks) {
482 case XK_Caps_Lock: 479 case XK_Caps_Lock:
483 m_capslock_mod = mods[i]; 480 s_capslock_mod = mods[i];
484 break; 481 break;
485 case XK_Scroll_Lock: 482 case XK_Scroll_Lock:
486 m_scrolllock_mod = mods[i]; 483 s_scrolllock_mod = mods[i];
487 break; 484 break;
488 case XK_Num_Lock: 485 case XK_Num_Lock:
489 m_numlock_mod = mods[i]; 486 s_numlock_mod = mods[i];
490 break; 487 break;
491 } 488 }
492 } 489 }