aboutsummaryrefslogtreecommitdiff
path: root/src/Keys.hh
diff options
context:
space:
mode:
Diffstat (limited to 'src/Keys.hh')
-rw-r--r--src/Keys.hh143
1 files changed, 105 insertions, 38 deletions
diff --git a/src/Keys.hh b/src/Keys.hh
index 3b19aaa..3351668 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -1,4 +1,4 @@
1// Key2.hh for Fluxbox - an X11 Window manager 1// Keys.hh for Fluxbox - an X11 Window manager
2// Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org) 2// Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org)
3// 3//
4// Permission is hereby granted, free of charge, to any person obtaining a 4// Permission is hereby granted, free of charge, to any person obtaining a
@@ -18,55 +18,112 @@
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
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#ifndef _KEYS_HH_ 21
22#define _KEYS_HH_ 22// $Id: Keys.hh,v 1.15 2002/08/04 15:55:13 fluxgen Exp $
23
24#ifndef KEYS_HH
25#define KEYS_HH
23 26
24#include <string> 27#include <string>
25#include <vector> 28#include <vector>
26 29#include <X11/Xlib.h>
30
27class Keys 31class Keys
28{ 32{
29public: 33public:
30enum KeyAction{ 34 /**
31 grabIconify=0, 35 Key actions
32 grabRaise, 36 */
33 grabLower, 37 enum KeyAction{
34 grabClose, 38 ICONIFY=0,
35 grabAbortKeychain, 39 RAISE, LOWER,
36 grabWorkspace1, grabWorkspace2, grabWorkspace3, grabWorkspace4, grabWorkspace5, 40 CLOSE,
37 grabWorkspace6, grabWorkspace7, grabWorkspace8, grabWorkspace9, grabWorkspace10, 41 ABORTKEYCHAIN,
38 grabWorkspace11, grabWorkspace12, grabNextWorkspace, grabPrevWorkspace, 42 WORKSPACE,
39 grabLeftWorkspace, grabRightWorkspace, 43 WORKSPACE1, WORKSPACE2, WORKSPACE3, WORKSPACE4,
40 grabKillWindow, grabNextWindow, grabPrevWindow, 44 WORKSPACE5, WORKSPACE6, WORKSPACE7, WORKSPACE8,
41 grabNextTab, grabPrevTab, 45 WORKSPACE9, WORKSPACE10, WORKSPACE11, WORKSPACE12,
42 grabShade, grabMaximize, grabStick, grabExecute, grabVertMax, 46 SENDTOWORKSPACE, // Send window to a workspace
43 grabHorizMax, grabNudgeRight, grabNudgeLeft,grabNudgeUp, 47 NEXTWORKSPACE, PREVWORKSPACE,
44 grabNudgeDown, grabBigNudgeRight, grabBigNudgeLeft, 48 LEFTWORKSPACE, RIGHTWORKSPACE,
45 grabBigNudgeUp, grabBigNudgeDown, 49 KILLWINDOW, NEXTWINDOW, PREVWINDOW,
46 grabHorizInc, grabVertInc, grabHorizDec, grabVertDec, 50 NEXTTAB, PREVTAB, FIRSTTAB, LASTTAB, MOVETABPREV, MOVETABNEXT,
47 grabToggleDecor, 51 SHADE, MAXIMIZE,
48 lastKeygrab 52 STICK, // Make Sticky
53 EXECUTE, // Run command
54 VERTMAX, // Maximize vertical
55 HORIZMAX, // Maximize horizontal
56 NUDGERIGHT, NUDGELEFT,NUDGEUP, NUDGEDOWN,
57 BIGNUDGERIGHT, BIGNUDGELEFT, BIGNUDGEUP, BIGNUDGEDOWN,
58 HORIZINC, VERTINC, HORIZDEC, VERTDEC,
59 TOGGLEDECOR,// toggle visibility of decor (title, frame, handles)
60 TOGGLETAB, // toggle visibilty of tab
61 ROOTMENU, // pop up rootmenu
62 LASTKEYGRAB //mark end of keygrabbs
49 }; 63 };
50 64 /**
51 Keys(char *filename); 65 Constructor
66 @param display display connection
67 @param filename file to load, default none
68 */
69 Keys(Display *display, const char *filename=0);
70 /// destructor
52 ~Keys(); 71 ~Keys();
53 bool load(char *filename=0); 72 /**
73 Load configuration from file
74 @return true on success, else false
75 */
76 bool load(const char *filename=0);
77 /**
78 Determine action from XKeyEvent
79 @return KeyAction value
80 */
54 KeyAction getAction(XKeyEvent *ke); 81 KeyAction getAction(XKeyEvent *ke);
55 bool reconfigure(char *filename); 82 /**
83 Reload configuration from filename
84 @return true on success, else false
85 */
86 bool reconfigure(const char *filename);
87 /**
88 Get string value of the KeyAction enum value
89 @return string of action
90 */
56 const char *getActionStr(KeyAction action); 91 const char *getActionStr(KeyAction action);
57 std::string getExecCommand() { return m_execcmdstring; } 92 /**
93 Get command to execute (key action EXECUTE)
94 @return string to command
95 */
96 const std::string &getExecCommand() { return m_execcmdstring; }
97 /**
98 @return number of parameters
99 */
100 int getParam() const { return m_param; }
101
58private: 102private:
59 void deleteTree(); 103 void deleteTree();
60 104 void ungrabKeys();
61 void bindKey(unsigned int key, unsigned int mod); 105 void bindKey(unsigned int key, unsigned int mod);
62 unsigned int getModifier(char *modstr); 106 /**
63 unsigned int getKey(char *keystr); 107 @param modstr modifier string (i.e Mod4, Mod5)
108 @return modifier number that match modstr
109 */
110 unsigned int getModifier(const char *modstr);
111 /**
112 @param keystr a key string (i.e F1, Enter)
113 @return key number that match keystr
114 */
115 unsigned int getKey(const char *keystr);
116 /**
117 grab a key
118 @param key the key
119 @param mod the modifier
120 */
64 void grabKey(unsigned int key, unsigned int mod); 121 void grabKey(unsigned int key, unsigned int mod);
65 std::string filename; 122 std::string filename;
66 123
67 class t_key { 124 class t_key {
68 public: 125 public:
69 t_key(unsigned int key, unsigned int mod, KeyAction action_ = lastKeygrab); 126 t_key(unsigned int key, unsigned int mod, KeyAction action_ = Keys::LASTKEYGRAB);
70 t_key(t_key *k); 127 t_key(t_key *k);
71 ~t_key(); 128 ~t_key();
72 129
@@ -94,23 +151,33 @@ private:
94 unsigned int mod; 151 unsigned int mod;
95 std::vector<t_key *> keylist; 152 std::vector<t_key *> keylist;
96 std::string execcommand; 153 std::string execcommand;
154 int param; // parameter to comands
97 }; 155 };
98 156 /**
157 merge two linked list
158 @return true on success, else false
159 */
99 bool mergeTree(t_key *newtree, t_key *basetree=0); 160 bool mergeTree(t_key *newtree, t_key *basetree=0);
100 #ifdef DEBUG 161
101 //debug functions 162#ifdef DEBUG
163 /// debug function
102 void showTree(); 164 void showTree();
165 /// debug function
103 void showKeyTree(t_key *key, unsigned int w=0); 166 void showKeyTree(t_key *key, unsigned int w=0);
104 #endif //DEBUG 167#endif //DEBUG
168
105 struct t_actionstr{ 169 struct t_actionstr{
106 const char *string; 170 const char *string;
107 KeyAction action; 171 KeyAction action;
108 }; 172 };
173
109 static t_actionstr m_actionlist[]; 174 static t_actionstr m_actionlist[];
110 175
111 std::vector<t_key *> m_keylist; 176 std::vector<t_key *> m_keylist;
112 t_key *m_abortkey; //abortkey for keygrabbing chain 177 t_key *m_abortkey; ///< abortkey for keygrabbing chain
113 std::string m_execcmdstring; //copy of the execcommandstring 178 std::string m_execcmdstring; ///< copy of the execcommandstring
179 int m_param; ///< copy of the param argument
180 Display *m_display; ///< display connection
114}; 181};
115 182
116#endif // _KEYS_HH_ 183#endif // _KEYS_HH_