From f89532c0cb3c8a5cc1a78bc11f1c6445edc2d826 Mon Sep 17 00:00:00 2001 From: rathnor <rathnor> Date: Tue, 14 Oct 2003 16:23:16 +0000 Subject: fix identification of event targets in event manager --- ChangeLog | 6 +++++ src/FbTk/EventManager.cc | 58 ++++++++++++++++++++++++++++++++++++++++++++++-- src/FbTk/EventManager.hh | 7 +++++- src/fluxbox.cc | 16 ++++++++----- 4 files changed, 79 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index 1bbc969..7ee9c53 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,11 @@ (Format: Year/Month/Day) Changes for 0.9.6: +*03/10/15: + * Fix event manager target window (Simon) + -> Some events don't have the main window as xany.window + (e.g. XConfigureRequestEvent has the parent there) + -> Fixes missing configurerequest events for e.g. galeon + EventManager.hh/cc fluxbox.cc *03/10/14: * Bug fix in NextWindow/PrevWindow Command (Henrik) it was only executed when last event = keyevent diff --git a/src/FbTk/EventManager.cc b/src/FbTk/EventManager.cc index ff01794..6c697e6 100644 --- a/src/FbTk/EventManager.cc +++ b/src/FbTk/EventManager.cc @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: EventManager.cc,v 1.9 2003/10/02 16:14:41 rathnor Exp $ +// $Id: EventManager.cc,v 1.10 2003/10/14 16:23:16 rathnor Exp $ #include "EventManager.hh" #include "FbWindow.hh" @@ -57,6 +57,58 @@ void EventManager::remove(const FbWindow &win) { unregisterEventHandler(win.window()); } +Window EventManager::getEventWindow(XEvent &ev) { + // we only have cases for events that differ from xany + switch (ev.type) { + case CreateNotify: + // XCreateWindowEvent + return ev.xcreatewindow.window; + break; + case DestroyNotify: + // XDestroyWindowEvent + return ev.xdestroywindow.window; + break; + case UnmapNotify: + // XUnmapEvent + return ev.xunmap.window; + break; + case MapNotify: + // XMapEvent + return ev.xmap.window; + break; + case MapRequest: + // XMapRequestEvent + return ev.xmaprequest.window; + break; + case ReparentNotify: + // XReparentEvent + return ev.xreparent.window; + break; + case ConfigureNotify: + // XConfigureNotify + return ev.xconfigure.window; + break; + case GravityNotify: + // XGravityNotify + return ev.xgravity.window; + break; + case ConfigureRequest: + // XConfigureRequestEvent + return ev.xconfigurerequest.window; + break; + case CirculateNotify: + // XCirculateEvent + return ev.xcirculate.window; + break; + case CirculateRequest: + // XCirculateRequestEvent + return ev.xcirculaterequest.window; + break; + default: + return ev.xany.window; + } +} + void EventManager::registerEventHandler(EventHandler &ev, Window win) { if (win != None) m_eventhandlers[win] = &ev; @@ -73,8 +125,10 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) { EventHandler *evhand = 0; if (parent) evhand = m_parent[win]; - else + else { + win = getEventWindow(ev); evhand = m_eventhandlers[win]; + } if (evhand == 0) return; diff --git a/src/FbTk/EventManager.hh b/src/FbTk/EventManager.hh index 7d1562e..1ad401e 100644 --- a/src/FbTk/EventManager.hh +++ b/src/FbTk/EventManager.hh @@ -19,7 +19,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: EventManager.hh,v 1.5 2003/08/23 15:44:06 fluxgen Exp $ +// $Id: EventManager.hh,v 1.6 2003/10/14 16:23:16 rathnor Exp $ #include "EventHandler.hh" #include <map> @@ -42,6 +42,11 @@ public: void remove(const FbWindow &win); void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } void remove(Window win) { unregisterEventHandler(win); } + + // Some events have the parent window as the xany.window + // This function always returns the actual window member of the event structure + static Window getEventWindow(XEvent &ev); + void registerEventHandler(EventHandler &ev, Window win); void unregisterEventHandler(Window win); private: diff --git a/src/fluxbox.cc b/src/fluxbox.cc index 7b089a5..50cb292 100644 --- a/src/fluxbox.cc +++ b/src/fluxbox.cc @@ -22,7 +22,7 @@ // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // DEALINGS IN THE SOFTWARE. -// $Id: fluxbox.cc,v 1.199 2003/10/13 19:31:04 fluxgen Exp $ +// $Id: fluxbox.cc,v 1.200 2003/10/14 16:23:15 rathnor Exp $ #include "fluxbox.hh" @@ -1091,8 +1091,15 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) { */ void Fluxbox::handleClientMessage(XClientMessageEvent &ce) { #ifdef DEBUG + const char * atom = "nothing"; + if (ce.message_type) + atom = XGetAtomName(FbTk::App::instance()->display(), ce.message_type); + cerr<<__FILE__<<"("<<__LINE__<<"): ClientMessage. data.l[0]=0x"<<hex<<ce.data.l[0]<< - " message_type=0x"<<ce.message_type<<dec<<endl; + " message_type=0x"<<ce.message_type<<dec<<" = \""<<atom<<"\""<<endl; + + if (ce.message_type && atom) XFree((char *) atom); + #endif // DEBUG if (ce.format != 32) @@ -1366,7 +1373,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) { if (m_focused_window == &client) revertFocus(screen); - removeWindowSearch(client.window()); // failed to revert focus? if (m_focused_window == &client) m_focused_window = 0; @@ -1423,9 +1429,9 @@ void Fluxbox::removeAtomHandler(AtomHandler *atomh) { WinClient *Fluxbox::searchWindow(Window window) { std::map<Window, WinClient *>::iterator it = m_window_search.find(window); - if (it != m_window_search.end()) + if (it != m_window_search.end()) return it->second; - + std::map<Window, FluxboxWindow *>::iterator git = m_window_search_group.find(window); return git == m_window_search_group.end() ? 0 : &git->second->winClient(); } -- cgit v0.11.2