Skip to content

Commit

Permalink
Cocoa: make "Send correct mouse buttons for tablets" optional
Browse files Browse the repository at this point in the history
Add an env variable QT_MAC_TABLET_IGNORE_BUTTON_MAPPING which, if set,
reverts to the old behavior.

The issues that it fixes are:
1) With a Genius tablet, it's not possible to generate a middle-click
at all, regardless of preferences, unless you set this variable
2) With a Wacom mouse (passive mouse used with an Intuos 3), the
side-buttons (normally mapped to forward and back buttons) do not
work unless you set this variable

[ChangeLog][macOS][Tablet support] If you have changed
the button mapping of your Wacom tablet in System Preferences,
it will be respected in Qt applications.  To revert to the
old behavior, set the environment variable
QT_MAC_TABLET_IGNORE_BUTTON_MAPPING

Task-number: QTBUG-57487
Task-number: QTBUG-54160
Change-Id: I0a1c9c6550e4dfe6ee2daa2d993f22691430826c
Reviewed-by: Andy Shaw <[email protected]>
  • Loading branch information
ec1oud committed Jan 2, 2018
1 parent 997dd02 commit 4f76c2d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/plugins/platforms/cocoa/qnsview.mm
Original file line number Diff line number Diff line change
Expand Up @@ -1064,6 +1064,8 @@ - (void)mouseExitedImpl:(NSEvent *)theEvent

- (bool)handleTabletEvent: (NSEvent *)theEvent
{
static bool ignoreButtonMapping = qEnvironmentVariableIsSet("QT_MAC_TABLET_IGNORE_BUTTON_MAPPING");

if (!m_platformWindow)
return false;

Expand Down Expand Up @@ -1112,14 +1114,15 @@ - (bool)handleTabletEvent: (NSEvent *)theEvent
rotation -= 360.0;

Qt::KeyboardModifiers keyboardModifiers = [QNSView convertKeyModifiers:[theEvent modifierFlags]];
Qt::MouseButtons buttons = ignoreButtonMapping ? static_cast<Qt::MouseButtons>(static_cast<uint>([theEvent buttonMask])) : m_buttons;

qCDebug(lcQpaTablet, "event on tablet %d with tool %d type %d unique ID %lld pos %6.1f, %6.1f root pos %6.1f, %6.1f buttons 0x%x pressure %4.2lf tilt %d, %d rotation %6.2lf",
deviceId, deviceData.device, deviceData.pointerType, deviceData.uid,
windowPoint.x(), windowPoint.y(), screenPoint.x(), screenPoint.y(),
static_cast<uint>(m_buttons), pressure, xTilt, yTilt, rotation);
static_cast<uint>(buttons), pressure, xTilt, yTilt, rotation);

QWindowSystemInterface::handleTabletEvent(m_platformWindow->window(), timestamp, windowPoint, screenPoint,
deviceData.device, deviceData.pointerType, m_buttons, pressure, xTilt, yTilt,
deviceData.device, deviceData.pointerType, buttons, pressure, xTilt, yTilt,
tangentialPressure, rotation, z, deviceData.uid,
keyboardModifiers);
return true;
Expand Down

0 comments on commit 4f76c2d

Please sign in to comment.