summaryrefslogtreecommitdiff
path: root/src/gui
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-02-19 00:30:19 +0200
committerAndrei Karas <akaras@inbox.ru>2011-02-19 00:30:19 +0200
commitb9331fca5a0472890c388175f23c6c7f70ab8d7f (patch)
treeded661080cbadb2005c9c98d157e83f91d8cc615 /src/gui
parent0b10f0318b9f9ab308f04712698aa104bec21e29 (diff)
downloadmanaverse-b9331fca5a0472890c388175f23c6c7f70ab8d7f.tar.gz
manaverse-b9331fca5a0472890c388175f23c6c7f70ab8d7f.tar.bz2
manaverse-b9331fca5a0472890c388175f23c6c7f70ab8d7f.tar.xz
manaverse-b9331fca5a0472890c388175f23c6c7f70ab8d7f.zip
Fix race condition in guichan bugfix.
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/gui.cpp11
-rw-r--r--src/gui/widgets/mouseevent.h47
2 files changed, 55 insertions, 3 deletions
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