FS#1140 - [OSX] Moving map with scrolling touchpad

Attached to Project: OpenTTD
Opened by hanicka (hanicka) - Saturday, 18 August 2007, 18:04 GMT
Last edited by Remko Bijker (Rubidium) - Thursday, 04 February 2010, 14:22 GMT
Type Feature Request
Category Interface
Status Confirmed
Assigned To No-one
Operating System Mac OS X
Severity Very Low
Priority Low
Reported Version trunk
Due in Version Undecided
Due Date Undecided
Percent Complete 0%
Votes 2
Private No


When I try to scroll map and building railway (or highway, etc) map is not scrolling. After mouseup move jump to position as I scroll.
This task depends upon

Comment by hanicka (hanicka) - Saturday, 18 August 2007, 18:04 GMT
It's revision 10927
Comment by Hathor (Hathor) - Sunday, 19 August 2007, 23:44 GMT
I dont really understand how you are able to both scroll and build something ONLY with your mouse at the same time. Building takes left mouse button making the movement of the mouse the direction of the tracks to be build. Scrolling takes right mouse button making the movement change the viewport. From my point of view it is only possible to do both when you use mouse and keyboard, though I might be mistaken.
Comment by hanicka (hanicka) - Monday, 20 August 2007, 06:24 GMT
I don't using second button, I'm using scrolling feature of my touchpad (like apple mighty mouse), i have pressed button (only one button on apple touchpad) and scrolling use two fingers on touchpad. (My touchpad is multi touch on latest ibook G4). But game, when I building something, stop react on any scrolling event on touchpad, and after I release button, game will instantly move screen to position as I scroll during building. It's good to can scrolling when building (very long rails). This scrolling is like roling mouse roller.
Comment by Hathor (Hathor) - Monday, 20 August 2007, 11:10 GMT
Alright. I am not really using apple stuff nor do I have good knowledge about the games event handling, so I guess its better if some dev is giving his opinion on the matter.
Comment by Remko Bijker (Rubidium) - Tuesday, 21 August 2007, 21:47 GMT
So these touchpad issues are basically OSX specific as I cannot reproduce them on a non-OSX operating system?
Comment by hanicka (hanicka) - Wednesday, 22 August 2007, 07:49 GMT
No, You must set Configure Patches > Function of scrollwheel > Scroll Map. And rolling with mouse wheel.
Comment by Remko Bijker (Rubidium) - Thursday, 23 August 2007, 07:17 GMT
It actually is OSX specific; only OSX implements that function.
Comment by Emil Djupfeldt (egladil) - Wednesday, 02 January 2008, 10:46 GMT
The events appears to be cached at os level. This I deduced by trying how other applications (TextEdit, XCode and XChat Aqua) behave when trying to scroll with the touchpad while holding the mouse button down. However, I can't find any documentation about this at all. But there seem to be a way to circumvent the caching as Firefox does not suffer from it.
Comment by m1ss1ontomars2k4 (m1ss1ontomars2k4) - Saturday, 14 November 2009, 18:59 GMT
Zooming the map with the scroll wheel also does not work (at all) while building if that option is selected in the patches. The events do seem to get cached; this doesn't happen in any web browser that I use, Mail, or a variety of other apps, but it does happen in some apps.
Comment by Tyler (tyler) - Sunday, 15 November 2009, 01:23 GMT
I don't think it's cached, I put some debug lines in the event handling code, the scroll wheel event is firing even while I'm dragging to build roads etc. I noticed that when the scroll wheel action is set to Zoom, scrolling while dragging doesn't cause the zoom to be delayed, it doesn't happen at all. Not really sure what it all means yet though
Comment by Tyler (tyler) - Friday, 20 November 2009, 16:47 GMT
I think we should decide what we want the desired behavior to be. If we want one to be able to use the scroll wheel while building, we'll have to implement that for Zoom also. If not, we should fix it so that while in Move Map mode, nothing happens when scrolling-while-building (to bring it in line with zoom). My suggestion, since only one person has reported this, two years ago, is to choose the latter option.
Comment by Peter Thorson (thorvoquien) - Monday, 01 February 2010, 01:46 GMT
I took a look at this and think I have a fix.

OpenTTD keeps track of traditional 1 dimensional line based scrolling and 2 dimensional precision scrolling (as found in Apple trackpads, mighty mice, and magic mice) in completely different ways.

There are two issues here.
First is that the current mouse event handling code returns after handling the first event (ie drag) so it never has a chance to get to the scrolling part.

Second is that, 2D scrolling events get cached (in OpenTTD - not the OS) during other mouse events (drags, regular 1D scrolls of widgets, etc) and gets turned into one huge jump-scroll once the drag ends or the 1D scroll moves off of the widget you were scrolling.

The second issue (the actual bug part of it) can be fixed with a 2 line patch (see next comment for said patch)

The first issue isn't so much a bug as a feature request. I can see why you would want this behavior, I turn off edge of screen scrolling when I turn 2D trackpad scrolling on because its annoying and as a result have no way to scroll while dragging. It could probably be done pretty easily by checking, early in the MouseLoop handler whether there are queued v_wheel/h_wheel values and scrolling the viewport there before continuing to the actual event.

Tyler is definitely right though that we need to consider carefully what the desired behavior should be. I don't think it makes as much sense to be able to zoom while laying track? I think there might be some situations where you would want 2D pad scroll + dragging and some that you wouldn't. Should it be a config option or a separate gesture?

I also discovered a few other quirks with the precision 2D scrolling devices. They aren't really bugs, so much as not using the hardware to its full advantage. In particular there is a quirk on the magic mouse where accelerated scrolling continues for a little bit afterwards even if you use the above patch to clear all cached events before you start a 2D scroll. In general all the precision 2D scrolling devices can give us delta values in pixels rather than lines which would make scrolling with these devices much smoother.

I am going to continue looking into improving the support for the optional features of these scrolling devices, what is the best way to go about getting the fix for the 2D scrolling cache bug tested/reviewed/committed?
Comment by Peter Thorson (thorvoquien) - Monday, 01 February 2010, 03:23 GMT
Here is a diff of my 2D scrolling fix patch against the latest nightly
Comment by Remko Bijker (Rubidium) - Thursday, 04 February 2010, 14:22 GMT
That patch is applied in 19002.