Description
There is special casing for ctl / cmd in the Qt backend on OSX
matplotlib/lib/matplotlib/backends/backend_qt.py
Lines 49 to 51 in 9465538
That is making the tests fail.
Looking at a US mac keyboard on the left side I see:
ctrl | option | command
and looking at US windows keyboard I see
ctrl | meta (aka windows) | alt
however that does not tell us what keycodes they actually generate.
We used to implement this logic differently (before we unified the qt backend code)
3.4.3
matplotlib/lib/matplotlib/backends/backend_qt5.py
Lines 62 to 67 in 919145f
3.2.2
matplotlib/lib/matplotlib/backends/backend_qt5.py
Lines 70 to 85 in a1a5298
This swapping goes all the way back to 5fdd68a (2012).
I think we need to:
- have a mac user with a mac keyboard veryify that the keys they hit match the keycodes we expect
- if the keys are right to the human typing then fix the tests (probably by tweaking what the key-codes fed in are)
- if the keys are wrong to the human typing
- if they are consistent across mpl versions on osx: gnash our teeth in despair and figure out how we want to fix this (on one hand, we should make sure that the key-codes are consistent across platfroms, on the other hand we do not want to break existing OSX users).
- if they changed from 3.4 to the default branch, fix the re-mapping
I also have a worry that Qt has started to fix this for us.
FYI: I just ran the latest tests and these are now failing for me and I'm wondering if it has to do with being on a mac? The tests look like they are swapping cmd/ctrl, so I tried swapping the modifier keys on my system and that didn't help.
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-control] - AssertionError: assert 'cmd+a' == 'ctrl+a'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-alt_control] - AssertionError: assert 'alt+cmd' == 'alt+control'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-control_alt] - AssertionError: assert 'cmd+alt' == 'ctrl+alt'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-modifier_order] - AssertionError: assert 'cmd+alt+ctrl+á' == 'ctrl+alt+super+á'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[Qt5Agg-backspace_mod] - AssertionError: assert 'cmd+backspace' == 'ctrl+backspace'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[QtAgg-control] - AssertionError: assert 'cmd+a' == 'ctrl+a'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[QtAgg-alt_control] - AssertionError: assert 'alt+cmd' == 'alt+control'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[QtAgg-control_alt] - AssertionError: assert 'cmd+alt' == 'ctrl+alt'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[QtAgg-modifier_order] - AssertionError: assert 'cmd+alt+ctrl+á' == 'ctrl+alt+super+á'
FAILED lib/matplotlib/tests/test_backend_qt.py::test_correct_key[QtAgg-backspace_mod] - AssertionError: assert 'cmd+backspace' == 'ctrl+backspace'
It looks like these may be getting skipped on the macos-latest CI?
SKIPPED [22] lib/matplotlib/tests/test_backend_qt.py:168: No usable Qt bindings
Originally posted by @greglucas in #20868 (comment)