all repos — fluxbox @ d95fcc2dbba7fdf3884452bd69c352c87ae1e57b

custom fork of the fluxbox windowmanager

Event Manager fixes/review
rathnor rathnor
commit

d95fcc2dbba7fdf3884452bd69c352c87ae1e57b

parent

e127dabae691ee567aaedb84a2d7456c72991978

M ChangeLogChangeLog

@@ -1,5 +1,8 @@

(Format: Year/Month/Day) Changes for 0.9.10: +*04/05/04: + * Fix EventManager bug/memory leak (possibly caused crash) (Simon) + EventManager.hh/cc *04/05/02: * Added new nls item for windowmenu: Layer nls/C/Windowmenu.m
M src/Container.ccsrc/Container.cc

@@ -20,7 +20,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: Container.cc,v 1.13 2004/01/21 13:34:40 fluxgen Exp $ +// $Id: Container.cc,v 1.14 2004/05/04 14:33:37 rathnor Exp $ #include "Container.hh"

@@ -37,7 +37,7 @@ FbTk::EventManager::instance()->add(*this, *this);

} Container::~Container() { - + // ~FbWindow cleans event manager } void Container::resize(unsigned int width, unsigned int height) {
M src/FbTk/EventManager.ccsrc/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.11 2004/04/19 22:46:46 fluxgen Exp $ +// $Id: EventManager.cc,v 1.12 2004/05/04 14:33:38 rathnor Exp $ #include "EventManager.hh" #include "FbWindow.hh"

@@ -128,11 +128,19 @@ }

void EventManager::dispatch(Window win, XEvent &ev, bool parent) { EventHandler *evhand = 0; - if (parent) - evhand = m_parent[win]; - else { + if (parent) { + EventHandlerMap::iterator it = m_parent.find(win); + if (it == m_parent.end()) + return; + else + evhand = it->second; + } else { win = getEventWindow(ev); - evhand = m_eventhandlers[win]; + EventHandlerMap::iterator it = m_eventhandlers.find(win); + if (it == m_eventhandlers.end()) + return; + else + evhand = it->second; } if (evhand == 0)
M src/FbTk/EventManager.hhsrc/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.8 2004/04/19 22:46:46 fluxgen Exp $ +// $Id: EventManager.hh,v 1.9 2004/05/04 14:33:38 rathnor Exp $ #include "EventHandler.hh" #include <map>

@@ -51,12 +51,15 @@ static Window getEventWindow(XEvent &ev);

void registerEventHandler(EventHandler &ev, Window win); void unregisterEventHandler(Window win); + private: EventManager() { } ~EventManager(); void dispatch(Window win, XEvent &event, bool parent = false); - std::map<Window, EventHandler *> m_eventhandlers; - std::map<Window, EventHandler *> m_parent; + + typedef std::map<Window, EventHandler *> EventHandlerMap; + EventHandlerMap m_eventhandlers; + EventHandlerMap m_parent; }; } //end namespace FbTk
M src/IconButton.ccsrc/IconButton.cc

@@ -20,7 +20,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: IconButton.cc,v 1.19 2004/05/02 20:46:19 fluxgen Exp $ +// $Id: IconButton.cc,v 1.20 2004/05/04 14:33:37 rathnor Exp $ #include "IconButton.hh"

@@ -112,7 +112,7 @@ update(0);

} IconButton::~IconButton() { - + // ~FbWindow cleans event manager }
M src/SystemTray.ccsrc/SystemTray.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: SystemTray.cc,v 1.9 2004/04/19 22:49:25 fluxgen Exp $ +// $Id: SystemTray.cc,v 1.10 2004/05/04 14:33:37 rathnor Exp $ #include "SystemTray.hh"

@@ -141,6 +141,7 @@ SystemTray::~SystemTray() {

// remove us, else fluxbox might delete the memory too Fluxbox::instance()->removeAtomHandler(m_handler.get()); removeAllClients(); + // ~FbWindow cleans EventManager } void SystemTray::move(int x, int y) {