summaryrefslogtreecommitdiff
path: root/src/window.cpp
diff options
context:
space:
mode:
authoralberth <alberth@openttd.org>2011-01-16 11:40:36 +0000
committeralberth <alberth@openttd.org>2011-01-16 11:40:36 +0000
commit32cd182ecc668874efdf9f30760fd67a2d8646c2 (patch)
tree4e4915f74087f863c8539cd3da16a361c3f6f083 /src/window.cpp
parent4a203e8a49b3f09f77ec8258e691745a88edfa56 (diff)
downloadopenttd-32cd182ecc668874efdf9f30760fd67a2d8646c2.tar.xz
(svn r21822) -Codechange: Merge event handling code.
Diffstat (limited to 'src/window.cpp')
-rw-r--r--src/window.cpp28
1 files changed, 7 insertions, 21 deletions
diff --git a/src/window.cpp b/src/window.cpp
index 89bad77a2..8263b717e 100644
--- a/src/window.cpp
+++ b/src/window.cpp
@@ -1429,38 +1429,24 @@ static void HandlePlacePresize()
*/
static EventState HandleMouseDragDrop()
{
- Window *w;
-
if (_special_mouse_mode != WSM_DRAGDROP) return ES_NOT_HANDLED;
if (_left_button_down && _cursor.delta.x == 0 && _cursor.delta.y == 0) return ES_HANDLED; // Dragging, but the mouse did not move.
- if (!_left_button_down) goto handle_dragdop;
-
- w = _thd.GetCallbackWnd();
+ Window *w = _thd.GetCallbackWnd();
if (w != NULL) {
/* Send an event in client coordinates. */
Point pt;
pt.x = _cursor.pos.x - w->left;
pt.y = _cursor.pos.y - w->top;
- w->OnMouseDrag(pt, GetWidgetFromPos(w, pt.x, pt.y));
- }
-
- return ES_HANDLED;
-
-handle_dragdop:
- w = _thd.GetCallbackWnd();
-
- if (w != NULL) {
- /* send an event in client coordinates. */
- Point pt;
- pt.x = _cursor.pos.x - w->left;
- pt.y = _cursor.pos.y - w->top;
- w->OnDragDrop(pt, GetWidgetFromPos(w, pt.x, pt.y));
+ if (_left_button_down) {
+ w->OnMouseDrag(pt, GetWidgetFromPos(w, pt.x, pt.y));
+ } else {
+ w->OnDragDrop(pt, GetWidgetFromPos(w, pt.x, pt.y));
+ }
}
- ResetObjectToPlace();
-
+ if (!_left_button_down) ResetObjectToPlace(); // Button released, finished dragging.
return ES_HANDLED;
}