From 8930a711ee101c1a02f579a2ee8ebbe39065c085 Mon Sep 17 00:00:00 2001 From: markt Date: Fri, 5 Jan 2007 16:54:34 +0000 Subject: only grab keybindings on screens managed by fluxbox --- ChangeLog | 2 ++ src/FbTk/KeyUtil.cc | 95 ++++++++++++++++++++++++----------------------------- src/FbTk/KeyUtil.hh | 4 +-- src/Keys.cc | 35 +++++++++++++++++--- src/Keys.hh | 5 ++- src/fluxbox.hh | 4 ++- 6 files changed, 84 insertions(+), 61 deletions(-) diff --git a/ChangeLog b/ChangeLog index e7ea179..7d24279 100644 --- a/ChangeLog +++ b/ChangeLog @@ -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 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() { 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; screendisplay(); - for (int screen=0; screendisplay()) { + typedef std::list 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(); } @@ -115,6 +124,22 @@ void Keys::deleteTree() { m_map.clear(); } +void Keys::grabKey(unsigned int key, unsigned int mod) { + std::list::iterator it = m_window_list.begin(); + std::list::iterator it_end = m_window_list.end(); + + for (; it != it_end; ++it) + FbTk::KeyUtil::grabKey(key, mod, *it); +} + +void Keys::ungrabKeys() { + std::list::iterator it = m_window_list.begin(); + std::list::iterator it_end = m_window_list.end(); + + for (; it != it_end; ++it) + FbTk::KeyUtil::ungrabKeys(*it); +} + /** Load and grab keys TODO: error checking @@ -285,7 +310,7 @@ bool Keys::doAction(XKeyEvent &ke) { 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 @@ void Keys::keyMode(string keyMode) { } 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; } 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 @@ #include #include +#include #include #include @@ -76,7 +77,8 @@ public: 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 @@ private: keyspace_t m_map; Display *m_display; ///< display connection + std::list m_window_list; }; #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: /// get screen from number BScreen *findScreen(int num); + typedef std::list 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 @@ private: std::multimap m_group_search; std::list m_menu_timestamps; - typedef std::list ScreenList; ScreenList m_screen_list; FluxboxWindow *m_masked_window; -- cgit v0.11.2