aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormarkt <markt>2007-01-05 16:54:34 (GMT)
committermarkt <markt>2007-01-05 16:54:34 (GMT)
commit8930a711ee101c1a02f579a2ee8ebbe39065c085 (patch)
treecce01b032cb6c7e76e820590490e7c08ab758112 /src
parent64fcedda00205f0c0b9464967f06322d4c7afa91 (diff)
downloadfluxbox_paul-8930a711ee101c1a02f579a2ee8ebbe39065c085.zip
fluxbox_paul-8930a711ee101c1a02f579a2ee8ebbe39065c085.tar.bz2
only grab keybindings on screens managed by fluxbox
Diffstat (limited to 'src')
-rw-r--r--src/FbTk/KeyUtil.cc95
-rw-r--r--src/FbTk/KeyUtil.hh4
-rw-r--r--src/Keys.cc35
-rw-r--r--src/Keys.hh5
-rw-r--r--src/fluxbox.hh4
5 files changed, 82 insertions, 61 deletions
diff --git a/src/FbTk/KeyUtil.cc b/src/FbTk/KeyUtil.cc
index de9f947..b02a76b 100644
--- a/src/FbTk/KeyUtil.cc
+++ b/src/FbTk/KeyUtil.cc
@@ -112,57 +112,51 @@ void KeyUtil::loadModmap() {
112 Grabs a key with the modifier 112 Grabs a key with the modifier
113 and with numlock,capslock and scrollock 113 and with numlock,capslock and scrollock
114*/ 114*/
115void KeyUtil::grabKey(unsigned int key, unsigned int mod) { 115void KeyUtil::grabKey(unsigned int key, unsigned int mod, Window win) {
116 Display *display = App::instance()->display(); 116 Display *display = App::instance()->display();
117 const unsigned int capsmod = instance().capslock(); 117 const unsigned int capsmod = instance().capslock();
118 const unsigned int nummod = instance().numlock(); 118 const unsigned int nummod = instance().numlock();
119 const unsigned int scrollmod = instance().scrolllock(); 119 const unsigned int scrollmod = instance().scrolllock();
120 120
121 for (int screen=0; screen<ScreenCount(display); screen++) { 121 XGrabKey(display, key, mod,
122 122 win, True,
123 Window root = RootWindow(display, screen); 123 GrabModeAsync, GrabModeAsync);
124 124
125 XGrabKey(display, key, mod, 125 // Grab with numlock, capslock and scrlock
126 root, True, 126
127 GrabModeAsync, GrabModeAsync); 127 //numlock
128 128 XGrabKey(display, key, mod|nummod,
129 // Grab with numlock, capslock and scrlock 129 win, True,
130 130 GrabModeAsync, GrabModeAsync);
131 //numlock 131 //scrolllock
132 XGrabKey(display, key, mod|nummod, 132 XGrabKey(display, key, mod|scrollmod,
133 root, True, 133 win, True,
134 GrabModeAsync, GrabModeAsync); 134 GrabModeAsync, GrabModeAsync);
135 //scrolllock 135 //capslock
136 XGrabKey(display, key, mod|scrollmod, 136 XGrabKey(display, key, mod|capsmod,
137 root, True, 137 win, True,
138 GrabModeAsync, GrabModeAsync); 138 GrabModeAsync, GrabModeAsync);
139 //capslock 139
140 XGrabKey(display, key, mod|capsmod, 140 //capslock+numlock
141 root, True, 141 XGrabKey(display, key, mod|capsmod|nummod,
142 GrabModeAsync, GrabModeAsync); 142 win, True,
143 143 GrabModeAsync, GrabModeAsync);
144 //capslock+numlock 144
145 XGrabKey(display, key, mod|capsmod|nummod, 145 //capslock+scrolllock
146 root, True, 146 XGrabKey(display, key, mod|capsmod|scrollmod,
147 GrabModeAsync, GrabModeAsync); 147 win, True,
148 148 GrabModeAsync, GrabModeAsync);
149 //capslock+scrolllock 149
150 XGrabKey(display, key, mod|capsmod|scrollmod, 150 //capslock+numlock+scrolllock
151 root, True, 151 XGrabKey(display, key, mod|capsmod|scrollmod|nummod,
152 GrabModeAsync, GrabModeAsync); 152 win, True,
153 153 GrabModeAsync, GrabModeAsync);
154 //capslock+numlock+scrolllock 154
155 XGrabKey(display, key, mod|capsmod|scrollmod|nummod, 155 //numlock+scrollLock
156 root, True, 156 XGrabKey(display, key, mod|nummod|scrollmod,
157 GrabModeAsync, GrabModeAsync); 157 win, True,
158 158 GrabModeAsync, GrabModeAsync);
159 //numlock+scrollLock 159
160 XGrabKey(display, key, mod|nummod|scrollmod,
161 root, True,
162 GrabModeAsync, GrabModeAsync);
163
164 }
165
166} 160}
167 161
168/** 162/**
@@ -196,12 +190,9 @@ unsigned int KeyUtil::getModifier(const char *modstr) {
196} 190}
197 191
198/// Ungrabs the keys 192/// Ungrabs the keys
199void KeyUtil::ungrabKeys() { 193void KeyUtil::ungrabKeys(Window win) {
200 Display * display = App::instance()->display(); 194 Display * display = App::instance()->display();
201 for (int screen=0; screen<ScreenCount(display); screen++) { 195 XUngrabKey(display, AnyKey, AnyModifier, win);
202 XUngrabKey(display, AnyKey, AnyModifier,
203 RootWindow(display, screen));
204 }
205} 196}
206 197
207unsigned int KeyUtil::keycodeToModmask(unsigned int keycode) { 198unsigned int KeyUtil::keycodeToModmask(unsigned int keycode) {
diff --git a/src/FbTk/KeyUtil.hh b/src/FbTk/KeyUtil.hh
index e1f1276..902d27e 100644
--- a/src/FbTk/KeyUtil.hh
+++ b/src/FbTk/KeyUtil.hh
@@ -43,7 +43,7 @@ public:
43 /** 43 /**
44 Grab the specified key 44 Grab the specified key
45 */ 45 */
46 static void grabKey(unsigned int key, unsigned int mod); 46 static void grabKey(unsigned int key, unsigned int mod, Window win);
47 47
48 /** 48 /**
49 convert the string to the keysym 49 convert the string to the keysym
@@ -59,7 +59,7 @@ public:
59 /** 59 /**
60 ungrabs all keys 60 ungrabs all keys
61 */ 61 */
62 static void ungrabKeys(); 62 static void ungrabKeys(Window win);
63 63
64 /** 64 /**
65 Strip out modifiers we want to ignore 65 Strip out modifiers we want to ignore
diff --git a/src/Keys.cc b/src/Keys.cc
index 72e3112..e7b7acd 100644
--- a/src/Keys.cc
+++ b/src/Keys.cc
@@ -24,6 +24,9 @@
24 24
25#include "Keys.hh" 25#include "Keys.hh"
26 26
27#include "fluxbox.hh"
28#include "Screen.hh"
29
27#include "FbTk/StringUtil.hh" 30#include "FbTk/StringUtil.hh"
28#include "FbTk/App.hh" 31#include "FbTk/App.hh"
29#include "FbTk/Command.hh" 32#include "FbTk/Command.hh"
@@ -99,12 +102,18 @@ using std::pair;
99Keys::Keys(): 102Keys::Keys():
100 m_display(FbTk::App::instance()->display()) 103 m_display(FbTk::App::instance()->display())
101{ 104{
105 typedef std::list<BScreen *> ScreenList;
106 ScreenList screen_list = Fluxbox::instance()->screenList();
107 ScreenList::iterator it = screen_list.begin();
108 ScreenList::iterator it_end = screen_list.end();
109
110 for (; it != it_end; ++it)
111 m_window_list.push_back(RootWindow(m_display,(*it)->screenNumber()));
102 112
103} 113}
104 114
105Keys::~Keys() { 115Keys::~Keys() {
106 116 ungrabKeys();
107 FbTk::KeyUtil::ungrabKeys();
108 deleteTree(); 117 deleteTree();
109} 118}
110 119
@@ -115,6 +124,22 @@ void Keys::deleteTree() {
115 m_map.clear(); 124 m_map.clear();
116} 125}
117 126
127void Keys::grabKey(unsigned int key, unsigned int mod) {
128 std::list<Window>::iterator it = m_window_list.begin();
129 std::list<Window>::iterator it_end = m_window_list.end();
130
131 for (; it != it_end; ++it)
132 FbTk::KeyUtil::grabKey(key, mod, *it);
133}
134
135void Keys::ungrabKeys() {
136 std::list<Window>::iterator it = m_window_list.begin();
137 std::list<Window>::iterator it_end = m_window_list.end();
138
139 for (; it != it_end; ++it)
140 FbTk::KeyUtil::ungrabKeys(*it);
141}
142
118/** 143/**
119 Load and grab keys 144 Load and grab keys
120 TODO: error checking 145 TODO: error checking
@@ -285,7 +310,7 @@ bool Keys::doAction(XKeyEvent &ke) {
285 setKeyMode(next_key); 310 setKeyMode(next_key);
286 // grab "None Escape" to exit keychain in the middle 311 // grab "None Escape" to exit keychain in the middle
287 unsigned int esc = FbTk::KeyUtil::getKey("Escape"); 312 unsigned int esc = FbTk::KeyUtil::getKey("Escape");
288 FbTk::KeyUtil::grabKey(esc,0); 313 grabKey(esc,0);
289 return true; 314 return true;
290 } 315 }
291 if (!temp_key || *temp_key->m_command == 0) { 316 if (!temp_key || *temp_key->m_command == 0) {
@@ -323,11 +348,11 @@ void Keys::keyMode(string keyMode) {
323} 348}
324 349
325void Keys::setKeyMode(t_key *keyMode) { 350void Keys::setKeyMode(t_key *keyMode) {
326 FbTk::KeyUtil::ungrabKeys(); 351 ungrabKeys();
327 keylist_t::iterator it = keyMode->keylist.begin(); 352 keylist_t::iterator it = keyMode->keylist.begin();
328 keylist_t::iterator it_end = keyMode->keylist.end(); 353 keylist_t::iterator it_end = keyMode->keylist.end();
329 for (; it != it_end; ++it) 354 for (; it != it_end; ++it)
330 FbTk::KeyUtil::grabKey((*it)->key,(*it)->mod); 355 grabKey((*it)->key,(*it)->mod);
331 m_keylist = keyMode; 356 m_keylist = keyMode;
332} 357}
333 358
diff --git a/src/Keys.hh b/src/Keys.hh
index 8e919b3..6602d49 100644
--- a/src/Keys.hh
+++ b/src/Keys.hh
@@ -26,6 +26,7 @@
26 26
27#include <string> 27#include <string>
28#include <vector> 28#include <vector>
29#include <list>
29#include <map> 30#include <map>
30#include <X11/Xlib.h> 31#include <X11/Xlib.h>
31 32
@@ -76,7 +77,8 @@ public:
76private: 77private:
77 void deleteTree(); 78 void deleteTree();
78 79
79 void bindKey(unsigned int key, unsigned int mod); 80 void grabKey(unsigned int key, unsigned int mod);
81 void ungrabKeys();
80 82
81 std::string m_filename; 83 std::string m_filename;
82 84
@@ -123,6 +125,7 @@ private:
123 keyspace_t m_map; 125 keyspace_t m_map;
124 126
125 Display *m_display; ///< display connection 127 Display *m_display; ///< display connection
128 std::list<Window> m_window_list;
126}; 129};
127 130
128#endif // KEYS_HH 131#endif // KEYS_HH
diff --git a/src/fluxbox.hh b/src/fluxbox.hh
index c80459a..3f4a00a 100644
--- a/src/fluxbox.hh
+++ b/src/fluxbox.hh
@@ -196,6 +196,9 @@ public:
196 /// get screen from number 196 /// get screen from number
197 BScreen *findScreen(int num); 197 BScreen *findScreen(int num);
198 198
199 typedef std::list<BScreen *> ScreenList;
200 const ScreenList screenList() const { return m_screen_list; }
201
199 /// @return whether the timestamps on the menu changed 202 /// @return whether the timestamps on the menu changed
200 bool menuTimestampsChanged() const; 203 bool menuTimestampsChanged() const;
201 bool haveShape() const { return m_have_shape; } 204 bool haveShape() const { return m_have_shape; }
@@ -269,7 +272,6 @@ private:
269 std::multimap<Window, WinClient *> m_group_search; 272 std::multimap<Window, WinClient *> m_group_search;
270 273
271 std::list<MenuTimestamp *> m_menu_timestamps; 274 std::list<MenuTimestamp *> m_menu_timestamps;
272 typedef std::list<BScreen *> ScreenList;
273 ScreenList m_screen_list; 275 ScreenList m_screen_list;
274 276
275 FluxboxWindow *m_masked_window; 277 FluxboxWindow *m_masked_window;