aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/EventManager.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/FbTk/EventManager.cc')
-rw-r--r--src/FbTk/EventManager.cc23
1 files changed, 8 insertions, 15 deletions
diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc
index 31d0293..ae52908 100644
--- a/src/FbTk/EventManager.cc
+++ b/src/FbTk/EventManager.cc
@@ -65,25 +65,14 @@ EventHandler *EventManager::find(Window win) {
65 return m_eventhandlers[win]; 65 return m_eventhandlers[win];
66} 66}
67 67
68bool EventManager::grabKeyboard(EventHandler &ev, Window win) { 68bool EventManager::grabKeyboard(Window win) {
69 if (m_grabbing_keyboard)
70 ungrabKeyboard();
71
72 int ret = XGrabKeyboard(App::instance()->display(), win, False, 69 int ret = XGrabKeyboard(App::instance()->display(), win, False,
73 GrabModeAsync, GrabModeAsync, CurrentTime); 70 GrabModeAsync, GrabModeAsync, CurrentTime);
74 71 return (ret == Success);
75 if (ret == Success) {
76 m_grabbing_keyboard = &ev;
77 return true;
78 }
79 return false;
80} 72}
81 73
82void EventManager::ungrabKeyboard() { 74void EventManager::ungrabKeyboard() {
83 XUngrabKeyboard(App::instance()->display(), CurrentTime); 75 XUngrabKeyboard(App::instance()->display(), CurrentTime);
84 if (m_grabbing_keyboard)
85 m_grabbing_keyboard->notifyUngrabKeyboard();
86 m_grabbing_keyboard = 0;
87} 76}
88 77
89Window EventManager::getEventWindow(XEvent &ev) { 78Window EventManager::getEventWindow(XEvent &ev) {
@@ -190,10 +179,14 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) {
190 evhand->exposeEvent(ev.xexpose); 179 evhand->exposeEvent(ev.xexpose);
191 break; 180 break;
192 case EnterNotify: 181 case EnterNotify:
193 evhand->enterNotifyEvent(ev.xcrossing); 182 if (ev.xcrossing.mode != NotifyGrab &&
183 ev.xcrossing.mode != NotifyUngrab)
184 evhand->enterNotifyEvent(ev.xcrossing);
194 break; 185 break;
195 case LeaveNotify: 186 case LeaveNotify:
196 evhand->leaveNotifyEvent(ev.xcrossing); 187 if (ev.xcrossing.mode != NotifyGrab &&
188 ev.xcrossing.mode != NotifyUngrab)
189 evhand->leaveNotifyEvent(ev.xcrossing);
197 break; 190 break;
198 default: 191 default:
199 evhand->handleEvent(ev); 192 evhand->handleEvent(ev);