From ce77642a0eb1901304cc56a879d6d2e21612c850 Mon Sep 17 00:00:00 2001 From: fluxgen Date: Tue, 19 Aug 2003 16:19:28 +0000 Subject: cleaning --- src/Keys.cc | 49 +++++++++++++++++++++++-------------------------- src/Keys.hh | 22 +++++++--------------- 2 files changed, 30 insertions(+), 41 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 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -//$Id: Keys.cc,v 1.35 2003/07/02 05:42:21 fluxgen Exp $ +//$Id: Keys.cc,v 1.36 2003/08/19 16:19:28 fluxgen Exp $ #include "Keys.hh" @@ -71,15 +71,16 @@ using namespace std; +int Keys::s_capslock_mod = 0; +int Keys::s_numlock_mod = 0; +int Keys::s_scrolllock_mod = 0; + Keys::Keys(const char *filename): - m_capslock_mod(0), - m_numlock_mod(0), - m_scrolllock_mod(0), - m_abortkey(0), m_display(FbTk::App::instance()->display()), - m_modmap(0) -{ + m_modmap(0) { + loadModmap(); + if (filename != 0) load(filename); } @@ -92,17 +93,13 @@ Keys::~Keys() { deleteTree(); } -/// Destroys the keytree and m_abortkey +/// Destroys the keytree void Keys::deleteTree() { while (!m_keylist.empty()) { - if (m_keylist.back() && m_keylist.back() != 0) + if (m_keylist.back()) delete m_keylist.back(); m_keylist.pop_back(); } - if (m_abortkey) { - delete m_abortkey; - m_abortkey=0; - } } /// Ungrabs the keys @@ -243,35 +240,35 @@ void Keys::grabKey(unsigned int key, unsigned int mod) { // Grab with numlock, capslock and scrlock //numlock - XGrabKey(m_display, key, mod|m_numlock_mod, + XGrabKey(m_display, key, mod|s_numlock_mod, root, True, GrabModeAsync, GrabModeAsync); //scrolllock - XGrabKey(m_display, key, mod|m_scrolllock_mod, + XGrabKey(m_display, key, mod|s_scrolllock_mod, root, True, GrabModeAsync, GrabModeAsync); //capslock - XGrabKey(m_display, key, mod|m_capslock_mod, + XGrabKey(m_display, key, mod|s_capslock_mod, root, True, GrabModeAsync, GrabModeAsync); //capslock+numlock - XGrabKey(m_display, key, mod|m_capslock_mod|m_numlock_mod, + XGrabKey(m_display, key, mod|s_capslock_mod|s_numlock_mod, root, True, GrabModeAsync, GrabModeAsync); //capslock+scrolllock - XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod, + XGrabKey(m_display, key, mod|s_capslock_mod|s_scrolllock_mod, root, True, GrabModeAsync, GrabModeAsync); //capslock+numlock+scrolllock - XGrabKey(m_display, key, mod|m_capslock_mod|m_scrolllock_mod|m_numlock_mod, + XGrabKey(m_display, key, mod|s_capslock_mod|s_scrolllock_mod|s_numlock_mod, root, True, GrabModeAsync, GrabModeAsync); //numlock+scrollLock - XGrabKey(m_display, key, mod|m_numlock_mod|m_scrolllock_mod, + XGrabKey(m_display, key, mod|s_numlock_mod|s_scrolllock_mod, root, True, GrabModeAsync, GrabModeAsync); @@ -287,10 +284,10 @@ unsigned int Keys::getModifier(const char *modstr) { if (!modstr) return 0; struct t_modlist{ - char *string; + char *str; unsigned int mask; bool operator == (const char *modstr) { - return (strcasecmp(string, modstr) == 0 && mask !=0); + return (strcasecmp(str, modstr) == 0 && mask !=0); } } modlist[] = { {"SHIFT", ShiftMask}, @@ -304,7 +301,7 @@ unsigned int Keys::getModifier(const char *modstr) { }; // find mod mask string - for (unsigned int i=0; modlist[i].string!=0; i++) { + for (unsigned int i=0; modlist[i].str !=0; i++) { if (modlist[i] == modstr) return modlist[i].mask; } @@ -480,13 +477,13 @@ void Keys::loadModmap() { switch (ks) { case XK_Caps_Lock: - m_capslock_mod = mods[i]; + s_capslock_mod = mods[i]; break; case XK_Scroll_Lock: - m_scrolllock_mod = mods[i]; + s_scrolllock_mod = mods[i]; break; case XK_Num_Lock: - m_numlock_mod = mods[i]; + s_numlock_mod = mods[i]; break; } } diff --git a/src/Keys.hh b/src/Keys.hh index a296200..efd6331 100644 --- a/src/Keys.hh +++ b/src/Keys.hh @@ -1,5 +1,5 @@ // Keys.hh for Fluxbox - an X11 Window manager -// Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen at linuxmail.org) +// Copyright (c) 2001 - 2003 Henrik Kinnunen (fluxgen at users.sourceforge.net) // // Permission is hereby granted, free of charge, to any person obtaining a // copy of this software and associated documentation files (the "Software"), @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: Keys.hh,v 1.26 2003/06/30 14:57:14 fluxgen Exp $ +// $Id: Keys.hh,v 1.27 2003/08/19 16:18:54 fluxgen Exp $ #ifndef KEYS_HH #define KEYS_HH @@ -52,7 +52,7 @@ public: */ static unsigned int cleanMods(unsigned int mods) //remove numlock, capslock and scrolllock - { return mods & (~Mod2Mask & ~Mod5Mask & ~LockMask);} + { return mods & (~s_capslock_mod & ~s_numlock_mod & ~s_scrolllock_mod); } unsigned int keycodeToModmask(unsigned int keycode); void loadModmap(); @@ -132,21 +132,13 @@ private: */ bool mergeTree(t_key *newtree, t_key *basetree=0); -#ifdef DEBUG - /// debug function - void showTree(); - /// debug function - void showKeyTree(t_key *key, unsigned int w=0); -#endif //DEBUG - - int m_capslock_mod, m_numlock_mod, m_scrolllock_mod; ///< modifiers + static int s_capslock_mod, s_numlock_mod, s_scrolllock_mod; ///< modifiers std::vector m_keylist; - t_key *m_abortkey; ///< abortkey for keygrabbing chain std::string m_execcmdstring; ///< copy of the execcommandstring int m_param; ///< copy of the param argument - Display *m_display; ///< display connection - XModifierKeymap *m_modmap; // Modifier->keycode mapping + Display *m_display; ///< display connection + XModifierKeymap *m_modmap; ///< Modifier->keycode mapping }; -#endif // _KEYS_HH_ +#endif // KEYS_HH -- cgit v0.11.2