only grab keybindings on screens managed by fluxbox
This commit is contained in:
parent
64fcedda00
commit
8930a711ee
6 changed files with 81 additions and 58 deletions
|
@ -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
|
||||
|
|
|
@ -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; screen<ScreenCount(display); screen++) {
|
||||
|
||||
Window root = RootWindow(display, screen);
|
||||
|
||||
XGrabKey(display, key, mod,
|
||||
root, True,
|
||||
GrabModeAsync, GrabModeAsync);
|
||||
|
||||
// Grab with numlock, capslock and scrlock
|
||||
|
||||
//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);
|
||||
XGrabKey(display, key, mod,
|
||||
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);
|
||||
// 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);
|
||||
|
||||
//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);
|
||||
|
||||
//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 @@ unsigned int KeyUtil::getModifier(const char *modstr) {
|
|||
}
|
||||
|
||||
/// 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) {
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
/**
|
||||
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 @@ public:
|
|||
/**
|
||||
ungrabs all keys
|
||||
*/
|
||||
static void ungrabKeys();
|
||||
static void ungrabKeys(Window win);
|
||||
|
||||
/**
|
||||
Strip out modifiers we want to ignore
|
||||
|
|
35
src/Keys.cc
35
src/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 @@ using std::pair;
|
|||
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();
|
||||
}
|
||||
|
||||
|
@ -115,6 +124,22 @@ void Keys::deleteTree() {
|
|||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
|
@ -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<Window> m_window_list;
|
||||
};
|
||||
|
||||
#endif // KEYS_HH
|
||||
|
|
|
@ -196,6 +196,9 @@ public:
|
|||
/// 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 @@ private:
|
|||
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;
|
||||
|
|
Loading…
Reference in a new issue