fix identification of event targets in event manager
rathnor rathnor
4 files changed,
79 insertions(+),
8 deletions(-)
M
ChangeLog
→
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
M
src/FbTk/EventManager.cc
→
src/FbTk/EventManager.cc
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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;
M
src/FbTk/EventManager.hh
→
src/FbTk/EventManager.hh
@@ -19,7 +19,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ void add(EventHandler &ev, const FbWindow &win);
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:
M
src/fluxbox.cc
→
src/fluxbox.cc
@@ -22,7 +22,7 @@ // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
// 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 @@ * Handles XClientMessageEvent
*/ 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 @@
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 @@ }
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(); }