diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-02-19 00:30:19 +0200 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-02-19 00:30:19 +0200 |
commit | b9331fca5a0472890c388175f23c6c7f70ab8d7f (patch) | |
tree | ded661080cbadb2005c9c98d157e83f91d8cc615 | |
parent | 0b10f0318b9f9ab308f04712698aa104bec21e29 (diff) | |
download | mv-b9331fca5a0472890c388175f23c6c7f70ab8d7f.tar.gz mv-b9331fca5a0472890c388175f23c6c7f70ab8d7f.tar.bz2 mv-b9331fca5a0472890c388175f23c6c7f70ab8d7f.tar.xz mv-b9331fca5a0472890c388175f23c6c7f70ab8d7f.zip |
Fix race condition in guichan bugfix.
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/gui/gui.cpp | 11 | ||||
-rw-r--r-- | src/gui/widgets/mouseevent.h | 47 |
4 files changed, 57 insertions, 3 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0b1575ffc..4e12bcc21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -166,6 +166,7 @@ SET(SRCS gui/widgets/linkhandler.h gui/widgets/listbox.cpp gui/widgets/listbox.h + gui/widgets/mouseevent.h gui/widgets/passwordfield.cpp gui/widgets/passwordfield.h gui/widgets/playerbox.cpp diff --git a/src/Makefile.am b/src/Makefile.am index 4ff75d1a0..09533b114 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -57,6 +57,7 @@ manaplus_SOURCES = gui/widgets/avatarlistbox.cpp \ gui/widgets/linkhandler.h \ gui/widgets/listbox.cpp \ gui/widgets/listbox.h \ + gui/widgets/mouseevent.h \ gui/widgets/passwordfield.cpp \ gui/widgets/passwordfield.h \ gui/widgets/playerbox.cpp \ diff --git a/src/gui/gui.cpp b/src/gui/gui.cpp index 984b9ea1a..937a102f7 100644 --- a/src/gui/gui.cpp +++ b/src/gui/gui.cpp @@ -27,6 +27,7 @@ #include "gui/theme.h" #include "gui/truetypefont.h" +#include "gui/widgets/mouseevent.h" #include "gui/widgets/window.h" #include "gui/widgets/windowcontainer.h" @@ -331,6 +332,10 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, return; } + MouseEvent mouseEvent(source, mShiftPressed, mControlPressed, + mAltPressed, mMetaPressed, type, button, + x, y, mClickCount); + while (parent != NULL) { // If the widget has been removed due to input @@ -340,14 +345,14 @@ void Gui::distributeMouseEvent(gcn::Widget* source, int type, int button, parent = (gcn::Widget*)widget->getParent(); + if (widget->isEnabled() || force) { int widgetX, widgetY; widget->getAbsolutePosition(widgetX, widgetY); - gcn::MouseEvent mouseEvent(source, mShiftPressed, mControlPressed, - mAltPressed, mMetaPressed, type, button, - x - widgetX, y - widgetY, mClickCount); + mouseEvent.setX(x - widgetX); + mouseEvent.setY(y - widgetY); std::list<gcn::MouseListener*> mouseListeners = widget->_getMouseListeners(); diff --git a/src/gui/widgets/mouseevent.h b/src/gui/widgets/mouseevent.h new file mode 100644 index 000000000..7951e41ca --- /dev/null +++ b/src/gui/widgets/mouseevent.h @@ -0,0 +1,47 @@ +/* + * The Mana Client + * Copyright (C) 2009-2010 The Mana Developers + * + * This file is part of The Mana Client. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see <http://www.gnu.org/licenses/>. + */ + +#ifndef GUI_MOUSEEVENT_H +#define GUI_MOUSEEVENT_H + +#include <guichan/mouseevent.hpp> +#include <guichan/widget.hpp> + +class MouseEvent : public gcn::MouseEvent +{ + public: + MouseEvent(gcn::Widget* source, bool isShiftPressed, + bool isControlPressed, bool isAltPressed, bool isMetaPressed, + unsigned int type, unsigned int button, int x, int y, + int clickCount) : + gcn::MouseEvent(source, isShiftPressed, isControlPressed, + isAltPressed, isMetaPressed, type, button, x, y, + clickCount) + { + } + + void setX(int n) + { mX = n; } + + void setY(int n) + { mY = n; } +}; + +#endif |