diff options
author | bjarni <bjarni@openttd.org> | 2007-03-11 10:55:35 +0000 |
---|---|---|
committer | bjarni <bjarni@openttd.org> | 2007-03-11 10:55:35 +0000 |
commit | 50fe0fe059c0dd3af5acdfdfee144e10dc678157 (patch) | |
tree | b5331cf55f4eaf3f50d7092f65b2f19db44884e0 /src/window.cpp | |
parent | 6def45089d56bb59d87f0757807b3522980389d3 (diff) | |
download | openttd-50fe0fe059c0dd3af5acdfdfee144e10dc678157.tar.xz |
(svn r9111) -Feature: [OSX] mighty mice and touchpads can now scroll the map (in all directions)
It has to be enabled first (in patches->interface) first and this will disable scrollwheel zooming
Note: patch setting "Map scrollwheel speed" might need to be changed since the "correct" setting
appears to depend on what kind of mouse is in use (mighty mouse or touchpad)
Diffstat (limited to 'src/window.cpp')
-rw-r--r-- | src/window.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/window.cpp b/src/window.cpp index 9e26bee1d..41653e926 100644 --- a/src/window.cpp +++ b/src/window.cpp @@ -1390,11 +1390,13 @@ static bool HandleViewportScroll() WindowEvent e; Window *w; + bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0); + if (!_scrolling_viewport) return true; w = FindWindowFromPt(_cursor.pos.x, _cursor.pos.y); - if (!_right_button_down || w == NULL) { + if (!(_right_button_down || scrollwheel_scrolling) || w == NULL) { _cursor.fix_at = false; _scrolling_viewport = false; return true; @@ -1408,6 +1410,14 @@ static bool HandleViewportScroll() e.we.scroll.delta.y = _cursor.delta.y; } + if (scrollwheel_scrolling) { + /* We are using scrollwheels for scrolling */ + e.we.scroll.delta.x = _cursor.h_wheel; + e.we.scroll.delta.y = _cursor.v_wheel; + _cursor.v_wheel = 0; + _cursor.h_wheel = 0; + } + /* Create a scroll-event and send it to the window */ e.event = WE_SCROLL; w->wndproc(w, &e); @@ -1628,6 +1638,7 @@ void MouseLoop(int click, int mousewheel) int x,y; Window *w; ViewPort *vp; + bool scrollwheel_scrolling = _patches.scrollwheel_scrolling == 1 && (_cursor.v_wheel != 0 || _cursor.h_wheel != 0); DecreaseWindowCounters(); HandlePlacePresize(); @@ -1643,7 +1654,7 @@ void MouseLoop(int click, int mousewheel) x = _cursor.pos.x; y = _cursor.pos.y; - if (click == 0 && mousewheel == 0) return; + if (click == 0 && mousewheel == 0 && !scrollwheel_scrolling) return; w = FindWindowFromPt(x, y); if (w == NULL) return; @@ -1659,13 +1670,14 @@ void MouseLoop(int click, int mousewheel) /* Send WE_MOUSEWHEEL event to window */ e.event = WE_MOUSEWHEEL; e.we.wheel.wheel = mousewheel; - w->wndproc(w, &e); + if (!scrollwheel_scrolling) w->wndproc(w, &e); /* Dispatch a MouseWheelEvent for widgets if it is not a viewport */ if (vp == NULL) DispatchMouseWheelEvent(w, GetWidgetFromPos(w, x - w->left, y - w->top), mousewheel); } if (vp != NULL) { + if (scrollwheel_scrolling) click = 2; // we are using the scrollwheel in a viewport, so we emulate right mouse button switch (click) { case 1: DEBUG(misc, 2, "Cursor: 0x%X (%d)", _cursor.sprite, _cursor.sprite); |