diff options
author | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
---|---|---|
committer | fluxgen <fluxgen> | 2001-12-11 20:47:02 (GMT) |
commit | 18830ac9add80cbd3bf7369307d7e35a519dca9b (patch) | |
tree | 4759a5434a34ba317fe77bbf8b0ed9bb57bb6018 /src/Keys.hh | |
parent | 1523b48bff07dead084af3064ad11c79a9b25df0 (diff) | |
download | fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.zip fluxbox-18830ac9add80cbd3bf7369307d7e35a519dca9b.tar.bz2 |
Initial revision
Diffstat (limited to 'src/Keys.hh')
-rw-r--r-- | src/Keys.hh | 116 |
1 files changed, 116 insertions, 0 deletions
diff --git a/src/Keys.hh b/src/Keys.hh new file mode 100644 index 0000000..3b19aaa --- /dev/null +++ b/src/Keys.hh | |||
@@ -0,0 +1,116 @@ | |||
1 | // Key2.hh for Fluxbox - an X11 Window manager | ||
2 | // Copyright (c) 2001 Henrik Kinnunen (fluxgen@linuxmail.org) | ||
3 | // | ||
4 | // Permission is hereby granted, free of charge, to any person obtaining a | ||
5 | // copy of this software and associated documentation files (the "Software"), | ||
6 | // to deal in the Software without restriction, including without limitation | ||
7 | // the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
8 | // and/or sell copies of the Software, and to permit persons to whom the | ||
9 | // Software is furnished to do so, subject to the following conditions: | ||
10 | // | ||
11 | // The above copyright notice and this permission notice shall be included in | ||
12 | // all copies or substantial portions of the Software. | ||
13 | // | ||
14 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
15 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
16 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | ||
17 | // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
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 | ||
20 | // DEALINGS IN THE SOFTWARE. | ||
21 | #ifndef _KEYS_HH_ | ||
22 | #define _KEYS_HH_ | ||
23 | |||
24 | #include <string> | ||
25 | #include <vector> | ||
26 | |||
27 | class Keys | ||
28 | { | ||
29 | public: | ||
30 | enum KeyAction{ | ||
31 | grabIconify=0, | ||
32 | grabRaise, | ||
33 | grabLower, | ||
34 | grabClose, | ||
35 | grabAbortKeychain, | ||
36 | grabWorkspace1, grabWorkspace2, grabWorkspace3, grabWorkspace4, grabWorkspace5, | ||
37 | grabWorkspace6, grabWorkspace7, grabWorkspace8, grabWorkspace9, grabWorkspace10, | ||
38 | grabWorkspace11, grabWorkspace12, grabNextWorkspace, grabPrevWorkspace, | ||
39 | grabLeftWorkspace, grabRightWorkspace, | ||
40 | grabKillWindow, grabNextWindow, grabPrevWindow, | ||
41 | grabNextTab, grabPrevTab, | ||
42 | grabShade, grabMaximize, grabStick, grabExecute, grabVertMax, | ||
43 | grabHorizMax, grabNudgeRight, grabNudgeLeft,grabNudgeUp, | ||
44 | grabNudgeDown, grabBigNudgeRight, grabBigNudgeLeft, | ||
45 | grabBigNudgeUp, grabBigNudgeDown, | ||
46 | grabHorizInc, grabVertInc, grabHorizDec, grabVertDec, | ||
47 | grabToggleDecor, | ||
48 | lastKeygrab | ||
49 | }; | ||
50 | |||
51 | Keys(char *filename); | ||
52 | ~Keys(); | ||
53 | bool load(char *filename=0); | ||
54 | KeyAction getAction(XKeyEvent *ke); | ||
55 | bool reconfigure(char *filename); | ||
56 | const char *getActionStr(KeyAction action); | ||
57 | std::string getExecCommand() { return m_execcmdstring; } | ||
58 | private: | ||
59 | void deleteTree(); | ||
60 | |||
61 | void bindKey(unsigned int key, unsigned int mod); | ||
62 | unsigned int getModifier(char *modstr); | ||
63 | unsigned int getKey(char *keystr); | ||
64 | void grabKey(unsigned int key, unsigned int mod); | ||
65 | std::string filename; | ||
66 | |||
67 | class t_key { | ||
68 | public: | ||
69 | t_key(unsigned int key, unsigned int mod, KeyAction action_ = lastKeygrab); | ||
70 | t_key(t_key *k); | ||
71 | ~t_key(); | ||
72 | |||
73 | inline t_key *find(unsigned int key_, unsigned int mod_) { | ||
74 | for (unsigned int i=0; i<keylist.size(); i++) { | ||
75 | if (keylist[i]->key == key_ && keylist[i]->mod == mod_) | ||
76 | return keylist[i]; | ||
77 | } | ||
78 | return 0; | ||
79 | } | ||
80 | inline t_key *find(XKeyEvent *ke) { | ||
81 | for (unsigned int i=0; i<keylist.size(); i++) { | ||
82 | if (keylist[i]->key == ke->keycode && keylist[i]->mod == ke->state) | ||
83 | return keylist[i]; | ||
84 | } | ||
85 | return 0; | ||
86 | } | ||
87 | |||
88 | inline bool operator == (XKeyEvent *ke) { | ||
89 | return (mod == ke->state && key == ke->keycode); | ||
90 | } | ||
91 | |||
92 | KeyAction action; | ||
93 | unsigned int key; | ||
94 | unsigned int mod; | ||
95 | std::vector<t_key *> keylist; | ||
96 | std::string execcommand; | ||
97 | }; | ||
98 | |||
99 | bool mergeTree(t_key *newtree, t_key *basetree=0); | ||
100 | #ifdef DEBUG | ||
101 | //debug functions | ||
102 | void showTree(); | ||
103 | void showKeyTree(t_key *key, unsigned int w=0); | ||
104 | #endif //DEBUG | ||
105 | struct t_actionstr{ | ||
106 | const char *string; | ||
107 | KeyAction action; | ||
108 | }; | ||
109 | static t_actionstr m_actionlist[]; | ||
110 | |||
111 | std::vector<t_key *> m_keylist; | ||
112 | t_key *m_abortkey; //abortkey for keygrabbing chain | ||
113 | std::string m_execcmdstring; //copy of the execcommandstring | ||
114 | }; | ||
115 | |||
116 | #endif // _KEYS_HH_ | ||