Opened 7 years ago

Closed 7 years ago

Last modified 7 years ago

#1474 closed defect (fixed)

Magic Mouse zoom broken

Reported by: pett Owned by: Tom Goddard
Priority: major Milestone:
Component: General Controls Version:
Keywords: Cc:
Blocked By: Blocking:
Notify when closed: Platform: all
Project: ChimeraX

Description

The scroll-wheel emulation of swiping on the middle of an Apple Magic Mouse no longer zooms the main view.

Change History (4)

comment:1 by Tom Goddard, 7 years ago

Resolution: fixed
Status: assignedclosed

Fixed, sort of.

I made magic mouse scroll cause zooming provided a trackpad with multitouch enabled is not connected.

The problem was that macOS magic trackpad generates scroll events during a two-finger drag. There appears to be no way to suppress this at the macOS native API level or Qt level. If multitouch is enabled in ChimeraX then two-finger trackpad drag is supposed to rotate so we have to ignore the scroll events. But Qt and apparently native macOS APIs give no way to tell if the scroll event came from a magic mouse or a magic trackpad. This sad state is described at the bottom of Apple developer docs on "Handling Trackpad Events"

https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingTouchEvents/HandlingTouchEvents.html

"If a mouse event is generated by a touch event, the subtype of the mouse event is NSTouchEventSubtype. You could evaluate mouse-event objects to determine when to ignore mouse events in favor of touch events when both are generated. (This advice is not applicable to scroll wheel events.)"

Previously I used code that simply discards scroll (ie wheel) events if any touch event was received in the past second. Unfortunately other bugs in Qt 5.9 prevent this from working reliably. Sometimes touch events are not generated from the trackpad and only wheel events. This happens after clicking into the Log panel or Volume Viewer histogram and then trying a two finger drag in the graphics window. Only the second two-finger drag works. The current code prevents the first two-finger drag from zooming, where the time-based filtering has the first two-finger drag zooming and the second rotating.

Let's see if the current compromise in which bugs are worse is acceptable. Users with only a trackpad or only a magic mouse should get good behavior.

comment:2 by Tom Goddard, 7 years ago

Ticket #427 describes some of the difficulties implementing multitouch which is disabled in Qt 5.11 and has been disabled for more than 5 years. It is not surprising that it works poorly.

comment:3 by Tom Goddard, 7 years ago

The fix to allow Magic Mouse scroll to zoom is no longer working. Tests on two 2017 iMac computers with Magic Mouse 2 and a 2012 iMac with Magic Mouse indicate that scrolling has no effect unless the default ChimeraX Trackpad preference to enable multitouch is turned off.

comment:4 by Tom Goddard, 7 years ago

Fixed.

I made Magic Mouse scroll do zooming unless a multitouch trackpad event is received in which case scroll zoom is disabled because there is no way in Qt to distinguish a trackpad two-finger drag (rotation) which always produces a QWheelEvent from a scroll produced by the Magic Mouse. A scroll on a wired mouse will always work as it is recognized as a non-synthesized scroll event.

This fix has the unpleasant unexpected consequence that Magic Mouse scroll works, but mysteriously stops working once the trackpad is used. I couldn't figure out any better compromise given the deficiencies in Qt multitouch.

Note: See TracTickets for help on using tickets.