aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk
diff options
context:
space:
mode:
authormarkt <markt>2007-03-04 17:47:37 (GMT)
committermarkt <markt>2007-03-04 17:47:37 (GMT)
commit4c1a242968dff12e504f281224819b7cd3850a04 (patch)
tree42a6e3de02153bc8f35cae43f89238d73e9b821a /src/FbTk
parent9477af82a5835b7336fec8879967abb67f3bd848 (diff)
downloadfluxbox-4c1a242968dff12e504f281224819b7cd3850a04.zip
fluxbox-4c1a242968dff12e504f281224819b7cd3850a04.tar.bz2
moved some code around (regarding event handling) in preparation for upcoming features
Diffstat (limited to 'src/FbTk')
-rw-r--r--src/FbTk/EventHandler.hh4
-rw-r--r--src/FbTk/EventManager.cc22
-rw-r--r--src/FbTk/EventManager.hh7
3 files changed, 28 insertions, 5 deletions
diff --git a/src/FbTk/EventHandler.hh b/src/FbTk/EventHandler.hh
index 3d2e545..45c7a2a 100644
--- a/src/FbTk/EventHandler.hh
+++ b/src/FbTk/EventHandler.hh
@@ -54,11 +54,11 @@ public:
54 virtual void exposeEvent(XExposeEvent &) { } 54 virtual void exposeEvent(XExposeEvent &) { }
55 virtual void motionNotifyEvent(XMotionEvent &) { } 55 virtual void motionNotifyEvent(XMotionEvent &) { }
56 virtual void keyPressEvent(XKeyEvent &) { } 56 virtual void keyPressEvent(XKeyEvent &) { }
57#ifdef NOT_USED
58 virtual void keyReleaseEvent(XKeyEvent &) { } 57 virtual void keyReleaseEvent(XKeyEvent &) { }
59#endif
60 virtual void leaveNotifyEvent(XCrossingEvent &) { } 58 virtual void leaveNotifyEvent(XCrossingEvent &) { }
61 virtual void enterNotifyEvent(XCrossingEvent &) { } 59 virtual void enterNotifyEvent(XCrossingEvent &) { }
60
61 virtual void notifyUngrabKeyboard() { }
62}; 62};
63 63
64} // end namespace FbTk 64} // end namespace FbTk
diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc
index 02259ac..fd26950 100644
--- a/src/FbTk/EventManager.cc
+++ b/src/FbTk/EventManager.cc
@@ -66,6 +66,26 @@ EventHandler *EventManager::find(Window win) {
66 return m_eventhandlers[win]; 66 return m_eventhandlers[win];
67} 67}
68 68
69bool EventManager::grabKeyboard(EventHandler &ev, Window win) {
70 if (m_grabbing_keyboard)
71 ungrabKeyboard();
72
73 int ret = XGrabKeyboard(App::instance()->display(), win, False,
74 GrabModeAsync, GrabModeAsync, CurrentTime);
75
76 if (ret == Success) {
77 m_grabbing_keyboard = &ev;
78 return true;
79 }
80 return false;
81}
82
83void EventManager::ungrabKeyboard() {
84 XUngrabKeyboard(App::instance()->display(), CurrentTime);
85 if (m_grabbing_keyboard)
86 m_grabbing_keyboard->notifyUngrabKeyboard();
87 m_grabbing_keyboard = 0;
88}
69 89
70Window EventManager::getEventWindow(XEvent &ev) { 90Window EventManager::getEventWindow(XEvent &ev) {
71 // we only have cases for events that differ from xany 91 // we only have cases for events that differ from xany
@@ -156,9 +176,7 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) {
156 evhand->keyPressEvent(ev.xkey); 176 evhand->keyPressEvent(ev.xkey);
157 break; 177 break;
158 case KeyRelease: 178 case KeyRelease:
159#ifdef NOT_USED
160 evhand->keyReleaseEvent(ev.xkey); 179 evhand->keyReleaseEvent(ev.xkey);
161#endif
162 break; 180 break;
163 case ButtonPress: 181 case ButtonPress:
164 evhand->buttonPressEvent(ev.xbutton); 182 evhand->buttonPressEvent(ev.xbutton);
diff --git a/src/FbTk/EventManager.hh b/src/FbTk/EventManager.hh
index 5bbaa00..149649b 100644
--- a/src/FbTk/EventManager.hh
+++ b/src/FbTk/EventManager.hh
@@ -43,6 +43,10 @@ public:
43 void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } 43 void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); }
44 void remove(Window win) { unregisterEventHandler(win); } 44 void remove(Window win) { unregisterEventHandler(win); }
45 45
46 bool grabKeyboard(EventHandler &ev, Window win);
47 void ungrabKeyboard();
48 EventHandler *grabbingKeyboard() { return m_grabbing_keyboard; }
49
46 EventHandler *find(Window win); 50 EventHandler *find(Window win);
47 51
48 // Some events have the parent window as the xany.window 52 // Some events have the parent window as the xany.window
@@ -53,13 +57,14 @@ public:
53 void unregisterEventHandler(Window win); 57 void unregisterEventHandler(Window win);
54 58
55private: 59private:
56 EventManager() { } 60 EventManager(): m_grabbing_keyboard(0) { }
57 ~EventManager(); 61 ~EventManager();
58 void dispatch(Window win, XEvent &event, bool parent = false); 62 void dispatch(Window win, XEvent &event, bool parent = false);
59 63
60 typedef std::map<Window, EventHandler *> EventHandlerMap; 64 typedef std::map<Window, EventHandler *> EventHandlerMap;
61 EventHandlerMap m_eventhandlers; 65 EventHandlerMap m_eventhandlers;
62 EventHandlerMap m_parent; 66 EventHandlerMap m_parent;
67 EventHandler *m_grabbing_keyboard;
63}; 68};
64 69
65} //end namespace FbTk 70} //end namespace FbTk