all repos — fluxbox @ 8930a711ee101c1a02f579a2ee8ebbe39065c085

custom fork of the fluxbox windowmanager

only grab keybindings on screens managed by fluxbox
markt markt
commit

8930a711ee101c1a02f579a2ee8ebbe39065c085

parent

64fcedda00205f0c0b9464967f06322d4c7afa91

6 files changed, 81 insertions(+), 58 deletions(-)

jump to
M ChangeLogChangeLog

@@ -1,6 +1,8 @@

(Format: Year/Month/Day) Changes for 1.0rc3: *07/01/05: + * Only grab keybindings on screens managed by fluxbox (Mark) + fluxbox.hh Keys.cc/hh FbTk/KeyUtil.cc/hh * Fix locale being applied to the clock. (Simon) - Also fixed a likely locale-killer for BSDs (without nl_langinfo) ClockTool.hh/cc FbTk/FbString.cc
M src/FbTk/KeyUtil.ccsrc/FbTk/KeyUtil.cc

@@ -112,57 +112,51 @@ /**

Grabs a key with the modifier and with numlock,capslock and scrollock */ -void KeyUtil::grabKey(unsigned int key, unsigned int mod) { +void KeyUtil::grabKey(unsigned int key, unsigned int mod, Window win) { Display *display = App::instance()->display(); const unsigned int capsmod = instance().capslock(); const unsigned int nummod = instance().numlock(); const unsigned int scrollmod = instance().scrolllock(); - - for (int screen=0; screen<ScreenCount(display); screen++) { - - Window root = RootWindow(display, screen); - - XGrabKey(display, key, mod, - root, True, - GrabModeAsync, GrabModeAsync); - - // Grab with numlock, capslock and scrlock + + XGrabKey(display, key, mod, + win, True, + GrabModeAsync, GrabModeAsync); + + // Grab with numlock, capslock and scrlock + + //numlock + XGrabKey(display, key, mod|nummod, + win, True, + GrabModeAsync, GrabModeAsync); + //scrolllock + XGrabKey(display, key, mod|scrollmod, + win, True, + GrabModeAsync, GrabModeAsync); + //capslock + XGrabKey(display, key, mod|capsmod, + win, True, + GrabModeAsync, GrabModeAsync); + + //capslock+numlock + XGrabKey(display, key, mod|capsmod|nummod, + win, True, + GrabModeAsync, GrabModeAsync); - //numlock - XGrabKey(display, key, mod|nummod, - root, True, - GrabModeAsync, GrabModeAsync); - //scrolllock - XGrabKey(display, key, mod|scrollmod, - root, True, - GrabModeAsync, GrabModeAsync); - //capslock - XGrabKey(display, key, mod|capsmod, - root, True, - GrabModeAsync, GrabModeAsync); - - //capslock+numlock - XGrabKey(display, key, mod|capsmod|nummod, - root, True, - GrabModeAsync, GrabModeAsync); + //capslock+scrolllock + XGrabKey(display, key, mod|capsmod|scrollmod, + win, True, + GrabModeAsync, GrabModeAsync); + + //capslock+numlock+scrolllock + XGrabKey(display, key, mod|capsmod|scrollmod|nummod, + win, True, + GrabModeAsync, GrabModeAsync); - //capslock+scrolllock - XGrabKey(display, key, mod|capsmod|scrollmod, - root, True, - GrabModeAsync, GrabModeAsync); - - //capslock+numlock+scrolllock - XGrabKey(display, key, mod|capsmod|scrollmod|nummod, - root, True, - GrabModeAsync, GrabModeAsync); + //numlock+scrollLock + XGrabKey(display, key, mod|nummod|scrollmod, + win, True, + GrabModeAsync, GrabModeAsync); - //numlock+scrollLock - XGrabKey(display, key, mod|nummod|scrollmod, - root, True, - GrabModeAsync, GrabModeAsync); - - } - } /**

@@ -196,12 +190,9 @@ return 0;

} /// Ungrabs the keys -void KeyUtil::ungrabKeys() { +void KeyUtil::ungrabKeys(Window win) { Display * display = App::instance()->display(); - for (int screen=0; screen<ScreenCount(display); screen++) { - XUngrabKey(display, AnyKey, AnyModifier, - RootWindow(display, screen)); - } + XUngrabKey(display, AnyKey, AnyModifier, win); } unsigned int KeyUtil::keycodeToModmask(unsigned int keycode) {
M src/FbTk/KeyUtil.hhsrc/FbTk/KeyUtil.hh

@@ -43,7 +43,7 @@

/** Grab the specified key */ - static void grabKey(unsigned int key, unsigned int mod); + static void grabKey(unsigned int key, unsigned int mod, Window win); /** convert the string to the keysym

@@ -59,7 +59,7 @@

/** ungrabs all keys */ - static void ungrabKeys(); + static void ungrabKeys(Window win); /** Strip out modifiers we want to ignore
M src/Keys.ccsrc/Keys.cc

@@ -24,6 +24,9 @@

#include "Keys.hh" +#include "fluxbox.hh" +#include "Screen.hh" + #include "FbTk/StringUtil.hh" #include "FbTk/App.hh" #include "FbTk/Command.hh"

@@ -99,12 +102,18 @@

Keys::Keys(): m_display(FbTk::App::instance()->display()) { + typedef std::list<BScreen *> ScreenList; + ScreenList screen_list = Fluxbox::instance()->screenList(); + ScreenList::iterator it = screen_list.begin(); + ScreenList::iterator it_end = screen_list.end(); + + for (; it != it_end; ++it) + m_window_list.push_back(RootWindow(m_display,(*it)->screenNumber())); } Keys::~Keys() { - - FbTk::KeyUtil::ungrabKeys(); + ungrabKeys(); deleteTree(); }

@@ -113,6 +122,22 @@ void Keys::deleteTree() {

for (keyspace_t::iterator map_it = m_map.begin(); map_it != m_map.end(); ++map_it) delete map_it->second; m_map.clear(); +} + +void Keys::grabKey(unsigned int key, unsigned int mod) { + std::list<Window>::iterator it = m_window_list.begin(); + std::list<Window>::iterator it_end = m_window_list.end(); + + for (; it != it_end; ++it) + FbTk::KeyUtil::grabKey(key, mod, *it); +} + +void Keys::ungrabKeys() { + std::list<Window>::iterator it = m_window_list.begin(); + std::list<Window>::iterator it_end = m_window_list.end(); + + for (; it != it_end; ++it) + FbTk::KeyUtil::ungrabKeys(*it); } /**

@@ -285,7 +310,7 @@ next_key = temp_key;

setKeyMode(next_key); // grab "None Escape" to exit keychain in the middle unsigned int esc = FbTk::KeyUtil::getKey("Escape"); - FbTk::KeyUtil::grabKey(esc,0); + grabKey(esc,0); return true; } if (!temp_key || *temp_key->m_command == 0) {

@@ -323,11 +348,11 @@ setKeyMode(it->second);

} void Keys::setKeyMode(t_key *keyMode) { - FbTk::KeyUtil::ungrabKeys(); + ungrabKeys(); keylist_t::iterator it = keyMode->keylist.begin(); keylist_t::iterator it_end = keyMode->keylist.end(); for (; it != it_end; ++it) - FbTk::KeyUtil::grabKey((*it)->key,(*it)->mod); + grabKey((*it)->key,(*it)->mod); m_keylist = keyMode; }
M src/Keys.hhsrc/Keys.hh

@@ -26,6 +26,7 @@ #define KEYS_HH

#include <string> #include <vector> +#include <list> #include <map> #include <X11/Xlib.h>

@@ -76,7 +77,8 @@ void keyMode(std::string keyMode);

private: void deleteTree(); - void bindKey(unsigned int key, unsigned int mod); + void grabKey(unsigned int key, unsigned int mod); + void ungrabKeys(); std::string m_filename;

@@ -123,6 +125,7 @@ t_key *m_keylist;

keyspace_t m_map; Display *m_display; ///< display connection + std::list<Window> m_window_list; }; #endif // KEYS_HH
M src/fluxbox.hhsrc/fluxbox.hh

@@ -196,6 +196,9 @@

/// get screen from number BScreen *findScreen(int num); + typedef std::list<BScreen *> ScreenList; + const ScreenList screenList() const { return m_screen_list; } + /// @return whether the timestamps on the menu changed bool menuTimestampsChanged() const; bool haveShape() const { return m_have_shape; }

@@ -269,7 +272,6 @@ // will have it's window being the group index

std::multimap<Window, WinClient *> m_group_search; std::list<MenuTimestamp *> m_menu_timestamps; - typedef std::list<BScreen *> ScreenList; ScreenList m_screen_list; FluxboxWindow *m_masked_window;