macOS: Fix mapping of Qt to Carbon modifiers with AA_MacDontSwapCtrlAndMeta
The macOS platform plugin function toCarbonModifiers is based on a mapping table with already swapped modifiers, where Qt::MetaModifier maps to controlKey. We were using the Carbon fooKeyBit constants instead of the fooKey constants, so the logic for mapping from Qt to Carbon modifiers when AA_MacDontSwapCtrlAndMeta was set to true would fail to reverse the swap from the mapping table. Since the command and control modifiers rarely produce different unicode characters from the base keyboard layout, at least not in the tested key layouts, and the AA_MacDontSwapCtrlAndMeta is not commonly used, this bug was not that visible. The logic maintains the behavior of mapping a single Qt modifier to multiple Carbon modifiers (both left and right command e.g.). This is a bit weird, but existing behavior that should be looked at in a followup. Change-Id: I8b30854770d1230a47f5144bf3245d0ac1493b51 Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This commit is contained in:
parent
fdc5e91dcf
commit
7b2cc3fc75
@ -119,11 +119,11 @@ static CarbonModifiers toCarbonModifiers(Qt::KeyboardModifiers qtModifiers)
|
|||||||
|
|
||||||
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
|
if (qApp->testAttribute(Qt::AA_MacDontSwapCtrlAndMeta)) {
|
||||||
int oldModifiers = carbonModifiers;
|
int oldModifiers = carbonModifiers;
|
||||||
carbonModifiers &= ~(controlKeyBit | cmdKeyBit);
|
carbonModifiers &= ~(controlKey | rightControlKey | cmdKey);
|
||||||
if (oldModifiers & controlKeyBit)
|
if (oldModifiers & (controlKey | rightControlKey))
|
||||||
carbonModifiers |= cmdKeyBit;
|
carbonModifiers |= cmdKey;
|
||||||
if (oldModifiers & cmdKeyBit)
|
if (oldModifiers & cmdKey)
|
||||||
carbonModifiers |= controlKeyBit;
|
carbonModifiers |= (controlKey | rightControlKey);
|
||||||
}
|
}
|
||||||
return carbonModifiers;
|
return carbonModifiers;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user