Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 1a3766c

Browse files
authored
Merge pull request #21269 from anntzer/pixeldelta
Don't use pixelDelta() on X11.
2 parents a8dccd5 + 58868ef commit 1a3766c

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

lib/matplotlib/backends/backend_qt.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -312,8 +312,10 @@ def mouseReleaseEvent(self, event):
312312

313313
def wheelEvent(self, event):
314314
x, y = self.mouseEventCoords(self._get_position(event))
315-
# from QWheelEvent::delta doc
316-
if event.pixelDelta().x() == 0 and event.pixelDelta().y() == 0:
315+
# from QWheelEvent::pixelDelta doc: pixelDelta is sometimes not
316+
# provided (`isNull()`) and is unreliable on X11 ("xcb").
317+
if (event.pixelDelta().isNull()
318+
or QtWidgets.QApplication.instance().platformName() == "xcb"):
317319
steps = event.angleDelta().y() / 120
318320
else:
319321
steps = event.pixelDelta().y()

0 commit comments

Comments
 (0)