aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.hh
diff options
context:
space:
mode:
authorfluxgen <fluxgen>2003-06-30 14:57:14 (GMT)
committerfluxgen <fluxgen>2003-06-30 14:57:14 (GMT)
commit24b7682033412123b3927aa4c1b7a92aef3a1a43 (patch)
treebe6ea0a2be01da12f5b9076ad5df989e2f5b9359 /src/Keys.hh
parent5c657dabaea8b7d0f7f44c73be37662ff8eff988 (diff)
downloadfluxbox-24b7682033412123b3927aa4c1b7a92aef3a1a43.zip
fluxbox-24b7682033412123b3927aa4c1b7a92aef3a1a43.tar.bz2
using new CommandParser and Commands instead of enum actions
Diffstat (limited to 'src/Keys.hh')
-rw-r--r--src/Keys.hh87
1 files changed, 16 insertions, 71 deletions
diff --git a/src/Keys.hh b/src/Keys.hh
index 99bc48d..a296200 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -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.hh,v 1.25 2003/06/15 11:38:35 rathnor Exp $ 22// $Id: Keys.hh,v 1.26 2003/06/30 14:57:14 fluxgen Exp $
23 23
24#ifndef KEYS_HH 24#ifndef KEYS_HH
25#define KEYS_HH 25#define KEYS_HH
@@ -29,47 +29,14 @@
29#include <X11/Xlib.h> 29#include <X11/Xlib.h>
30 30
31#include "NotCopyable.hh" 31#include "NotCopyable.hh"
32#include "RefCount.hh"
33namespace FbTk {
34class Command;
35};
32 36
33class Keys:private FbTk::NotCopyable { 37class Keys:private FbTk::NotCopyable {
34public: 38public:
35 /** 39
36 Key actions
37 */
38 enum KeyAction{
39 ICONIFY=0,
40 RAISE, LOWER,
41 RAISELAYER, LOWERLAYER, TOPLAYER, BOTTOMLAYER,
42 ALWAYSONTOP, ALWAYSONBOTTOM, // aliases for TOPLAYER, etc
43 CLOSE,
44 ABORTKEYCHAIN,
45 WORKSPACE,
46 WORKSPACE1, WORKSPACE2, WORKSPACE3, WORKSPACE4,
47 WORKSPACE5, WORKSPACE6, WORKSPACE7, WORKSPACE8,
48 WORKSPACE9, WORKSPACE10, WORKSPACE11, WORKSPACE12,
49 SENDTOWORKSPACE, // Send window to a workspace
50 NEXTWORKSPACE, PREVWORKSPACE,
51 LEFTWORKSPACE, RIGHTWORKSPACE,
52 KILLWINDOW, NEXTWINDOW, PREVWINDOW,
53 NEXTGROUP, PREVGROUP,
54 NEXTTAB, PREVTAB, FIRSTTAB, LASTTAB, MOVETABPREV, MOVETABNEXT,
55 ATTACHLAST, DETACHCLIENT,
56 FOCUSUP, FOCUSDOWN, FOCUSLEFT, FOCUSRIGHT,
57 SHADE, MAXIMIZE,
58 STICK, // Make Sticky
59 EXECUTE, // Run command
60 VERTMAX, // Maximize vertical
61 HORIZMAX, // Maximize horizontal
62 NUDGERIGHT, NUDGELEFT,NUDGEUP, NUDGEDOWN,
63 BIGNUDGERIGHT, BIGNUDGELEFT, BIGNUDGEUP, BIGNUDGEDOWN,
64 HORIZINC, VERTINC, HORIZDEC, VERTDEC,
65 TOGGLEDECOR,// toggle visibility of decor (title, frame, handles)
66 TOGGLETAB, // toggle visibilty of tab
67 ROOTMENU, // pop up rootmenu
68 RECONFIGURE, // reload configuration
69 RESTART, // restart fluxbox
70 QUIT, // Die, quit, logout, shutdown
71 LASTKEYGRAB //mark end of keygrabbs
72 };
73 /** 40 /**
74 Constructor 41 Constructor
75 @param display display connection 42 @param display display connection
@@ -96,29 +63,14 @@ public:
96 */ 63 */
97 bool load(const char *filename=0); 64 bool load(const char *filename=0);
98 /** 65 /**
99 Determine action from XKeyEvent 66 do action from XKeyEvent
100 @return KeyAction value
101 */ 67 */
102 KeyAction getAction(XKeyEvent *ke); 68 void doAction(XKeyEvent &ke);
103 /** 69 /**
104 Reload configuration from filename 70 Reload configuration from filename
105 @return true on success, else false 71 @return true on success, else false
106 */ 72 */
107 bool reconfigure(const char *filename); 73 bool reconfigure(const char *filename);
108 /**
109 Get string value of the KeyAction enum value
110 @return string of action
111 */
112 const char *getActionStr(KeyAction action);
113 /**
114 Get command to execute (key action EXECUTE/RESTART)
115 @return string to command
116 */
117 const std::string &getExecCommand() { return m_execcmdstring; }
118 /**
119 @return number of parameters
120 */
121 int getParam() const { return m_param; }
122 74
123private: 75private:
124 void deleteTree(); 76 void deleteTree();
@@ -144,7 +96,8 @@ private:
144 96
145 class t_key { 97 class t_key {
146 public: 98 public:
147 t_key(unsigned int key, unsigned int mod, KeyAction action_ = Keys::LASTKEYGRAB); 99 t_key(unsigned int key, unsigned int mod,
100 FbTk::RefCount<FbTk::Command> command = FbTk::RefCount<FbTk::Command>(0));
148 t_key(t_key *k); 101 t_key(t_key *k);
149 ~t_key(); 102 ~t_key();
150 103
@@ -155,25 +108,24 @@ private:
155 } 108 }
156 return 0; 109 return 0;
157 } 110 }
158 inline t_key *find(XKeyEvent *ke) { 111 inline t_key *find(XKeyEvent &ke) {
159 for (unsigned int i=0; i<keylist.size(); i++) { 112 for (unsigned int i=0; i<keylist.size(); i++) {
160 if (keylist[i]->key == ke->keycode && keylist[i]->mod == ke->state) 113 if (keylist[i]->key == ke.keycode && keylist[i]->mod == ke.state)
161 return keylist[i]; 114 return keylist[i];
162 } 115 }
163 return 0; 116 return 0;
164 } 117 }
165 118
166 inline bool operator == (XKeyEvent *ke) { 119 inline bool operator == (XKeyEvent &ke) const {
167 return (mod == ke->state && key == ke->keycode); 120 return (mod == ke.state && key == ke.keycode);
168 } 121 }
169 122
170 KeyAction action; 123 FbTk::RefCount<FbTk::Command> m_command;
171 unsigned int key; 124 unsigned int key;
172 unsigned int mod; 125 unsigned int mod;
173 std::vector<t_key *> keylist; 126 std::vector<t_key *> keylist;
174 std::string execcommand;
175 int param; // parameter to comands
176 }; 127 };
128
177 /** 129 /**
178 merge two linked list 130 merge two linked list
179 @return true on success, else false 131 @return true on success, else false
@@ -187,15 +139,8 @@ private:
187 void showKeyTree(t_key *key, unsigned int w=0); 139 void showKeyTree(t_key *key, unsigned int w=0);
188#endif //DEBUG 140#endif //DEBUG
189 141
190 struct t_actionstr{
191 const char *string;
192 KeyAction action;
193 };
194
195 int m_capslock_mod, m_numlock_mod, m_scrolllock_mod; ///< modifiers 142 int m_capslock_mod, m_numlock_mod, m_scrolllock_mod; ///< modifiers
196 143
197 static t_actionstr m_actionlist[];
198
199 std::vector<t_key *> m_keylist; 144 std::vector<t_key *> m_keylist;
200 t_key *m_abortkey; ///< abortkey for keygrabbing chain 145 t_key *m_abortkey; ///< abortkey for keygrabbing chain
201 std::string m_execcmdstring; ///< copy of the execcommandstring 146 std::string m_execcmdstring; ///< copy of the execcommandstring