fix identification of event targets in event manager

This commit is contained in:
rathnor 2003-10-14 16:23:16 +00:00
parent c583251e18
commit f89532c0cb
4 changed files with 79 additions and 8 deletions

View file

@ -1,5 +1,11 @@
(Format: Year/Month/Day) (Format: Year/Month/Day)
Changes for 0.9.6: 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: *03/10/14:
* Bug fix in NextWindow/PrevWindow Command (Henrik) * Bug fix in NextWindow/PrevWindow Command (Henrik)
it was only executed when last event = keyevent it was only executed when last event = keyevent

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 "EventManager.hh"
#include "FbWindow.hh" #include "FbWindow.hh"
@ -57,6 +57,58 @@ void EventManager::remove(const FbWindow &win) {
unregisterEventHandler(win.window()); 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) { void EventManager::registerEventHandler(EventHandler &ev, Window win) {
if (win != None) if (win != None)
m_eventhandlers[win] = &ev; m_eventhandlers[win] = &ev;
@ -73,8 +125,10 @@ void EventManager::dispatch(Window win, XEvent &ev, bool parent) {
EventHandler *evhand = 0; EventHandler *evhand = 0;
if (parent) if (parent)
evhand = m_parent[win]; evhand = m_parent[win];
else else {
win = getEventWindow(ev);
evhand = m_eventhandlers[win]; evhand = m_eventhandlers[win];
}
if (evhand == 0) if (evhand == 0)
return; return;

View file

@ -19,7 +19,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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 "EventHandler.hh"
#include <map> #include <map>
@ -42,6 +42,11 @@ public:
void remove(const FbWindow &win); void remove(const FbWindow &win);
void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); } void add(EventHandler &ev, Window win) { registerEventHandler(ev, win); }
void remove(Window win) { unregisterEventHandler(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 registerEventHandler(EventHandler &ev, Window win);
void unregisterEventHandler(Window win); void unregisterEventHandler(Window win);
private: private:

View file

@ -22,7 +22,7 @@
// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE. // 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" #include "fluxbox.hh"
@ -1091,8 +1091,15 @@ void Fluxbox::handleUnmapNotify(XUnmapEvent &ue) {
*/ */
void Fluxbox::handleClientMessage(XClientMessageEvent &ce) { void Fluxbox::handleClientMessage(XClientMessageEvent &ce) {
#ifdef DEBUG #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]<< 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 #endif // DEBUG
if (ce.format != 32) if (ce.format != 32)
@ -1366,7 +1373,6 @@ void Fluxbox::update(FbTk::Subject *changedsub) {
if (m_focused_window == &client) if (m_focused_window == &client)
revertFocus(screen); revertFocus(screen);
removeWindowSearch(client.window());
// failed to revert focus? // failed to revert focus?
if (m_focused_window == &client) if (m_focused_window == &client)
m_focused_window = 0; m_focused_window = 0;